├── .gitattributes ├── .gitignore ├── README.md ├── build.ps1 ├── help └── xunit.shfb ├── license.txt ├── nuget.config ├── samples ├── AssertExamples │ ├── AssertExamples.csproj │ ├── AsyncExamples.cs │ ├── CollectionExample.cs │ ├── EqualExample.cs │ └── packages.config ├── AssertExtensions │ ├── AssertExtensions.csproj │ ├── BooleanAssertionExtensions.cs │ ├── CollectionAssertionExtensions.cs │ ├── ExampleFacts.cs │ ├── ObjectAssertExtensions.cs │ ├── StringAssertionExtensions.cs │ └── packages.config ├── AssumeIdentity │ ├── AssumeIdentity.csproj │ ├── AssumeIdentityAttribute.cs │ ├── AssumeIdentityAttributeTests.cs │ └── packages.config ├── ClassFixtureExample │ ├── App.config │ ├── ClassFixtureExample.csproj │ ├── ClassFixtureTests.cs │ ├── DatabaseFixture.cs │ ├── DatabaseFixture.mdf │ ├── DatabaseFixture_log.LDF │ └── packages.config ├── CollectionFixtureExample │ ├── CollectionFixtureExample.csproj │ ├── ConnectionFacts.cs │ ├── DatabaseCollection.cs │ ├── DatabaseFixture.cs │ ├── DatabaseFixture.mdf │ ├── DatabaseFixture_log.ldf │ ├── InsertTests.cs │ ├── app.config │ └── packages.config ├── ExcelDataExample │ ├── AcceptanceTestData.xls │ ├── ExcelDataAttribute.cs │ ├── ExcelDataExample.csproj │ ├── ExcelDataExamples.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── UnitTestData.xls │ └── packages.config ├── GlobalAssemblyInfo.cs ├── Samples.sln ├── SpecificationExamples │ ├── SpecificationBaseStyle │ │ ├── ObservationAttribute.cs │ │ ├── SpecificationBase.cs │ │ └── SpecificationBaseRunner.cs │ ├── SpecificationExamples.csproj │ ├── Stack.cs │ ├── StackSpecificationBaseExample.cs │ ├── StackSubSpecExample.cs │ ├── SubSpec │ │ ├── ExceptionTestCommand.cs │ │ ├── SpecificationAttribute.cs │ │ ├── SpecificationContext.cs │ │ └── SpecificationExtensions.cs │ └── packages.config ├── Stack │ ├── Stack.cs │ ├── Stack.csproj │ ├── StackTests.cs │ └── packages.config ├── TestOrderExamples │ ├── AlphabeticalOrderExample.cs │ ├── AlphabeticalOrderer.cs │ ├── PriorityOrderExamples.cs │ ├── PriorityOrderer.cs │ ├── TestOrderExamples.csproj │ ├── TestPriorityAttribute.cs │ └── packages.config ├── TracingExample │ ├── Example.cs │ ├── TracingExample.csproj │ ├── TracingSplicerAttribute.cs │ └── packages.config ├── TraitExtensibility │ ├── CategoryAttribute.cs │ ├── CategoryDiscoverer.cs │ ├── Example.cs │ ├── TraitExtensibility.csproj │ └── packages.config └── UseCulture │ ├── UseCulture.csproj │ ├── UseCultureAttribute.cs │ ├── UseCultureAttributeTests.cs │ └── packages.config ├── src ├── CodeAnalysisDictionary.xml ├── common │ ├── Application.ico │ ├── AssemblyExtensions.cs │ ├── DictionaryExtensions.cs │ ├── DisposableExtensions.cs │ ├── ExceptionExtensions.cs │ ├── GlobalAssemblyInfo.cs │ ├── Guard.cs │ ├── SerializationInfoExtensions.cs │ ├── SourceInformation.cs │ ├── TestDiscoveryVisitor.cs │ ├── TestOptionsNames.cs │ └── XmlTestExecutionVisitor.cs ├── signing.snk ├── xunit.abstractions.net35 │ └── xunit.abstractions.net35.csproj ├── xunit.abstractions.nuspec ├── xunit.abstractions.pcl │ └── xunit.abstractions.pcl.csproj ├── xunit.abstractions │ ├── Frameworks │ │ ├── ISourceInformation.cs │ │ ├── ISourceInformationProvider.cs │ │ ├── ITestFramework.cs │ │ ├── ITestFrameworkDiscoverer.cs │ │ ├── ITestFrameworkExecutor.cs │ │ └── ITestFrameworkOptions.cs │ ├── GlobalSuppressions.cs │ ├── Messages │ │ ├── BaseInterfaces │ │ │ ├── IFinishedMessage.cs │ │ │ ├── IMessageSink.cs │ │ │ ├── IMessageSinkMessage.cs │ │ │ ├── ITestCaseMessage.cs │ │ │ ├── ITestClassMessage.cs │ │ │ ├── ITestCollectionMessage.cs │ │ │ ├── ITestMessage.cs │ │ │ └── ITestResultMessage.cs │ │ ├── IAfterTestFinished.cs │ │ ├── IAfterTestStarting.cs │ │ ├── IBeforeTestFinished.cs │ │ ├── IBeforeTestStarting.cs │ │ ├── IDiscoveryCompleteMessage.cs │ │ ├── IErrorMessage.cs │ │ ├── IFailureInformation.cs │ │ ├── ITestAssemblyFinished.cs │ │ ├── ITestAssemblyStarting.cs │ │ ├── ITestCaseDiscoveryMessage.cs │ │ ├── ITestCaseFinished.cs │ │ ├── ITestCaseStarting.cs │ │ ├── ITestClassConstructionFinished.cs │ │ ├── ITestClassConstructionStarting.cs │ │ ├── ITestClassDisposeFinished.cs │ │ ├── ITestClassDisposeStarting.cs │ │ ├── ITestClassFinished.cs │ │ ├── ITestClassStarting.cs │ │ ├── ITestCollectionFinished.cs │ │ ├── ITestCollectionStarting.cs │ │ ├── ITestFailed.cs │ │ ├── ITestFinished.cs │ │ ├── ITestMethodFinished.cs │ │ ├── ITestMethodStarting.cs │ │ ├── ITestPassed.cs │ │ ├── ITestSkipped.cs │ │ └── ITestStarting.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Reflection │ │ ├── IAssemblyInfo.cs │ │ ├── IAttributeInfo.cs │ │ ├── IMethodInfo.cs │ │ ├── IParameterInfo.cs │ │ ├── IReflectionAssemblyInfo.cs │ │ ├── IReflectionAttributeInfo.cs │ │ ├── IReflectionMethodInfo.cs │ │ ├── IReflectionParameterInfo.cs │ │ ├── IReflectionTypeInfo.cs │ │ └── ITypeInfo.cs │ ├── TestCases │ │ ├── ITestCase.cs │ │ └── ITestCollection.cs │ ├── xunit.abstractions.projitems │ └── xunit.abstractions.shproj ├── xunit.assert.source.nuspec ├── xunit.assert │ ├── Asserts │ │ ├── Assert.cs │ │ ├── BooleanAsserts.cs │ │ ├── CollectionAsserts.cs │ │ ├── Comparers.cs │ │ ├── EqualityAsserts.cs │ │ ├── ExceptionAsserts.cs │ │ ├── Guards.cs │ │ ├── IdentityAsserts.cs │ │ ├── NullAsserts.cs │ │ ├── PropertyAsserts.cs │ │ ├── RangeAsserts.cs │ │ ├── Record.cs │ │ ├── Sdk │ │ │ ├── AssertComparer.cs │ │ │ ├── AssertEqualityComparer.cs │ │ │ ├── AssertEqualityComparerAdapter.cs │ │ │ └── Exceptions │ │ │ │ ├── AssertActualExpectedException.cs │ │ │ │ ├── AssertCollectionCountException.cs │ │ │ │ ├── CollectionException.cs │ │ │ │ ├── ContainsException.cs │ │ │ │ ├── DoesNotContainException.cs │ │ │ │ ├── DoesNotMatchException.cs │ │ │ │ ├── DoesNotThrowException.cs │ │ │ │ ├── EmptyException.cs │ │ │ │ ├── EndsWithException.cs │ │ │ │ ├── EqualException.cs │ │ │ │ ├── FalseException.cs │ │ │ │ ├── InRangeException.cs │ │ │ │ ├── IsAssignableFromException.cs │ │ │ │ ├── IsNotTypeException.cs │ │ │ │ ├── IsTypeException.cs │ │ │ │ ├── MatchesException.cs │ │ │ │ ├── NoneException.cs │ │ │ │ ├── NotEmptyException.cs │ │ │ │ ├── NotEqualException.cs │ │ │ │ ├── NotInRangeException.cs │ │ │ │ ├── NotNullException.cs │ │ │ │ ├── NotSameException.cs │ │ │ │ ├── NullException.cs │ │ │ │ ├── ParameterCountMismatchException.cs │ │ │ │ ├── ProperSubsetException.cs │ │ │ │ ├── ProperSupersetException.cs │ │ │ │ ├── PropertyChangedException.cs │ │ │ │ ├── SameException.cs │ │ │ │ ├── SingleException.cs │ │ │ │ ├── StartsWithException.cs │ │ │ │ ├── SubsetException.cs │ │ │ │ ├── SupersetException.cs │ │ │ │ ├── ThrowsException.cs │ │ │ │ ├── TimeoutException.cs │ │ │ │ ├── TrueException.cs │ │ │ │ └── XunitException.cs │ │ ├── SetAsserts.cs │ │ ├── StringAsserts.cs │ │ └── TypeAsserts.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── xunit.assert.csproj │ └── xunit.assert.nuspec ├── xunit.console │ ├── App.config │ ├── CommandLine.cs │ ├── Config │ │ ├── TransformConfigurationElement.cs │ │ ├── TransformConfigurationElementCollection.cs │ │ └── XunitConsoleConfigurationSection.cs │ ├── HTML.xslt │ ├── ParallelismOption.cs │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── RunnerCallbacks │ │ ├── RunnerCallback.cs │ │ ├── StandardRunnerCallback.cs │ │ └── TeamCityRunnerCallback.cs │ ├── Utility │ │ ├── StackFrameTransformer.cs │ │ ├── Transform.cs │ │ └── TransformFactory.cs │ ├── Visitors │ │ ├── StandardOutputVisitor.cs │ │ └── TeamCityVisitor.cs │ ├── xUnit1.xslt │ └── xunit.console.csproj ├── xunit.core.nuspec ├── xunit.core │ ├── CollectionAttribute.cs │ ├── CollectionBehavior.cs │ ├── CollectionBehaviorAttribute.cs │ ├── CollectionDefinitionAttribute.cs │ ├── FactAttribute.cs │ ├── IClassFixture.cs │ ├── ICollectionFixture.cs │ ├── InlineDataAttribute.cs │ ├── MemberDataAttribute.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Sdk │ │ ├── ArgumentFormatter.cs │ │ ├── BeforeAfterTestAttribute.cs │ │ ├── DataAttribute.cs │ │ ├── DataDiscoverer.cs │ │ ├── DataDiscovererAttribute.cs │ │ ├── ExceptionAggregator.cs │ │ ├── IDataDiscoverer.cs │ │ ├── IMessageAggregator.cs │ │ ├── IMessageBus.cs │ │ ├── ITestCaseOrderer.cs │ │ ├── ITraitAttribute.cs │ │ ├── ITraitDiscoverer.cs │ │ ├── IXunitTestCase.cs │ │ ├── IXunitTestCaseDiscoverer.cs │ │ ├── IXunitTestCollectionFactory.cs │ │ ├── InlineDataDiscoverer.cs │ │ ├── RunSummary.cs │ │ ├── TraitDiscoverer.cs │ │ ├── TraitDiscovererAttribute.cs │ │ └── XunitTestCaseDiscovererAttribute.cs │ ├── TestCaseOrdererAttribute.cs │ ├── TestFrameworkAttribute.cs │ ├── TheoryAttribute.cs │ ├── TheoryData.cs │ ├── TraitAttribute.cs │ ├── build │ │ └── xunit.core.props │ ├── xunit.core.csproj │ └── xunit.core.dll.tdnet ├── xunit.empty.ruleset ├── xunit.execution │ ├── Extensions │ │ └── ReflectionAbstractionExtensions.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Sdk │ │ ├── AsyncTestSyncContext.cs │ │ ├── DefaultTestCaseOrderer.cs │ │ ├── DisposalTracker.cs │ │ ├── EnvironmentalWarning.cs │ │ ├── ExceptionUtility.cs │ │ ├── ExtensibilityPointFactory.cs │ │ ├── Frameworks │ │ │ ├── CollectionPerAssemblyTestCollectionFactory.cs │ │ │ ├── CollectionPerClassTestCollectionFactory.cs │ │ │ ├── FactDiscoverer.cs │ │ │ ├── LambdaTestCase.cs │ │ │ ├── Runners │ │ │ │ ├── TestAssemblyRunner.cs │ │ │ │ ├── TestClassRunner.cs │ │ │ │ ├── TestCollectionRunner.cs │ │ │ │ ├── TestMethodRunner.cs │ │ │ │ ├── XunitTestAssemblyRunner.cs │ │ │ │ ├── XunitTestClassRunner.cs │ │ │ │ ├── XunitTestCollectionRunner.cs │ │ │ │ └── XunitTestMethodRunner.cs │ │ │ ├── TestCollectionComparer.cs │ │ │ ├── TestCollectionFactoryHelper.cs │ │ │ ├── TestFramework.cs │ │ │ ├── TestFrameworkDiscoverer.cs │ │ │ ├── TestFrameworkExecutor.cs │ │ │ ├── TestFrameworkProxy.cs │ │ │ ├── TheoryDiscoverer.cs │ │ │ ├── XunitTestCase.cs │ │ │ ├── XunitTestCollection.cs │ │ │ ├── XunitTestFramework.cs │ │ │ ├── XunitTestFrameworkDiscoverer.cs │ │ │ ├── XunitTestFrameworkExecutor.cs │ │ │ └── XunitTheoryTestCase.cs │ │ ├── LongLivedMarshalByRefObject.cs │ │ ├── MaxConcurrencyTaskScheduler.cs │ │ ├── MessageAggregator.cs │ │ ├── MessageBus.cs │ │ ├── Messages │ │ │ ├── AfterTestFinished.cs │ │ │ ├── AfterTestStarting.cs │ │ │ ├── BaseMessages │ │ │ │ ├── TestCaseMessage.cs │ │ │ │ ├── TestClassMessage.cs │ │ │ │ ├── TestCollectionMessage.cs │ │ │ │ ├── TestMessage.cs │ │ │ │ └── TestResultMessage.cs │ │ │ ├── BeforeTestFinished.cs │ │ │ ├── BeforeTestStarting.cs │ │ │ ├── DelegatingMessageBus.cs │ │ │ ├── DelegatingMessageSink.cs │ │ │ ├── DiscoveryCompleteMessage.cs │ │ │ ├── ErrorMessage.cs │ │ │ ├── TestAssemblyFinished.cs │ │ │ ├── TestAssemblyStarting.cs │ │ │ ├── TestCaseDiscoveryMessage.cs │ │ │ ├── TestCaseFinished.cs │ │ │ ├── TestCaseStarting.cs │ │ │ ├── TestClassConstructionFinished.cs │ │ │ ├── TestClassConstructionStarting.cs │ │ │ ├── TestClassDisposeFinished.cs │ │ │ ├── TestClassDisposeStarting.cs │ │ │ ├── TestClassFinished.cs │ │ │ ├── TestClassStarting.cs │ │ │ ├── TestCollectionFinished.cs │ │ │ ├── TestCollectionStarting.cs │ │ │ ├── TestFailed.cs │ │ │ ├── TestFinished.cs │ │ │ ├── TestMethodFinished.cs │ │ │ ├── TestMethodStarting.cs │ │ │ ├── TestPassed.cs │ │ │ ├── TestSkipped.cs │ │ │ └── TestStarting.cs │ │ ├── Reflection │ │ │ ├── ReflectionAssemblyInfo.cs │ │ │ ├── ReflectionAttributeInfo.cs │ │ │ ├── ReflectionMethodInfo.cs │ │ │ ├── ReflectionParameterInfo.cs │ │ │ ├── ReflectionTypeInfo.cs │ │ │ └── Reflector.cs │ │ ├── SerializationHelper.cs │ │ ├── SynchronousMessageBus.cs │ │ ├── TestClassException.cs │ │ └── TestMessageVisitor.cs │ ├── xunit.execution.csproj │ └── xunit.execution.nuspec ├── xunit.nuspec ├── xunit.ruleset ├── xunit.runner.msbuild │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Utility │ │ └── TraitParser.cs │ ├── Visitors │ │ ├── MSBuildVisitor.cs │ │ ├── StandardOutputVisitor.cs │ │ └── TeamCityVisitor.cs │ ├── xunit.cs │ └── xunit.runner.msbuild.csproj ├── xunit.runner.tdnet │ ├── Extensions │ │ └── XunitExtension.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── TdNetLogger.cs │ ├── TdNetRunner.cs │ ├── TdNetRunnerHelper.cs │ ├── Visitors │ │ └── ResultVisitor.cs │ └── xunit.runner.tdnet.csproj ├── xunit.runner.utility │ ├── Frameworks │ │ ├── IFrontController.cs │ │ ├── NullSourceInformationProvider.cs │ │ ├── RemoteAppDomainManager.cs │ │ ├── TestFrameworkOptions.cs │ │ ├── VisualStudioSourceInformationProvider.cs │ │ ├── XunitFrontController.cs │ │ ├── v1 │ │ │ ├── IXunit1Executor.cs │ │ │ ├── RunSummary.cs │ │ │ ├── TestClassCallbackHandler.cs │ │ │ ├── XmlNodeCallbackHandler.cs │ │ │ ├── XmlNodeExtensions.cs │ │ │ ├── Xunit1.cs │ │ │ ├── Xunit1AssemblyInfo.cs │ │ │ ├── Xunit1ExceptionUtility.cs │ │ │ ├── Xunit1Executor.cs │ │ │ ├── Xunit1ReflectionWrapper.cs │ │ │ ├── Xunit1TestCase.cs │ │ │ └── Xunit1TestCollection.cs │ │ └── v2 │ │ │ ├── Xunit2.cs │ │ │ ├── Xunit2Discoverer.cs │ │ │ ├── XunitDiscoveryOptions.cs │ │ │ └── XunitExecutionOptions.cs │ ├── Project │ │ ├── XunitFilters.cs │ │ ├── XunitProject.cs │ │ └── XunitProjectAssembly.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Utility │ │ ├── AssemblyHelper.cs │ │ ├── DiaNavigationData.cs │ │ ├── DiaSession.cs │ │ ├── DiaSessionWrapper.cs │ │ ├── DiaSessionWrapperHelper.cs │ │ ├── ExceptionUtility.cs │ │ ├── ExecutionSummary.cs │ │ ├── LongLivedMarshalByRefObject.cs │ │ └── RemotingUtility.cs │ ├── Visitors │ │ └── TestMessageVisitor.cs │ ├── xunit.runner.utility.csproj │ └── xunit.runner.utility.nuspec ├── xunit.runner.visualstudio.nuspec ├── xunit.runner.visualstudio.settings │ ├── Guids.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── SettingsProvider.cs │ ├── XunitVisualStudioPackage.cs │ ├── XunitVisualStudioSettings.cs │ ├── [Content_Types].xml │ ├── extension.vsixmanifest │ ├── packages.config │ ├── xunit.runner.visualstudio.pkgdef │ └── xunit.runner.visualstudio.settings.csproj ├── xunit.runner.visualstudio.testadapter │ ├── Constants.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Settings │ │ ├── XunitTestRunSettings.cs │ │ ├── XunitTestRunSettingsProvider.cs │ │ └── XunitVisualStudioSettings.cs │ ├── Visitors │ │ ├── VsDiscoveryVisitor.cs │ │ └── VsExecutionVisitor.cs │ ├── VsTestRunner.cs │ ├── packages.config │ └── xunit.runner.visualstudio.testadapter.csproj └── xunit.runners.nuspec ├── test ├── GlobalTestAssemblyInfo.cs ├── test.utility │ ├── Abstractions │ │ ├── AssemblyWrapper.cs │ │ ├── AttributeWrapper.cs │ │ ├── MethodWrapper.cs │ │ ├── TestCase.cs │ │ ├── TestCollection.cs │ │ ├── TestFailed.cs │ │ ├── TestPassed.cs │ │ ├── TestSkipped.cs │ │ └── TypeWrapper.cs │ ├── AcceptanceTest.cs │ ├── AcceptanceTestAssembly.cs │ ├── CulturedFactAttribute.cs │ ├── CulturedFactAttributeDiscoverer.cs │ ├── CulturedXunitTestCase.cs │ ├── Mocks.cs │ ├── NSubstituteExtensions.cs │ ├── PreserveWorkingDirectoryAttribute.cs │ ├── SerializationUtility.cs │ ├── SpyBeforeAfterTest.cs │ ├── SpyMessageBus.cs │ ├── SpyMessageSink.cs │ ├── TempFile.cs │ ├── packages.config │ └── test.utility.csproj ├── test.xunit.assert │ ├── Asserts │ │ ├── BooleanAssertsTests.cs │ │ ├── CollectionAssertsTests.cs │ │ ├── EqualityAssertsTests.cs │ │ ├── ExceptionAssertsTests.cs │ │ ├── IdentityAssertsTests.cs │ │ ├── NullAssertsTests.cs │ │ ├── PropertyAssertsTests.cs │ │ ├── RangeAssertsTests.cs │ │ ├── RecordTests.cs │ │ ├── Sdk │ │ │ └── Exceptions │ │ │ │ ├── AssertActualExpectedExceptionTests.cs │ │ │ │ ├── EndsWithExceptionTests.cs │ │ │ │ ├── EqualExceptionTests.cs │ │ │ │ ├── StartsWithExceptionTests.cs │ │ │ │ └── XunitExceptionTests.cs │ │ ├── SetAssertsTests.cs │ │ ├── StringAssertsTests.cs │ │ └── TypeAssertsTests.cs │ ├── packages.config │ └── test.xunit.assert.csproj ├── test.xunit.console │ ├── CommandLineTests.cs │ ├── Utility │ │ ├── StackFrameTransformerTests.cs │ │ └── TransformFactoryFacts.cs │ ├── packages.config │ └── test.xunit.console.csproj ├── test.xunit.execution │ ├── Acceptance │ │ ├── AsyncAcceptanceTests.cs │ │ ├── CollectionAcceptanceTests.cs │ │ ├── FixtureAcceptanceTests.cs │ │ ├── Xunit2AcceptanceTests.cs │ │ └── Xunit2TheoryAcceptanceTests.cs │ ├── Common │ │ └── XmlTestExecutionVisitorTests.cs │ ├── Sdk │ │ ├── ArgumentFormatterTests.cs │ │ ├── DefaultTestCaseOrdererTests.cs │ │ ├── Frameworks │ │ │ ├── CollectionPerAssemblyTestCollectionFactoryTests.cs │ │ │ ├── CollectionPerClassTestCollectionFactoryTests.cs │ │ │ ├── TheoryDiscovererTests.cs │ │ │ ├── XunitTestCaseTests.cs │ │ │ ├── XunitTestFrameworkDiscovererTests.cs │ │ │ └── XunitTheoryTestCaseTests.cs │ │ ├── MessageBusTests.cs │ │ ├── Reflection │ │ │ └── ReflectorTests.cs │ │ ├── SpyMessageSink.cs │ │ ├── SynchronousMessageBusTests.cs │ │ └── TestCaseSerializerTests.cs │ ├── SerializationTests.cs │ ├── packages.config │ └── test.xunit.execution.csproj ├── test.xunit.runner.msbuild │ ├── Utility │ │ ├── SpyLogger.cs │ │ └── TraitParserTests.cs │ ├── Visitors │ │ ├── StandardOutputVisitorTests.cs │ │ └── TeamCityVisitorTests.cs │ ├── packages.config │ ├── test.xunit.runner.msbuild.csproj │ └── xunitTests.cs ├── test.xunit.runner.tdnet │ ├── Extensions │ │ └── TestResultMessageExtensionsTests.cs │ ├── TdNetRunnerTests.cs │ ├── Visitors │ │ └── ResultVisitorTests.cs │ ├── packages.config │ └── test.xunit.runner.tdnet.csproj ├── test.xunit.runner.utility │ ├── Frameworks │ │ ├── v1 │ │ │ ├── TestClassCallbackHandlerTests.cs │ │ │ ├── Xunit1TestCaseTests.cs │ │ │ └── Xunit1Tests.cs │ │ └── v2 │ │ │ └── Xunit2Tests.cs │ ├── Project │ │ └── XunitFiltersTests.cs │ ├── SpyTestMessageVisitor.cs │ ├── Utility │ │ └── ExceptionUtilityTests.cs │ ├── Visitors │ │ ├── TestDiscoveryVisitorTests.cs │ │ └── TestMessageVisitorTests.cs │ ├── packages.config │ └── test.xunit.runner.utility.csproj ├── test.xunit.runner.visualstudio.testadapter │ ├── packages.config │ └── test.xunit.runner.visualstudio.testadapter.csproj └── test.xunit1 │ ├── packages.config │ ├── test.xunit1.csproj │ ├── utility │ ├── AcceptanceTest.cs │ ├── AcceptanceTestInNewAppDomain.cs │ ├── MockAssembly.cs │ ├── ResultXmlUtility.cs │ ├── SerializationUtility.cs │ ├── StubExecutorWrapper.cs │ ├── StubTestRunner.cs │ ├── StubTransformer.cs │ └── TestTimingAttribute.cs │ ├── xunit.extensions │ ├── AssumeIdentity │ │ ├── AssumeIdentityAttributeAcceptanceTests.cs │ │ └── AssumeIdentityAttributeFacts.cs │ ├── DataTheories │ │ ├── AcceptanceTests │ │ │ ├── AcceptanceTestData.xls │ │ │ ├── ClassDataAcceptanceTests.cs │ │ │ ├── ExcelDataAcceptanceTests.cs │ │ │ ├── InlineDataAcceptanceTests.cs │ │ │ ├── PropertyDataAcceptanceTests.cs │ │ │ └── TheoryAcceptanceTests.cs │ │ ├── DataAdapterDataAttributeTests.cs │ │ ├── GenericTheoryTests.cs │ │ ├── TheoryAttributeTests.cs │ │ ├── TheoryCommandTests.cs │ │ └── UnitTestData.xls │ └── FreezeClock │ │ ├── ClockFacts.cs │ │ ├── FreezeClockAttributeAcceptanceTests.cs │ │ └── FreezeClockAttributeFacts.cs │ └── xunit │ ├── AcceptanceTests │ ├── AbstractTestClassTests.cs │ ├── ApartmentAcceptanceTests.cs │ ├── AsyncAcceptanceTests.cs │ ├── ConfigFileAcceptanceTests.cs │ ├── ExecutorAssemblyNodeCallbackAcceptanceTests.cs │ ├── ExecutorCurrentDirectoryAcceptanceTests.cs │ ├── FactMethodWithArgumentsTests.cs │ ├── FailureTimingAcceptanceTests.cs │ ├── FixtureDataAcceptanceTests.cs │ ├── SkipAcceptanceTests.cs │ └── TestTimeoutTests.cs │ ├── ContainsTests.cs │ ├── DoesNotContainTests.cs │ ├── DoesNotThrowTests.cs │ ├── EmptyTests.cs │ ├── EqualTests.cs │ ├── FactAttributeTests.cs │ ├── FalseTests.cs │ ├── InRangeTests.cs │ ├── IsAssignableFromTests.cs │ ├── IsNotTypeTests.cs │ ├── IsTypeTests.cs │ ├── NotEmptyTests.cs │ ├── NotEqualTests.cs │ ├── NotInRangeTests.cs │ ├── NotNullTests.cs │ ├── NotSameTests.cs │ ├── NullTests.cs │ ├── PropertyChangedTests.cs │ ├── RecordTests.cs │ ├── SameTests.cs │ ├── Sdk │ ├── AfterTestExceptionTests.cs │ ├── Commands │ │ ├── ClassCommands │ │ │ ├── TestClassCommandFactoryTests.cs │ │ │ ├── TestClassCommandRunnerTests.cs │ │ │ └── TestClassCommandTests.cs │ │ └── TestCommands │ │ │ ├── BeforeAfterCommandTests.cs │ │ │ ├── ExceptionAndOutputCaptureCommandTests.cs │ │ │ ├── FactCommandTests.cs │ │ │ ├── LifetimeCommandTests.cs │ │ │ ├── SkipCommandTests.cs │ │ │ ├── TestCommandFactoryTests.cs │ │ │ ├── TestCommandTests.cs │ │ │ ├── TimedCommandTests.cs │ │ │ └── TimeoutCommandTests.cs │ ├── Exceptions │ │ ├── AssertActualExpectedExceptionTests.cs │ │ ├── AssertExceptionTests.cs │ │ ├── DoesNotThrowExceptionTests.cs │ │ ├── ExceptionRequirementTests.cs │ │ ├── InRangeExceptionTests.cs │ │ ├── NotInRangeExceptionTests.cs │ │ ├── ThrowsExceptionTests.cs │ │ └── TraceAssertExceptionTests.cs │ ├── ExecutorCallbackTests.cs │ ├── Results │ │ ├── AssemblyResultTests.cs │ │ ├── ClassResultTests.cs │ │ ├── CompositeResultsTests.cs │ │ ├── FailedResultTests.cs │ │ ├── MethodResultTests.cs │ │ ├── PassedResultTests.cs │ │ └── SkipResultTests.cs │ └── Utilities │ │ ├── MethodUtilityTests.cs │ │ ├── MultiValueDictionaryTests.cs │ │ ├── ReflectorTests.cs │ │ └── TypeUtilityTests.cs │ ├── SerializationTests.cs │ ├── SingleTests.cs │ ├── Stubs │ ├── FixtureSpy.cs │ ├── StubTestClassCommand.cs │ └── StubTestCommand.cs │ ├── ThrowsTests.cs │ └── TrueTests.cs ├── tools ├── TestDriven.Framework.dll ├── xUnitSummary.xsl ├── xunit.targets ├── xunit.tests.msbuild └── xunit.vsix.msbuild ├── xunit.msbuild └── xunit.sln /.gitattributes: -------------------------------------------------------------------------------- 1 | *.ico binary 2 | *.snk binary 3 | *.xls binary 4 | 5 | *.bat text 6 | *.config text 7 | *.cs text diff=csharp 8 | *.csproj text merge=union 9 | *.manifest text 10 | *.msbuild text 11 | *.nuspec text 12 | *.resx text merge=union 13 | *.ruleset text 14 | *.settings text 15 | *.shfb text 16 | *.targets text 17 | *.tdnet text 18 | *.txt text 19 | *.vb text 20 | *.vbproj text merge=union 21 | *.vsixmanifest text 22 | *.vstemplate text 23 | *.xml text 24 | *.xsl text 25 | *.xslt text 26 | *.xunit text 27 | 28 | *.sln text eol=crlf merge=union 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | [Bb]in 2 | [Oo]bj 3 | packages 4 | help 5 | 6 | *.suo 7 | *.user 8 | *.[Cc]ache 9 | *[Rr]esharper* 10 | *.zip 11 | *.suo 12 | *.user 13 | *.cache 14 | *.nupkg 15 | *.exe 16 | *.dll 17 | *.ncrunch* 18 | 19 | Test*.html 20 | Test*.xml 21 | 22 | Index.dat 23 | Storage.dat 24 | -------------------------------------------------------------------------------- /build.ps1: -------------------------------------------------------------------------------- 1 | param( 2 | [string]$target = "Test", 3 | [string]$verbosity = "minimal", 4 | [int]$maxCpuCount = 0 5 | ) 6 | 7 | # Kill all MSBUILD.EXE processes because they could very likely have a lock against our 8 | # MSBuild runner from when we last ran unit tests. 9 | get-process -name "msbuild" -ea SilentlyContinue | %{ stop-process $_.ID -force } 10 | 11 | $msbuilds = @(get-command msbuild -ea SilentlyContinue) 12 | if ($msbuilds.Count -eq 0) { 13 | $msbuild = join-path $env:windir "Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" 14 | } else { 15 | $msbuild = $msbuilds[0].Definition 16 | } 17 | 18 | if ($maxCpuCount -lt 1) { 19 | $maxCpuCountText = $Env:MSBuildProcessorCount 20 | } else { 21 | $maxCpuCountText = ":$maxCpuCount" 22 | } 23 | 24 | $allArgs = @("xunit.msbuild", "/m$maxCpuCountText", "/nologo", "/verbosity:$verbosity", "/t:$target", "/property:RequestedVerbosity=$verbosity", $args) 25 | & $msbuild $allArgs 26 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | Copyright 2014 Outercurve Foundation 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /nuget.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /samples/AssertExamples/AsyncExamples.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using Xunit; 4 | 5 | public class AsyncExamples 6 | { 7 | [Fact] 8 | public async void CodeThrowsAsync() 9 | { 10 | Func testCode = () => Task.Factory.StartNew(ThrowingMethod); 11 | 12 | var ex = await Assert.ThrowsAsync(testCode); 13 | 14 | Assert.IsType(ex); 15 | } 16 | 17 | [Fact] 18 | public async void RecordAsync() 19 | { 20 | Func testCode = () => Task.Factory.StartNew(ThrowingMethod); 21 | 22 | var ex = await Record.ExceptionAsync(testCode); 23 | 24 | Assert.IsType(ex); 25 | } 26 | 27 | [Fact] 28 | public async void CodeDoesNotThrow() 29 | { 30 | Func testCode = () => Task.Factory.StartNew(() => { }); 31 | 32 | await Assert.DoesNotThrowAsync(testCode); 33 | } 34 | 35 | void ThrowingMethod() 36 | { 37 | throw new NotImplementedException(); 38 | } 39 | } 40 | 41 | -------------------------------------------------------------------------------- /samples/AssertExamples/EqualExample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Xunit; 4 | 5 | public class EqualExample 6 | { 7 | [Fact] 8 | public void EqualStringIgnoreCase() 9 | { 10 | string expected = "TestString"; 11 | string actual = "teststring"; 12 | 13 | Assert.False(actual == expected); 14 | Assert.NotEqual(expected, actual); 15 | Assert.Equal(expected, actual, StringComparer.CurrentCultureIgnoreCase); 16 | } 17 | 18 | class DateComparer : IEqualityComparer 19 | { 20 | public bool Equals(DateTime x, DateTime y) 21 | { 22 | return x.Date == y.Date; 23 | } 24 | 25 | public int GetHashCode(DateTime obj) 26 | { 27 | return obj.GetHashCode(); 28 | } 29 | } 30 | 31 | [Fact] 32 | public void DateShouldBeEqualEvenThoughTimesAreDifferent() 33 | { 34 | DateTime firstTime = DateTime.Now.Date; 35 | DateTime later = firstTime.AddMinutes(90); 36 | 37 | Assert.NotEqual(firstTime, later); 38 | Assert.Equal(firstTime, later, new DateComparer()); 39 | } 40 | } -------------------------------------------------------------------------------- /samples/AssertExamples/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/AssertExtensions/ExampleFacts.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit; 3 | using Xunit.Extensions.AssertExtensions; 4 | 5 | 6 | public class ExampleFacts 7 | { 8 | public class BooleanFacts 9 | { 10 | [Fact] 11 | public void ShouldBeTrue() 12 | { 13 | Boolean val = true; 14 | 15 | val.ShouldBeTrue(); 16 | } 17 | 18 | [Fact] 19 | public void ShouldBeFalse() 20 | { 21 | Boolean val = false; 22 | 23 | val.ShouldBeFalse(); 24 | } 25 | 26 | [Fact] 27 | public void ShouldBeTrueWithMessage() 28 | { 29 | Boolean val = false; 30 | 31 | Exception exception = Record.Exception(() => val.ShouldBeTrue("should be true")); 32 | 33 | Assert.Equal("should be true", exception.Message); 34 | } 35 | 36 | [Fact] 37 | public void ShouldBeFalseWithMessage() 38 | { 39 | Boolean val = true; 40 | 41 | Exception exception = Record.Exception(() => val.ShouldBeFalse("should be false")); 42 | 43 | Assert.Equal("should be false", exception.Message); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /samples/AssertExtensions/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/AssumeIdentity/AssumeIdentityAttributeTests.cs: -------------------------------------------------------------------------------- 1 | using System.Security; 2 | using System.Security.Permissions; 3 | using System.Threading; 4 | using Xunit; 5 | 6 | public class AssumeIdentityAttributeTests 7 | { 8 | [Fact, AssumeIdentity("casper")] 9 | public void AttributeChangesRoleInTestMethod() 10 | { 11 | Assert.True(Thread.CurrentPrincipal.IsInRole("casper")); 12 | } 13 | 14 | [Fact] 15 | public void CallingSecuredMethodWillThrow() 16 | { 17 | Assert.Throws(() => DefeatVillian()); 18 | } 19 | 20 | [Fact, AssumeIdentity("Q")] 21 | public void CallingSecuredMethodWithWrongIdentityWillThrow() 22 | { 23 | Assert.Throws(() => DefeatVillian()); 24 | } 25 | 26 | [Fact, AssumeIdentity("007")] 27 | public void CallingSecuredMethodWithAssumedIdentityPasses() 28 | { 29 | Assert.DoesNotThrow(() => DefeatVillian()); 30 | } 31 | 32 | [PrincipalPermission(SecurityAction.Demand, Role = "007")] 33 | public void DefeatVillian() { } 34 | } -------------------------------------------------------------------------------- /samples/AssumeIdentity/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/ClassFixtureExample/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/ClassFixtureExample/ClassFixtureTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Configuration; 3 | using System.Data.SqlClient; 4 | using Xunit; 5 | 6 | public class ClassFixtureTests : IClassFixture 7 | { 8 | DatabaseFixture database; 9 | 10 | public ClassFixtureTests(DatabaseFixture data) 11 | { 12 | database = data; 13 | } 14 | 15 | [Fact] 16 | public void ConnectionIsEstablished() 17 | { 18 | Assert.NotNull(database.Connection); 19 | } 20 | 21 | [Fact] 22 | public void FooUserWasInserted() 23 | { 24 | string sql = "SELECT COUNT(*) FROM Users WHERE ID = @id;"; 25 | 26 | using (SqlCommand cmd = new SqlCommand(sql, database.Connection)) 27 | { 28 | cmd.Parameters.AddWithValue("@id", database.FooUserID); 29 | 30 | int rowCount = Convert.ToInt32(cmd.ExecuteScalar()); 31 | 32 | Assert.Equal(1, rowCount); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /samples/ClassFixtureExample/DatabaseFixture.mdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamarin/xunit/ddd38e486e722ac3ded0435068f8e33f1d4f87d1/samples/ClassFixtureExample/DatabaseFixture.mdf -------------------------------------------------------------------------------- /samples/ClassFixtureExample/DatabaseFixture_log.LDF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamarin/xunit/ddd38e486e722ac3ded0435068f8e33f1d4f87d1/samples/ClassFixtureExample/DatabaseFixture_log.LDF -------------------------------------------------------------------------------- /samples/ClassFixtureExample/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/CollectionFixtureExample/ConnectionFacts.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Xunit; 7 | 8 | [Collection("DatabaseCollection")] 9 | public class ConnectionTests 10 | { 11 | DatabaseFixture database; 12 | 13 | public ConnectionTests(DatabaseFixture data) 14 | { 15 | database = data; 16 | } 17 | 18 | [Fact] 19 | public void ConnectionIsEstablished() 20 | { 21 | Assert.NotNull(database.Connection); 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /samples/CollectionFixtureExample/DatabaseCollection.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Xunit; 7 | 8 | [CollectionDefinition("DatabaseCollection")] 9 | public class DatabaseCollection : ICollectionFixture 10 | { 11 | } 12 | -------------------------------------------------------------------------------- /samples/CollectionFixtureExample/DatabaseFixture.mdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamarin/xunit/ddd38e486e722ac3ded0435068f8e33f1d4f87d1/samples/CollectionFixtureExample/DatabaseFixture.mdf -------------------------------------------------------------------------------- /samples/CollectionFixtureExample/DatabaseFixture_log.ldf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamarin/xunit/ddd38e486e722ac3ded0435068f8e33f1d4f87d1/samples/CollectionFixtureExample/DatabaseFixture_log.ldf -------------------------------------------------------------------------------- /samples/CollectionFixtureExample/InsertTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Data.SqlClient; 3 | using Xunit; 4 | 5 | [Collection("DatabaseCollection")] 6 | public class InsertTests 7 | { 8 | DatabaseFixture database; 9 | 10 | public InsertTests(DatabaseFixture fixture) 11 | { 12 | database = fixture; 13 | } 14 | 15 | [Fact] 16 | public void FooUserWasInserted() 17 | { 18 | string sql = "SELECT COUNT(*) FROM Users WHERE ID = @id;"; 19 | 20 | using (SqlCommand cmd = new SqlCommand(sql, database.Connection)) 21 | { 22 | cmd.Parameters.AddWithValue("@id", database.FooUserID); 23 | 24 | int rowCount = Convert.ToInt32(cmd.ExecuteScalar()); 25 | 26 | Assert.Equal(1, rowCount); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /samples/CollectionFixtureExample/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /samples/CollectionFixtureExample/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/ExcelDataExample/AcceptanceTestData.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamarin/xunit/ddd38e486e722ac3ded0435068f8e33f1d4f87d1/samples/ExcelDataExample/AcceptanceTestData.xls -------------------------------------------------------------------------------- /samples/ExcelDataExample/ExcelDataExamples.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq.Expressions; 3 | using Xunit; 4 | 5 | public class ExcelDataExamples 6 | { 7 | [Theory] 8 | [ExcelData("UnitTestData.xls", "select * from [Sheet1$A1:C5]")] 9 | public void ExcelXlsTests(int x, string y, string z) 10 | { 11 | Assert.NotEqual("Baz", z); 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /samples/ExcelDataExample/UnitTestData.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamarin/xunit/ddd38e486e722ac3ded0435068f8e33f1d4f87d1/samples/ExcelDataExample/UnitTestData.xls -------------------------------------------------------------------------------- /samples/ExcelDataExample/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/GlobalAssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.CodeAnalysis; 2 | using System.Reflection; 3 | 4 | [assembly: AssemblyCompany("Outercurve Foundation")] 5 | [assembly: AssemblyProduct("xUnit.net Testing Framework")] 6 | [assembly: AssemblyCopyright("Copyright (C) Outercurve Foundation")] 7 | [assembly: AssemblyVersion("2.0.0.0")] -------------------------------------------------------------------------------- /samples/SpecificationExamples/SpecificationBaseStyle/ObservationAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SpecificationBaseStyle 4 | { 5 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)] 6 | public class ObservationAttribute : Attribute { } 7 | } -------------------------------------------------------------------------------- /samples/SpecificationExamples/SpecificationBaseStyle/SpecificationBase.cs: -------------------------------------------------------------------------------- 1 | using Xunit; 2 | 3 | namespace SpecificationBaseStyle 4 | { 5 | [RunWith(typeof(SpecificationBaseRunner))] 6 | public abstract class SpecificationBase 7 | { 8 | protected virtual void Because() { } 9 | 10 | protected virtual void DestroyContext() { } 11 | 12 | protected virtual void EstablishContext() { } 13 | 14 | internal void OnFinish() 15 | { 16 | DestroyContext(); 17 | } 18 | 19 | internal void OnStart() 20 | { 21 | EstablishContext(); 22 | Because(); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /samples/SpecificationExamples/Stack.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | class Stack 5 | { 6 | readonly LinkedList elements = new LinkedList(); 7 | 8 | public bool IsEmpty 9 | { 10 | get { return elements.Count == 0; } 11 | } 12 | 13 | public void Push(T element) 14 | { 15 | elements.AddFirst(element); 16 | } 17 | 18 | public T Top 19 | { 20 | get 21 | { 22 | if (elements.Count == 0) 23 | throw new InvalidOperationException("cannot top an empty stack"); 24 | 25 | return elements.First.Value; 26 | } 27 | } 28 | 29 | public T Pop() 30 | { 31 | T top = Top; 32 | elements.RemoveFirst(); 33 | 34 | return top; 35 | } 36 | } -------------------------------------------------------------------------------- /samples/SpecificationExamples/SubSpec/SpecificationAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Xunit; 4 | using Xunit.Sdk; 5 | 6 | namespace SubSpec 7 | { 8 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)] 9 | public class SpecificationAttribute : FactAttribute 10 | { 11 | protected override IEnumerable EnumerateTestCommands(IMethodInfo method) 12 | { 13 | try 14 | { 15 | object obj = Activator.CreateInstance(method.MethodInfo.ReflectedType); 16 | method.Invoke(obj, null); 17 | return SpecificationContext.ToTestCommands(method); 18 | } 19 | catch (Exception ex) 20 | { 21 | return new ITestCommand[] { new ExceptionTestCommand(method, ex) }; 22 | } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /samples/SpecificationExamples/SubSpec/SpecificationExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SubSpec 4 | { 5 | public static class SpecificationExtensions 6 | { 7 | public static void Context(this string message, Action arrange) 8 | { 9 | SpecificationContext.Context(message, arrange); 10 | } 11 | 12 | public static void Do(this string message, Action act) 13 | { 14 | SpecificationContext.Do(message, act); 15 | } 16 | 17 | public static void Assert(this string message, Action assert) 18 | { 19 | SpecificationContext.Assert(message, assert); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /samples/SpecificationExamples/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/Stack/Stack.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | public class Stack 6 | { 7 | List elements = new List(); 8 | 9 | public int Count 10 | { 11 | get { return elements.Count; } 12 | } 13 | 14 | public bool Contains(T element) 15 | { 16 | return elements.Contains(element); 17 | } 18 | 19 | public T Peek() 20 | { 21 | if (Count == 0) 22 | throw new InvalidOperationException("empty stack"); 23 | 24 | return elements.Last(); 25 | } 26 | 27 | public T Pop() 28 | { 29 | T element = Peek(); 30 | elements.RemoveAt(Count - 1); 31 | return element; 32 | } 33 | 34 | public void Push(T element) 35 | { 36 | elements.Add(element); 37 | } 38 | } -------------------------------------------------------------------------------- /samples/Stack/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/TestOrderExamples/AlphabeticalOrderer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Xunit.Sdk; 5 | 6 | public class AlphabeticalOrderer : ITestCaseOrderer 7 | { 8 | public IEnumerable OrderTestCases(IEnumerable testCases) 9 | { 10 | var result = testCases.ToList(); 11 | result.Sort((x, y) => StringComparer.OrdinalIgnoreCase.Compare(x.Method.Name, y.Method.Name)); 12 | return result; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /samples/TestOrderExamples/TestPriorityAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] 4 | public class TestPriorityAttribute : Attribute 5 | { 6 | public TestPriorityAttribute(int priority) 7 | { 8 | Priority = priority; 9 | } 10 | 11 | public int Priority { get; private set; } 12 | } 13 | -------------------------------------------------------------------------------- /samples/TestOrderExamples/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /samples/TracingExample/Example.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit; 3 | 4 | public class Example 5 | { 6 | [Fact, TracingSplicer] 7 | public void TestThis() 8 | { 9 | Console.WriteLine("I'm inside the test!"); 10 | } 11 | } -------------------------------------------------------------------------------- /samples/TracingExample/TracingSplicerAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using Xunit; 4 | using Xunit.Sdk; 5 | 6 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] 7 | public class TracingSplicerAttribute : BeforeAfterTestAttribute 8 | { 9 | public override void Before(MethodInfo methodUnderTest) 10 | { 11 | Console.WriteLine("Before : {0}.{1}", methodUnderTest.DeclaringType.FullName, methodUnderTest.Name); 12 | } 13 | 14 | public override void After(MethodInfo methodUnderTest) 15 | { 16 | Console.WriteLine("After : {0}.{1}", methodUnderTest.DeclaringType.FullName, methodUnderTest.Name); 17 | } 18 | } -------------------------------------------------------------------------------- /samples/TracingExample/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/TraitExtensibility/CategoryAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit.Sdk; 3 | 4 | /// 5 | /// Apply this attribute to your test method to specify a category. 6 | /// 7 | [TraitDiscoverer("CategoryDiscoverer", "TraitExtensibility")] 8 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] 9 | class CategoryAttribute : Attribute, ITraitAttribute 10 | { 11 | public CategoryAttribute(string category) { } 12 | } 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /samples/TraitExtensibility/CategoryDiscoverer.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using Xunit.Sdk; 3 | using Xunit.Abstractions; 4 | using System.Collections.Generic; 5 | 6 | /// 7 | /// This class discovers all of the tests and test classes that have 8 | /// applied the Category attribute 9 | /// 10 | public class CategoryDiscoverer : ITraitDiscoverer 11 | { 12 | /// 13 | /// Gets the trait values from the Category attribute. 14 | /// 15 | /// The trait attribute containing the trait values. 16 | /// The trait values. 17 | public IEnumerable> GetTraits(IAttributeInfo traitAttribute) 18 | { 19 | var ctorArgs = traitAttribute.GetConstructorArguments().ToList(); 20 | yield return new KeyValuePair("Category", ctorArgs[0].ToString()); 21 | } 22 | } -------------------------------------------------------------------------------- /samples/TraitExtensibility/Example.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using Xunit; 3 | 4 | public class Example 5 | { 6 | [Fact, Category("Trait")] 7 | public void ExampleFact() 8 | { 9 | Assert.True(true); 10 | } 11 | } -------------------------------------------------------------------------------- /samples/TraitExtensibility/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /samples/UseCulture/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/CodeAnalysisDictionary.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | xunit 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/common/Application.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamarin/xunit/ddd38e486e722ac3ded0435068f8e33f1d4f87d1/src/common/Application.ico -------------------------------------------------------------------------------- /src/common/AssemblyExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | 5 | internal static class AssemblyExtensions 6 | { 7 | public static string GetLocalCodeBase(this Assembly assembly) 8 | { 9 | string codeBase = assembly.CodeBase; 10 | if (codeBase == null) 11 | return null; 12 | 13 | if (!codeBase.StartsWith("file:///")) 14 | throw new ArgumentException(String.Format("Code base {0} in wrong format; must start with file:///", codeBase), "assembly"); 15 | 16 | codeBase = codeBase.Substring(8); 17 | if (Path.DirectorySeparatorChar == '/') 18 | return "/" + codeBase; 19 | 20 | return codeBase.Replace('/', Path.DirectorySeparatorChar); 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /src/common/DisposableExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | internal static class DisposableExtensions 4 | { 5 | public static void SafeDispose(this IDisposable disposable) 6 | { 7 | if (disposable != null) 8 | disposable.Dispose(); 9 | } 10 | } -------------------------------------------------------------------------------- /src/common/GlobalAssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.CodeAnalysis; 2 | using System.Reflection; 3 | 4 | [assembly: AssemblyCompany("Outercurve Foundation")] 5 | [assembly: AssemblyProduct("xUnit.net Testing Framework")] 6 | [assembly: AssemblyCopyright("Copyright (C) Outercurve Foundation")] 7 | [assembly: AssemblyVersion("2.0.0.0")] 8 | 9 | [assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Xunit.Sdk")] 10 | [assembly: SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "xunit")] 11 | [assembly: SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "extensions")] 12 | [assembly: SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "utility")] 13 | [assembly: SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "runner")] -------------------------------------------------------------------------------- /src/common/SerializationInfoExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.Serialization; 2 | 3 | internal static class SerializationInfoExtensions 4 | { 5 | public static T GetValue(this SerializationInfo info, string name) 6 | { 7 | return (T)info.GetValue(name, typeof(T)); 8 | } 9 | } -------------------------------------------------------------------------------- /src/common/TestDiscoveryVisitor.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Xunit.Abstractions; 3 | 4 | namespace Xunit 5 | { 6 | internal class TestDiscoveryVisitor : TestMessageVisitor 7 | { 8 | public TestDiscoveryVisitor() 9 | { 10 | TestCases = new List(); 11 | } 12 | 13 | public List TestCases { get; private set; } 14 | 15 | public override void Dispose() 16 | { 17 | TestCases.ForEach(testCase => testCase.Dispose()); 18 | TestCases = null; 19 | } 20 | 21 | protected override bool Visit(ITestCaseDiscoveryMessage discovery) 22 | { 23 | TestCases.Add(discovery.TestCase); 24 | 25 | return true; 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /src/common/TestOptionsNames.cs: -------------------------------------------------------------------------------- 1 | internal static class TestOptionsNames 2 | { 3 | internal static class Discovery 4 | { 5 | } 6 | 7 | internal static class Execution 8 | { 9 | public static readonly string SynchronousMessageReporting = "xunit.SynchronousMessageReporting"; 10 | public static readonly string DisableParallelization = "xunit.DisableParallelization"; 11 | public static readonly string MaxParallelThreads = "xunit.MaxParallelThreads"; 12 | } 13 | } -------------------------------------------------------------------------------- /src/signing.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamarin/xunit/ddd38e486e722ac3ded0435068f8e33f1d4f87d1/src/signing.snk -------------------------------------------------------------------------------- /src/xunit.abstractions/Frameworks/ISourceInformation.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit.Abstractions 2 | { 3 | /// 4 | /// Represents source information about a test case. 5 | /// 6 | public interface ISourceInformation 7 | { 8 | /// 9 | /// Gets or sets the source file name. A null value indicates that the 10 | /// source file name is not known. 11 | /// 12 | string FileName { get; set; } 13 | 14 | /// 15 | /// Gets or sets the source file line. A null value indicates that the 16 | /// source file line is not known. 17 | /// 18 | int? LineNumber { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/xunit.abstractions/Frameworks/ISourceInformationProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Xunit.Abstractions 4 | { 5 | /// 6 | /// Represents a provider which gives source line information for a test case. Generally 7 | /// consumed by an implementation of during Find operations. 8 | /// 9 | public interface ISourceInformationProvider : IDisposable 10 | { 11 | /// 12 | /// Returns the source information for a test case. 13 | /// 14 | /// The test case to retrieve information for. 15 | /// The source information, with null string and int values when the information is not available. 16 | /// Note: return value should never be null, only the interior data values inside. 17 | ISourceInformation GetSourceInformation(ITestCase testCase); 18 | } 19 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/GlobalSuppressions.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.CodeAnalysis; [assembly: SuppressMessage("Microsoft.Naming", "CA1709:IdentifierShouldBeCasedCorrectly", MessageId = "abstractions")] -------------------------------------------------------------------------------- /src/xunit.abstractions/Messages/BaseInterfaces/IFinishedMessage.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit.Abstractions 2 | { 3 | /// 4 | /// This is the base message for various types of completion that can occur during the 5 | /// various phases of execution process (e.g., test case, test class, test collection, 6 | /// and assembly). 7 | /// 8 | public interface IFinishedMessage : IMessageSinkMessage 9 | { 10 | /// 11 | /// The execution time (in seconds) for this execution. 12 | /// 13 | decimal ExecutionTime { get; } 14 | 15 | /// 16 | /// The number of failing tests. 17 | /// 18 | int TestsFailed { get; } 19 | 20 | /// 21 | /// The total number of tests run. 22 | /// 23 | int TestsRun { get; } 24 | 25 | /// 26 | /// The number of skipped tests. 27 | /// 28 | int TestsSkipped { get; } 29 | } 30 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Messages/BaseInterfaces/IMessageSink.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Xunit.Abstractions 4 | { 5 | /// 6 | /// Represents an endpoint for the reception of test messages. 7 | /// 8 | public interface IMessageSink : IDisposable 9 | { 10 | /// 11 | /// Reports the presence of a message on the message bus. This method should 12 | /// never throw exceptions. 13 | /// 14 | /// The message from the message bus 15 | /// Return true to continue running tests, or false to stop. 16 | bool OnMessage(IMessageSinkMessage message); 17 | } 18 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Messages/BaseInterfaces/IMessageSinkMessage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Xunit.Abstractions 4 | { 5 | /// 6 | /// This is the base interface for all test messages. A test message is a message that is 7 | /// used to communicate the status of discovery and execution of tests. 8 | /// 9 | public interface IMessageSinkMessage { } 10 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Messages/BaseInterfaces/ITestCaseMessage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Xunit.Abstractions 5 | { 6 | /// 7 | /// Base message interface for all messages related to test cases. 8 | /// 9 | public interface ITestCaseMessage : ITestCollectionMessage 10 | { 11 | /// 12 | /// The test case that is associated with this message. 13 | /// 14 | ITestCase TestCase { get; } 15 | } 16 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Messages/BaseInterfaces/ITestClassMessage.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit.Abstractions 2 | { 3 | /// 4 | /// Base message interface for all messages related to test classes. 5 | /// 6 | public interface ITestClassMessage : ITestCollectionMessage 7 | { 8 | /// 9 | /// The fully-qualified name of the test class. 10 | /// 11 | string ClassName { get; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/xunit.abstractions/Messages/BaseInterfaces/ITestCollectionMessage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Xunit.Abstractions 5 | { 6 | /// 7 | /// Base message interface for all messages related to test collections. 8 | /// 9 | public interface ITestCollectionMessage : IMessageSinkMessage 10 | { 11 | /// 12 | /// Gets the test collection this test message is associated with. 13 | /// 14 | ITestCollection TestCollection { get; } 15 | } 16 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Messages/BaseInterfaces/ITestMessage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Xunit.Abstractions 5 | { 6 | /// 7 | /// Base message interface for all messages related to tests. 8 | /// 9 | public interface ITestMessage : ITestCaseMessage 10 | { 11 | /// 12 | /// The display name of the test. 13 | /// 14 | string TestDisplayName { get; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/xunit.abstractions/Messages/BaseInterfaces/ITestResultMessage.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit.Abstractions 2 | { 3 | /// 4 | /// This is the base interface for all individual test results (e.g., tests which 5 | /// pass, fail, or are skipped). 6 | /// 7 | public interface ITestResultMessage : ITestMessage 8 | { 9 | /// 10 | /// The execution time of the test, in seconds. 11 | /// 12 | decimal ExecutionTime { get; } 13 | 14 | /// 15 | /// The captured output of the test. 16 | /// 17 | string Output { get; } 18 | } 19 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Messages/IAfterTestFinished.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit.Abstractions 2 | { 3 | /// 4 | /// This message is sent during execution to indicate that the After method of 5 | /// a has completed executing. 6 | /// 7 | public interface IAfterTestFinished : ITestMessage 8 | { 9 | /// 10 | /// The fully qualified type name of the . 11 | /// 12 | string AttributeName { get; } 13 | } 14 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Messages/IAfterTestStarting.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit.Abstractions 2 | { 3 | /// 4 | /// This message is sent during execution to indicate that the After method of 5 | /// a is about to execute. 6 | /// 7 | public interface IAfterTestStarting : ITestMessage 8 | { 9 | /// 10 | /// The fully qualified type name of the . 11 | /// 12 | string AttributeName { get; } 13 | } 14 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Messages/IBeforeTestFinished.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit.Abstractions 2 | { 3 | /// 4 | /// This message is sent during execution to indicate that the Before method of 5 | /// a has completed executing. 6 | /// 7 | public interface IBeforeTestFinished : ITestMessage 8 | { 9 | /// 10 | /// The fully qualified type name of the . 11 | /// 12 | string AttributeName { get; } 13 | } 14 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Messages/IBeforeTestStarting.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit.Abstractions 2 | { 3 | /// 4 | /// This message is sent during execution to indicate that the Before method of 5 | /// a is about to execute. 6 | /// 7 | public interface IBeforeTestStarting : ITestMessage 8 | { 9 | /// 10 | /// The fully qualified type name of the . 11 | /// 12 | string AttributeName { get; } 13 | } 14 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Messages/IDiscoveryCompleteMessage.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Xunit.Abstractions 4 | { 5 | /// 6 | /// This message indicates that the discovery process has been completed for 7 | /// the requested assembly. 8 | /// 9 | public interface IDiscoveryCompleteMessage : IMessageSinkMessage 10 | { 11 | /// 12 | /// Gets the list of warnings that were raised during discovery. 13 | /// 14 | IEnumerable Warnings { get; } 15 | } 16 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Messages/IErrorMessage.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit.Abstractions 2 | { 3 | /// 4 | /// This message indicates that an error has occurred in the execution process. 5 | /// 6 | public interface IErrorMessage : IMessageSinkMessage, IFailureInformation 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Messages/ITestAssemblyFinished.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit.Abstractions 2 | { 3 | /// 4 | /// This message indicates that the execution process has been completed for 5 | /// the requested assembly. 6 | /// 7 | public interface ITestAssemblyFinished : IFinishedMessage 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/xunit.abstractions/Messages/ITestCaseDiscoveryMessage.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit.Abstractions 2 | { 3 | /// 4 | /// This message indicates that a test case had been found during the discovery process. 5 | /// 6 | public interface ITestCaseDiscoveryMessage : ITestCaseMessage 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Messages/ITestCaseFinished.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit.Abstractions 2 | { 3 | /// 4 | /// This message indicates that a test case has finished executing. 5 | /// 6 | public interface ITestCaseFinished : ITestCaseMessage, IFinishedMessage 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Messages/ITestCaseStarting.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit.Abstractions 2 | { 3 | /// 4 | /// This message indicates that a test case is about to start executing. 5 | /// 6 | public interface ITestCaseStarting : ITestCaseMessage 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Messages/ITestClassConstructionFinished.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit.Abstractions 2 | { 3 | /// 4 | /// This message indicates that an instance of a test class has just been constructed. 5 | /// Instance (non-static) methods of tests get a new instance of the test class for each 6 | /// individual test execution; static methods do not get an instance of the test class. 7 | /// 8 | public interface ITestClassConstructionFinished : ITestMessage 9 | { 10 | } 11 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Messages/ITestClassConstructionStarting.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit.Abstractions 2 | { 3 | /// 4 | /// This message indicates that an instance of a test class is about to be constructed. 5 | /// Instance (non-static) methods of tests get a new instance of the test class for each 6 | /// individual test execution; static methods do not get an instance of the test class. 7 | /// 8 | public interface ITestClassConstructionStarting : ITestMessage 9 | { 10 | } 11 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Messages/ITestClassDisposeFinished.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit.Abstractions 2 | { 3 | /// 4 | /// This message indicates that the method was 5 | /// just called on the test class for the test case that just finished executing. 6 | /// 7 | public interface ITestClassDisposeFinished : ITestMessage 8 | { 9 | } 10 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Messages/ITestClassDisposeStarting.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit.Abstractions 2 | { 3 | /// 4 | /// This message indicates that the method is 5 | /// about to be called on the test class for the test case that just finished executing. 6 | /// 7 | public interface ITestClassDisposeStarting : ITestMessage 8 | { 9 | } 10 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Messages/ITestClassFinished.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit.Abstractions 2 | { 3 | /// 4 | /// This message indicates that a test class has finished executing (meaning, all of the 5 | /// test cases in this test class have finished running). 6 | /// 7 | public interface ITestClassFinished : ITestClassMessage, IFinishedMessage 8 | { 9 | } 10 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Messages/ITestClassStarting.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit.Abstractions 2 | { 3 | /// 4 | /// This message indicates that a test class is about to begin running. 5 | /// 6 | public interface ITestClassStarting : ITestClassMessage 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Messages/ITestCollectionFinished.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit.Abstractions 2 | { 3 | /// 4 | /// This message indicates that a test collection has just finished executing (meaning, 5 | /// all the test classes in the collection has finished). 6 | /// 7 | public interface ITestCollectionFinished : ITestCollectionMessage, IFinishedMessage 8 | { 9 | } 10 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Messages/ITestCollectionStarting.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit.Abstractions 2 | { 3 | /// 4 | /// This message indicates that a test collection has is about to start executing. 5 | /// 6 | public interface ITestCollectionStarting : ITestCollectionMessage 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Messages/ITestFailed.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit.Abstractions 2 | { 3 | /// 4 | /// This message indicates that a test has failed. 5 | /// 6 | public interface ITestFailed : ITestResultMessage, IFailureInformation 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Messages/ITestFinished.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit.Abstractions 2 | { 3 | /// 4 | /// This message indicates that a test has finished executing. 5 | /// 6 | public interface ITestFinished : ITestMessage 7 | { 8 | /// 9 | /// Gets the time spent executing the test, in seconds. 10 | /// 11 | decimal ExecutionTime { get; } 12 | 13 | /// 14 | /// The captured output of the test. 15 | /// 16 | string Output { get; } 17 | 18 | // TODO: How do we differentiate a test (when a test case has multiple tests)? 19 | // Is it solely by the display name of the test? 20 | } 21 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Messages/ITestMethodFinished.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit.Abstractions 2 | { 3 | /// 4 | /// This message indicates that a test method has finished executing (meaning, all 5 | /// the test cases that derived from the test method have finished). 6 | /// 7 | public interface ITestMethodFinished : ITestCollectionMessage 8 | { 9 | /// 10 | /// The fully-qualified name of the test class. 11 | /// 12 | string ClassName { get; } 13 | 14 | /// 15 | /// The name of the test method. 16 | /// 17 | string MethodName { get; } 18 | } 19 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Messages/ITestMethodStarting.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit.Abstractions 2 | { 3 | /// 4 | /// This message indicates that a test method is about to begin executing. 5 | /// 6 | public interface ITestMethodStarting : ITestCollectionMessage 7 | { 8 | /// 9 | /// The fully-qualified name of the test class. 10 | /// 11 | string ClassName { get; } 12 | 13 | /// 14 | /// The name of the test method. 15 | /// 16 | string MethodName { get; } 17 | } 18 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Messages/ITestPassed.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit.Abstractions 2 | { 3 | /// 4 | /// Indicates that a test has passed. 5 | /// 6 | public interface ITestPassed : ITestResultMessage 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Messages/ITestSkipped.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit.Abstractions 2 | { 3 | /// 4 | /// This message indicates that a test was skipped. 5 | /// 6 | public interface ITestSkipped : ITestResultMessage 7 | { 8 | /// 9 | /// The reason given for skipping the test. 10 | /// 11 | string Reason { get; } 12 | } 13 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Messages/ITestStarting.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit.Abstractions 2 | { 3 | /// 4 | /// This message indicates that a test is about to start executing. 5 | /// 6 | public interface ITestStarting : ITestMessage 7 | { 8 | // TODO: How do we differentiate a test (when a test case has multiple tests)? 9 | // Is it solely by the display name of the test? 10 | } 11 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | using System.Reflection; 4 | 5 | // This file does not use GlobalAssemblyInfo.cs because its version should not change over time. 6 | // Once 2.0 ships, this assembly will be considered to be frozen. 7 | 8 | [assembly: AssemblyTitle("xUnit.net Abstractions")] 9 | [assembly: AssemblyCompany("Outercurve Foundation")] 10 | [assembly: AssemblyProduct("xUnit.net Testing Framework")] 11 | [assembly: AssemblyCopyright("Copyright (C) Outercurve Foundation")] 12 | [assembly: CLSCompliant(true)] 13 | [assembly: AssemblyVersion("2.0.0.0")] 14 | 15 | [assembly: SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "xunit")] 16 | -------------------------------------------------------------------------------- /src/xunit.abstractions/Reflection/IParameterInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Xunit.Abstractions 4 | { 5 | /// 6 | /// Represents information about a method parameter. The primary implementation is based on runtime 7 | /// reflection, but may also be implemented by runner authors to provide non-reflection-based 8 | /// test discovery (for example, AST-based runners like CodeRush or Resharper). 9 | /// 10 | public interface IParameterInfo 11 | { 12 | /// 13 | /// The name of the parameter. 14 | /// 15 | string Name { get; } 16 | 17 | /// 18 | /// Gets the type of the parameter. 19 | /// 20 | ITypeInfo ParameterType { get; } 21 | } 22 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Reflection/IReflectionAssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | namespace Xunit.Abstractions 4 | { 5 | /// 6 | /// Represents a reflection-backed implementation of . 7 | /// 8 | public interface IReflectionAssemblyInfo : IAssemblyInfo 9 | { 10 | /// 11 | /// Gets the underlying for the assembly. 12 | /// 13 | Assembly Assembly { get; } 14 | } 15 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Reflection/IReflectionAttributeInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Xunit.Abstractions 4 | { 5 | /// 6 | /// Represents a reflection-backed implementation of . 7 | /// 8 | public interface IReflectionAttributeInfo : IAttributeInfo 9 | { 10 | /// 11 | /// Gets the instance of the attribute, if available. 12 | /// 13 | Attribute Attribute { get; } 14 | } 15 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Reflection/IReflectionMethodInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | namespace Xunit.Abstractions 4 | { 5 | /// 6 | /// Represents a reflection-backed implementation of . 7 | /// 8 | public interface IReflectionMethodInfo : IMethodInfo 9 | { 10 | /// 11 | /// Gets the underlying for the method. 12 | /// 13 | MethodInfo MethodInfo { get; } 14 | } 15 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Reflection/IReflectionParameterInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | namespace Xunit.Abstractions 4 | { 5 | /// 6 | /// Represents a reflection-backed implementation of . 7 | /// 8 | public interface IReflectionParameterInfo : IParameterInfo 9 | { 10 | /// 11 | /// Gets the underlying for the parameter. 12 | /// 13 | ParameterInfo ParameterInfo { get; } 14 | } 15 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/Reflection/IReflectionTypeInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Xunit.Abstractions 4 | { 5 | /// 6 | /// Represents a reflection-backed implementation of . 7 | /// 8 | public interface IReflectionTypeInfo : ITypeInfo 9 | { 10 | /// 11 | /// Gets the underlying object. 12 | /// 13 | Type Type { get; } 14 | } 15 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/TestCases/ITestCollection.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Xunit.Abstractions 4 | { 5 | /// 6 | /// Represents a group of test cases. Test collections form the basis of the parallelization in 7 | /// xUnit.net. Test cases which are in the same test collection will not be run in parallel 8 | /// against sibling tests, but will run in parallel against tests in other collections. 9 | /// 10 | public interface ITestCollection 11 | { 12 | /// 13 | /// Gets the type that the test collection was defined with, if available; may be null 14 | /// if the test collection didn't have a definition type. 15 | /// 16 | ITypeInfo CollectionDefinition { get; } 17 | 18 | /// 19 | /// Gets the display name of the test collection. 20 | /// 21 | string DisplayName { get; } 22 | 23 | /// 24 | /// Gets the test collection ID. Test collection equality is determined by comparing IDs. 25 | /// 26 | Guid ID { get; } 27 | } 28 | } -------------------------------------------------------------------------------- /src/xunit.abstractions/xunit.abstractions.shproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ef8381db-7aa0-41b8-99c5-7a69f1a61f18 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/xunit.assert.source.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | xunit.assert.source 5 | 2.0.0-beta 6 | xUnit.net [Assertion Library, as source] 7 | James Newkirk, Brad Wilson 8 | Includes the current assertion library from xUnit.net, as source into your project. 9 | en-US 10 | https://github.com/xunit/xunit 11 | https://raw.githubusercontent.com/xunit/media/master/logo-512-transparent.png 12 | https://raw.githubusercontent.com/xunit/xunit/master/license.txt 13 | false 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/xunit.assert/Asserts/Comparers.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using Xunit.Sdk; 5 | 6 | namespace Xunit 7 | { 8 | public partial class Assert 9 | { 10 | static IComparer GetComparer() where T : IComparable 11 | { 12 | return new AssertComparer(); 13 | } 14 | 15 | static IEqualityComparer GetEqualityComparer(bool skipTypeCheck = false, IEqualityComparer innerComparer = null) 16 | { 17 | return new AssertEqualityComparer(skipTypeCheck, innerComparer); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/xunit.assert/Asserts/Guards.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Xunit 4 | { 5 | public partial class Assert 6 | { 7 | /// 8 | internal static void GuardArgumentNotNull(string argName, object argValue) 9 | { 10 | if (argValue == null) 11 | throw new ArgumentNullException(argName); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/xunit.assert/Asserts/NullAsserts.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit.Sdk; 3 | 4 | namespace Xunit 5 | { 6 | public partial class Assert 7 | { 8 | /// 9 | /// Verifies that an object reference is not null. 10 | /// 11 | /// The object to be validated 12 | /// Thrown when the object is not null 13 | public static void NotNull(object @object) 14 | { 15 | if (@object == null) 16 | throw new NotNullException(); 17 | } 18 | 19 | /// 20 | /// Verifies that an object reference is null. 21 | /// 22 | /// The object to be inspected 23 | /// Thrown when the object reference is not null 24 | public static void Null(object @object) 25 | { 26 | if (@object != null) 27 | throw new NullException(@object); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/xunit.assert/Asserts/Sdk/Exceptions/AssertCollectionCountException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | using System.Globalization; 4 | 5 | namespace Xunit.Sdk 6 | { 7 | /// 8 | /// Exception thrown when the collection did not contain exactly the given number element. 9 | /// 10 | [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")] 11 | public class AssertCollectionCountException : XunitException 12 | { 13 | /// 14 | /// Initializes a new instance of the class. 15 | /// 16 | /// The expected number of items in the collection. 17 | /// The actual number of items in the collection. 18 | public AssertCollectionCountException(int expectedCount, int actualCount) 19 | : base(String.Format(CultureInfo.CurrentCulture, "The collection contained {0} matching element(s) instead of {1}.", actualCount, expectedCount)) { } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/xunit.assert/Asserts/Sdk/Exceptions/DoesNotContainException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | using System.Globalization; 4 | 5 | namespace Xunit.Sdk 6 | { 7 | /// 8 | /// Exception thrown when a collection unexpectedly contains the expected value. 9 | /// 10 | [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")] 11 | public class DoesNotContainException : XunitException 12 | { 13 | /// 14 | /// Creates a new instance of the class. 15 | /// 16 | /// The expected object value 17 | public DoesNotContainException(object expected) 18 | : base(String.Format(CultureInfo.CurrentCulture, "Assert.DoesNotContain() Failure: Found: {0}", expected)) { } 19 | } 20 | } -------------------------------------------------------------------------------- /src/xunit.assert/Asserts/Sdk/Exceptions/DoesNotMatchException.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit.Sdk 2 | { 3 | using System; 4 | using System.Diagnostics.CodeAnalysis; 5 | using System.Globalization; 6 | 7 | /// 8 | /// Exception thrown when a string unexpectedly matches a regular expression. 9 | /// 10 | [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")] 11 | public class DoesNotMatchException : XunitException 12 | { 13 | /// 14 | /// Creates a new instance of the class. 15 | /// 16 | /// The regular expression pattern expected not to match 17 | /// The actual value 18 | public DoesNotMatchException(object expectedRegexPattern, object actual) 19 | : base(String.Format(CultureInfo.CurrentCulture, "Assert.DoesNotMatch() Failure:{2}Regex: {0}{2}Value: {1}", expectedRegexPattern, actual, Environment.NewLine)) { } 20 | } 21 | } -------------------------------------------------------------------------------- /src/xunit.assert/Asserts/Sdk/Exceptions/EmptyException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | 4 | namespace Xunit.Sdk 5 | { 6 | /// 7 | /// Exception thrown when a collection is unexpectedly not empty. 8 | /// 9 | [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")] 10 | public class EmptyException : XunitException 11 | { 12 | /// 13 | /// Creates a new instance of the class. 14 | /// 15 | public EmptyException() 16 | : base("Assert.Empty() Failure") { } 17 | } 18 | } -------------------------------------------------------------------------------- /src/xunit.assert/Asserts/Sdk/Exceptions/FalseException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | 4 | namespace Xunit.Sdk 5 | { 6 | /// 7 | /// Exception thrown when a value is unexpectedly true. 8 | /// 9 | [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")] 10 | public class FalseException : XunitException 11 | { 12 | /// 13 | /// Creates a new instance of the class. 14 | /// 15 | /// The user message to be display, or null for the default message 16 | public FalseException(string userMessage) 17 | : base(userMessage ?? "Assert.False() Failure") { } 18 | } 19 | } -------------------------------------------------------------------------------- /src/xunit.assert/Asserts/Sdk/Exceptions/IsAssignableFromException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | 4 | namespace Xunit.Sdk 5 | { 6 | /// 7 | /// Exception thrown when the value is unexpectedly not of the given type or a derived type. 8 | /// 9 | [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")] 10 | public class IsAssignableFromException : AssertActualExpectedException 11 | { 12 | /// 13 | /// Creates a new instance of the class. 14 | /// 15 | /// The expected type 16 | /// The actual object value 17 | public IsAssignableFromException(Type expected, object actual) 18 | : base(expected, actual == null ? null : actual.GetType(), "Assert.IsAssignableFrom() Failure") { } 19 | } 20 | } -------------------------------------------------------------------------------- /src/xunit.assert/Asserts/Sdk/Exceptions/IsNotTypeException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | 4 | namespace Xunit.Sdk 5 | { 6 | /// 7 | /// Exception thrown when the value is unexpectedly of the exact given type. 8 | /// 9 | [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")] 10 | public class IsNotTypeException : AssertActualExpectedException 11 | { 12 | /// 13 | /// Creates a new instance of the class. 14 | /// 15 | /// The expected type 16 | /// The actual object value 17 | public IsNotTypeException(Type expected, object actual) 18 | : base(expected, actual == null ? null : actual.GetType(), "Assert.IsNotType() Failure") { } 19 | } 20 | } -------------------------------------------------------------------------------- /src/xunit.assert/Asserts/Sdk/Exceptions/IsTypeException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | 4 | namespace Xunit.Sdk 5 | { 6 | /// 7 | /// Exception thrown when the value is unexpectedly not of the exact given type. 8 | /// 9 | [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")] 10 | public class IsTypeException : AssertActualExpectedException 11 | { 12 | /// 13 | /// Creates a new instance of the class. 14 | /// 15 | /// The expected type name 16 | /// The actual type name 17 | public IsTypeException(string expectedTypeName, string actualTypeName) 18 | : base(expectedTypeName, actualTypeName, "Assert.IsType() Failure") { } 19 | } 20 | } -------------------------------------------------------------------------------- /src/xunit.assert/Asserts/Sdk/Exceptions/MatchesException.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit.Sdk 2 | { 3 | using System; 4 | using System.Diagnostics.CodeAnalysis; 5 | using System.Globalization; 6 | 7 | /// 8 | /// Exception thrown when a string does not match a regular expression. 9 | /// 10 | [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")] 11 | public class MatchesException : XunitException 12 | { 13 | /// 14 | /// Creates a new instance of the class. 15 | /// 16 | /// The expected regular expression pattern 17 | /// The actual value 18 | public MatchesException(object expectedRegexPattern, object actual) 19 | : base(String.Format(CultureInfo.CurrentCulture, "Assert.Matches() Failure:{2}Regex: {0}{2}Value: {1}", expectedRegexPattern, actual, Environment.NewLine)) { } 20 | } 21 | } -------------------------------------------------------------------------------- /src/xunit.assert/Asserts/Sdk/Exceptions/NoneException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | 4 | namespace Xunit.Sdk 5 | { 6 | /// 7 | /// Exception thrown when the collection did not contain exactly zero elements. 8 | /// 9 | [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")] 10 | public class NoneException : AssertCollectionCountException 11 | { 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | /// The numbers of items in the collection. 16 | public NoneException(int count) : base(0, count) { } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/xunit.assert/Asserts/Sdk/Exceptions/NotEmptyException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | 4 | namespace Xunit.Sdk 5 | { 6 | /// 7 | /// Exception thrown when a collection is unexpectedly empty. 8 | /// 9 | [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")] 10 | public class NotEmptyException : XunitException 11 | { 12 | /// 13 | /// Creates a new instance of the class. 14 | /// 15 | public NotEmptyException() 16 | : base("Assert.NotEmpty() Failure") { } 17 | } 18 | } -------------------------------------------------------------------------------- /src/xunit.assert/Asserts/Sdk/Exceptions/NotEqualException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | 4 | namespace Xunit.Sdk 5 | { 6 | /// 7 | /// Exception thrown when two values are unexpectedly equal. 8 | /// 9 | [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")] 10 | public class NotEqualException : XunitException 11 | { 12 | /// 13 | /// Creates a new instance of the class. 14 | /// 15 | public NotEqualException() 16 | : base("Assert.NotEqual() Failure") { } 17 | } 18 | } -------------------------------------------------------------------------------- /src/xunit.assert/Asserts/Sdk/Exceptions/NotNullException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | 4 | namespace Xunit.Sdk 5 | { 6 | /// 7 | /// Exception thrown when an object is unexpectedly null. 8 | /// 9 | [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")] 10 | public class NotNullException : XunitException 11 | { 12 | /// 13 | /// Creates a new instance of the class. 14 | /// 15 | public NotNullException() 16 | : base("Assert.NotNull() Failure") { } 17 | } 18 | } -------------------------------------------------------------------------------- /src/xunit.assert/Asserts/Sdk/Exceptions/NotSameException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | 4 | namespace Xunit.Sdk 5 | { 6 | /// 7 | /// Exception thrown when two values are unexpected the same instance. 8 | /// 9 | [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")] 10 | public class NotSameException : XunitException 11 | { 12 | /// 13 | /// Creates a new instance of the class. 14 | /// 15 | public NotSameException() 16 | : base("Assert.NotSame() Failure") { } 17 | } 18 | } -------------------------------------------------------------------------------- /src/xunit.assert/Asserts/Sdk/Exceptions/NullException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | 4 | namespace Xunit.Sdk 5 | { 6 | /// 7 | /// Exception thrown when an object reference is unexpectedly not null. 8 | /// 9 | [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")] 10 | public class NullException : AssertActualExpectedException 11 | { 12 | /// 13 | /// Creates a new instance of the class. 14 | /// 15 | /// 16 | public NullException(object actual) 17 | : base(null, actual, "Assert.Null() Failure") { } 18 | } 19 | } -------------------------------------------------------------------------------- /src/xunit.assert/Asserts/Sdk/Exceptions/ParameterCountMismatchException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | 4 | namespace Xunit.Sdk 5 | { 6 | /// 7 | /// Exception to be thrown from theory execution when the number of 8 | /// parameter values does not the test method signature. 9 | /// 10 | [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")] 11 | public class ParameterCountMismatchException : Exception 12 | { 13 | /// 14 | public ParameterCountMismatchException() { } 15 | } 16 | } -------------------------------------------------------------------------------- /src/xunit.assert/Asserts/Sdk/Exceptions/ProperSubsetException.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Diagnostics.CodeAnalysis; 3 | 4 | namespace Xunit.Sdk 5 | { 6 | /// 7 | /// Exception thrown when a set is not a proper subset of another set. 8 | /// 9 | [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")] 10 | public class ProperSubsetException : AssertActualExpectedException 11 | { 12 | /// 13 | /// Creates a new instance of the class. 14 | /// 15 | public ProperSubsetException(IEnumerable expected, IEnumerable actual) 16 | : base(expected, actual, "Assert.ProperSubset() Failure") { } 17 | } 18 | } -------------------------------------------------------------------------------- /src/xunit.assert/Asserts/Sdk/Exceptions/ProperSupersetException.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Diagnostics.CodeAnalysis; 3 | 4 | namespace Xunit.Sdk 5 | { 6 | /// 7 | /// Exception thrown when a set is not a proper superset of another set. 8 | /// 9 | [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")] 10 | public class ProperSupersetException : AssertActualExpectedException 11 | { 12 | /// 13 | /// Creates a new instance of the class. 14 | /// 15 | public ProperSupersetException(IEnumerable expected, IEnumerable actual) 16 | : base(expected, actual, "Assert.ProperSuperset() Failure") { } 17 | } 18 | } -------------------------------------------------------------------------------- /src/xunit.assert/Asserts/Sdk/Exceptions/PropertyChangedException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | using System.Globalization; 4 | 5 | namespace Xunit.Sdk 6 | { 7 | /// 8 | /// Exception thrown when code unexpectedly fails change a property. 9 | /// 10 | [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")] 11 | public class PropertyChangedException : XunitException 12 | { 13 | /// 14 | /// Creates a new instance of the class. Call this constructor 15 | /// when no exception was thrown. 16 | /// 17 | /// The name of the property that was expected to be changed. 18 | public PropertyChangedException(string propertyName) 19 | : base(String.Format(CultureInfo.CurrentCulture, "Assert.PropertyChanged failure: Property {0} was not set", propertyName)) { } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/xunit.assert/Asserts/Sdk/Exceptions/SameException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | 4 | namespace Xunit.Sdk 5 | { 6 | /// 7 | /// Exception thrown when two object references are unexpectedly not the same instance. 8 | /// 9 | [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")] 10 | public class SameException : AssertActualExpectedException 11 | { 12 | /// 13 | /// Creates a new instance of the class. 14 | /// 15 | /// The expected object reference 16 | /// The actual object reference 17 | public SameException(object expected, 18 | object actual) 19 | : base(expected, actual, "Assert.Same() Failure") { } 20 | } 21 | } -------------------------------------------------------------------------------- /src/xunit.assert/Asserts/Sdk/Exceptions/SingleException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | 4 | namespace Xunit.Sdk 5 | { 6 | /// 7 | /// Exception thrown when the collection did not contain exactly one element. 8 | /// 9 | [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")] 10 | public class SingleException : AssertCollectionCountException 11 | { 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | /// The numbers of items in the collection. 16 | public SingleException(int count) : base(1, count) { } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/xunit.assert/Asserts/Sdk/Exceptions/SubsetException.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Diagnostics.CodeAnalysis; 3 | 4 | namespace Xunit.Sdk 5 | { 6 | /// 7 | /// Exception thrown when a set is not a subset of another set. 8 | /// 9 | [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")] 10 | public class SubsetException : AssertActualExpectedException 11 | { 12 | /// 13 | /// Creates a new instance of the class. 14 | /// 15 | public SubsetException(IEnumerable expected, IEnumerable actual) 16 | : base(expected, actual, "Assert.Subset() Failure") { } 17 | } 18 | } -------------------------------------------------------------------------------- /src/xunit.assert/Asserts/Sdk/Exceptions/SupersetException.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Diagnostics.CodeAnalysis; 3 | 4 | namespace Xunit.Sdk 5 | { 6 | /// 7 | /// Exception thrown when a set is not a superset of another set. 8 | /// 9 | [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")] 10 | public class SupersetException : AssertActualExpectedException 11 | { 12 | /// 13 | /// Creates a new instance of the class. 14 | /// 15 | public SupersetException(IEnumerable expected, IEnumerable actual) 16 | : base(expected, actual, "Assert.Superset() Failure") { } 17 | } 18 | } -------------------------------------------------------------------------------- /src/xunit.assert/Asserts/Sdk/Exceptions/TimeoutException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | using System.Globalization; 4 | 5 | namespace Xunit.Sdk 6 | { 7 | /// 8 | /// Exception thrown when a test method exceeds the given timeout value 9 | /// 10 | [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")] 11 | public class TimeoutException : XunitException 12 | { 13 | /// 14 | /// Creates a new instance of the class. 15 | /// 16 | /// The timeout value, in milliseconds 17 | public TimeoutException(long timeout) 18 | : base(String.Format(CultureInfo.CurrentCulture, "Test execution time exceeded: {0}ms", timeout)) { } 19 | } 20 | } -------------------------------------------------------------------------------- /src/xunit.assert/Asserts/Sdk/Exceptions/TrueException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | 4 | namespace Xunit.Sdk 5 | { 6 | /// 7 | /// Exception thrown when a value is unexpectedly false. 8 | /// 9 | [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")] 10 | public class TrueException : XunitException 11 | { 12 | /// 13 | /// Creates a new instance of the class. 14 | /// 15 | /// The user message to be displayed, or null for the default message 16 | public TrueException(string userMessage) 17 | : base(userMessage ?? "Assert.True() Failure") { } 18 | } 19 | } -------------------------------------------------------------------------------- /src/xunit.assert/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Security; 4 | 5 | [assembly: AssemblyTitle("xUnit.net Assertion Library")] 6 | [assembly: CLSCompliant(true)] 7 | -------------------------------------------------------------------------------- /src/xunit.assert/xunit.assert.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | xunit.assert 5 | 2.0.0-beta 6 | xUnit.net [Assertion Library] 7 | James Newkirk, Brad Wilson 8 | 9 | Includes the current assertion library from xUnit.net (xunit.assert.dll). 10 | Supported platforms: Desktop .NET 4.5+, Modern Windows 8+, Windows Phone 8+ (Silverlight), Windows Phone 8.1+ (Universal), Portable Libraries (supporting Profile259). 11 | 12 | en-US 13 | https://github.com/xunit/xunit 14 | https://raw.githubusercontent.com/xunit/media/master/logo-512-transparent.png 15 | https://raw.githubusercontent.com/xunit/xunit/master/license.txt 16 | false 17 | 18 | -------------------------------------------------------------------------------- /src/xunit.console/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/xunit.console/Config/TransformConfigurationElement.cs: -------------------------------------------------------------------------------- 1 | using System.Configuration; 2 | 3 | namespace Xunit.ConsoleClient 4 | { 5 | public class TransformConfigurationElement : ConfigurationElement 6 | { 7 | [ConfigurationProperty("commandline", IsRequired = true, IsKey = true)] 8 | public string CommandLine 9 | { 10 | get { return (string)this["commandline"]; } 11 | set { this["commandline"] = value; } 12 | } 13 | 14 | [ConfigurationProperty("description", IsRequired = true)] 15 | public string Description 16 | { 17 | get { return (string)this["description"]; } 18 | set { this["description"] = value; } 19 | } 20 | 21 | [ConfigurationProperty("xslfile", IsRequired = true)] 22 | public string XslFile 23 | { 24 | get { return (string)this["xslfile"]; } 25 | set { this["xslfile"] = value; } 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /src/xunit.console/Config/TransformConfigurationElementCollection.cs: -------------------------------------------------------------------------------- 1 | using System.Configuration; 2 | 3 | namespace Xunit.ConsoleClient 4 | { 5 | public class TransformConfigurationElementCollection : ConfigurationElementCollection 6 | { 7 | protected override ConfigurationElement CreateNewElement() 8 | { 9 | return new TransformConfigurationElement(); 10 | } 11 | 12 | protected override object GetElementKey(ConfigurationElement element) 13 | { 14 | return ((TransformConfigurationElement)element).CommandLine; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /src/xunit.console/Config/XunitConsoleConfigurationSection.cs: -------------------------------------------------------------------------------- 1 | using System.Configuration; 2 | 3 | namespace Xunit.ConsoleClient 4 | { 5 | public class XunitConsoleConfigurationSection : ConfigurationSection 6 | { 7 | [ConfigurationProperty("transforms", IsDefaultCollection = false)] 8 | public TransformConfigurationElementCollection Transforms 9 | { 10 | get { return (TransformConfigurationElementCollection)this["transforms"]; } 11 | set { this["transforms"] = value; } 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /src/xunit.console/ParallelismOption.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Xunit.ConsoleClient 8 | { 9 | public enum ParallelismOption 10 | { 11 | none, 12 | collections, 13 | assemblies, 14 | all 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/xunit.console/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | [assembly : AssemblyTitle("xUnit.net Console Test Runner")] -------------------------------------------------------------------------------- /src/xunit.console/Utility/Transform.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Xml.Linq; 7 | 8 | namespace Xunit.ConsoleClient 9 | { 10 | public class Transform 11 | { 12 | public string CommandLine; 13 | public string Description; 14 | public Action OutputHandler; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/xunit.core/CollectionAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Xunit 4 | { 5 | /// 6 | /// Used to declare a specific test collection for a test class. 7 | /// 8 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] 9 | public sealed class CollectionAttribute : Attribute 10 | { 11 | /// 12 | /// Initializes a new instance of the class. 13 | /// 14 | /// The test collection name. 15 | public CollectionAttribute(string name) { } 16 | } 17 | } -------------------------------------------------------------------------------- /src/xunit.core/CollectionBehavior.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit 2 | { 3 | /// 4 | /// Defines the built-in behavior types for collections in xUnit.net. 5 | /// 6 | public enum CollectionBehavior 7 | { 8 | /// 9 | /// By default, generates a collection per assembly, and any test classes that are not 10 | /// decorated with will be placed into the assembly-level 11 | /// collection. 12 | /// 13 | CollectionPerAssembly, 14 | 15 | /// 16 | /// By default, generates a collection per test class for any test classes that are not 17 | /// decorated with . 18 | /// 19 | CollectionPerClass 20 | } 21 | } -------------------------------------------------------------------------------- /src/xunit.core/CollectionDefinitionAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Xunit 5 | { 6 | /// 7 | /// Used to declare a test collection container class. The container class gives 8 | /// developers a place to attach interfaces like and 9 | /// that will be applied to all tests classes 10 | /// that are members of the test collection. 11 | /// 12 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] 13 | public sealed class CollectionDefinitionAttribute : Attribute 14 | { 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | /// The test collection name. 19 | public CollectionDefinitionAttribute(string name) { } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/xunit.core/IClassFixture.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit 2 | { 3 | /// 4 | /// Used to decorate xUnit.net test classes and collections to indicate a test which has 5 | /// per-test-class fixture data. An instance of the fixture data is initialized just before 6 | /// the first test in the class is run, and if it implements IDisposable, is disposed 7 | /// after the last test in the class is run. To gain access to the fixture data from 8 | /// inside the test, a constructor argument should be added to the test class which 9 | /// exactly matches the . 10 | /// 11 | /// The type of the fixture. 12 | public interface IClassFixture where TFixture : class, new() { } 13 | } 14 | -------------------------------------------------------------------------------- /src/xunit.core/ICollectionFixture.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Xunit 5 | { 6 | /// 7 | /// Used to decorate xUnit.net test classes and collections to indicate a test which has 8 | /// per-test-collection fixture data. An instance of the fixture data is initialized just before 9 | /// the first test in the collection is run, and if it implements IDisposable, is disposed 10 | /// after the last test in the collection is run. To gain access to the fixture data from 11 | /// inside the test, a constructor argument should be added to the test class which 12 | /// exactly matches the . 13 | /// 14 | /// The type of the fixture. 15 | public interface ICollectionFixture where TFixture : class, new() { } 16 | } 17 | -------------------------------------------------------------------------------- /src/xunit.core/InlineDataAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | using Xunit.Sdk; 5 | 6 | namespace Xunit 7 | { 8 | /// 9 | /// Provides a data source for a data theory, with the data coming from inline values. 10 | /// 11 | [CLSCompliant(false)] 12 | [DataDiscoverer("Xunit.Sdk.InlineDataDiscoverer", "xunit.core")] 13 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] 14 | public sealed class InlineDataAttribute : DataAttribute 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The data values to pass to the theory. 20 | public InlineDataAttribute(params object[] data) { } 21 | 22 | /// 23 | public override IEnumerable GetData(MethodInfo testMethod) 24 | { 25 | // This should never be called, because the discoverer can always find the data. 26 | throw new InvalidOperationException(); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /src/xunit.core/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Security; 4 | 5 | [assembly: AssemblyTitle("xUnit.net Core")] 6 | [assembly: CLSCompliant(true)] 7 | -------------------------------------------------------------------------------- /src/xunit.core/Sdk/BeforeAfterTestAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | 4 | namespace Xunit.Sdk 5 | { 6 | /// 7 | /// Base attribute which indicates a test method interception (allows code to be run before and 8 | /// after the test is run). 9 | /// 10 | [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true, Inherited = true)] 11 | public abstract class BeforeAfterTestAttribute : Attribute 12 | { 13 | /// 14 | /// This method is called after the test method is executed. 15 | /// 16 | /// The method under test 17 | public virtual void After(MethodInfo methodUnderTest) { } 18 | 19 | /// 20 | /// This method is called before the test method is executed. 21 | /// 22 | /// The method under test 23 | public virtual void Before(MethodInfo methodUnderTest) { } 24 | } 25 | } -------------------------------------------------------------------------------- /src/xunit.core/Sdk/DataAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | 5 | namespace Xunit.Sdk 6 | { 7 | /// 8 | /// Abstract attribute which represents a data source for a data theory. 9 | /// Data source providers derive from this attribute and implement GetData 10 | /// to return the data for the theory. 11 | /// 12 | [DataDiscoverer("Xunit.Sdk.DataDiscoverer", "xunit.core")] 13 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)] 14 | public abstract class DataAttribute : Attribute 15 | { 16 | /// 17 | /// Returns the data to be used to test the theory. 18 | /// 19 | /// The method that is being tested 20 | /// One or more sets of theory data. Each invocation of the test method 21 | /// is represented by a single object array. 22 | public abstract IEnumerable GetData(MethodInfo testMethod); 23 | } 24 | } -------------------------------------------------------------------------------- /src/xunit.core/Sdk/DataDiscoverer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Xunit.Abstractions; 3 | 4 | namespace Xunit.Sdk 5 | { 6 | /// 7 | /// Default implementation of . Uses reflection to find the 8 | /// data associated with ; may return null when called 9 | /// without reflection-based abstraction implementations. 10 | /// 11 | public class DataDiscoverer : IDataDiscoverer 12 | { 13 | /// 14 | public virtual IEnumerable GetData(IAttributeInfo dataAttribute, IMethodInfo testMethod) 15 | { 16 | var reflectionDataAttribute = dataAttribute as IReflectionAttributeInfo; 17 | var reflectionTestMethod = testMethod as IReflectionMethodInfo; 18 | 19 | if (reflectionDataAttribute != null && reflectionTestMethod != null) 20 | return ((DataAttribute)reflectionDataAttribute.Attribute).GetData(reflectionTestMethod.MethodInfo); 21 | 22 | return null; 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/xunit.core/Sdk/DataDiscovererAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Xunit.Sdk 4 | { 5 | /// 6 | /// An attribute used to decorate classes which derive from , 7 | /// to indicate how data elements should be discovered. 8 | /// 9 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] 10 | public sealed class DataDiscovererAttribute : Attribute 11 | { 12 | /// 13 | /// Initializes an instance of . 14 | /// 15 | /// The fully qualified type name of the discoverer 16 | /// (f.e., 'Xunit.Sdk.DataDiscoverer') 17 | /// The name of the assembly that the discoverer type 18 | /// is located in, without file extension (f.e., 'xunit.execution') 19 | public DataDiscovererAttribute(string typeName, string assemblyName) { } 20 | } 21 | } -------------------------------------------------------------------------------- /src/xunit.core/Sdk/IMessageAggregator.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Xunit.Sdk 4 | { 5 | /// 6 | /// Represents an aggregator which collects and returns messages of arbitrary types. 7 | /// 8 | public interface IMessageAggregator 9 | { 10 | /// 11 | /// Adds the specified message to the aggregation for the given type. 12 | /// 13 | /// The type of the message. 14 | /// The message. 15 | void Add(TMessage message); 16 | 17 | /// 18 | /// Returns all the currently aggregated messages of the given type, and clears 19 | /// the list for future iterations. 20 | /// 21 | /// The type of the message. 22 | /// The aggregated messages. 23 | IEnumerable GetAndClear(); 24 | } 25 | } -------------------------------------------------------------------------------- /src/xunit.core/Sdk/IMessageBus.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit.Abstractions; 3 | 4 | namespace Xunit.Sdk 5 | { 6 | /// 7 | /// This is an internal interface, and is not intended to be called from end-user code. 8 | /// 9 | public interface IMessageBus : IDisposable 10 | { 11 | /// 12 | bool QueueMessage(IMessageSinkMessage message); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/xunit.core/Sdk/ITestCaseOrderer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Xunit.Abstractions; 3 | 4 | namespace Xunit.Sdk 5 | { 6 | /// 7 | /// A class implements this interface to participate in ordering tests 8 | /// for the test runner. Test case orderers are applied using the 9 | /// , which can be applied at 10 | /// the assembly, test collection, and test class level. 11 | /// 12 | public interface ITestCaseOrderer 13 | { 14 | /// 15 | /// Orders test cases for execution. 16 | /// 17 | /// The test cases to be ordered. 18 | /// The test cases in the order to be run. 19 | IEnumerable OrderTestCases(IEnumerable testCases) where TTestCase : ITestCase; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/xunit.core/Sdk/ITraitAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit.Sdk 2 | { 3 | /// 4 | /// Marker interface used by attributes which provide trait data. 5 | /// 6 | public interface ITraitAttribute { } 7 | } 8 | -------------------------------------------------------------------------------- /src/xunit.core/Sdk/ITraitDiscoverer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Xunit.Abstractions; 3 | 4 | namespace Xunit.Sdk 5 | { 6 | /// 7 | /// This interface is implemented by discoverers that provide trait values to 8 | /// xUnit.net v2 tests. 9 | /// 10 | public interface ITraitDiscoverer 11 | { 12 | /// 13 | /// Gets the trait values from the trait attribute. 14 | /// 15 | /// The trait attribute containing the trait values. 16 | /// The trait values. 17 | IEnumerable> GetTraits(IAttributeInfo traitAttribute); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/xunit.core/Sdk/IXunitTestCase.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | using Xunit.Abstractions; 4 | 5 | namespace Xunit.Sdk 6 | { 7 | /// 8 | /// Represents a single test case from xUnit.net v2. 9 | /// 10 | public interface IXunitTestCase : ITestCase 11 | { 12 | /// 13 | /// Executes the test case, returning 0 or more result messages through the message sink. 14 | /// 15 | /// The message bus to report results to. 16 | /// The arguments to pass to the constructor. 17 | /// The error aggregator to use for catching exception. 18 | /// The cancellation token source that indicates whether cancellation has been requested. 19 | /// Returns the summary of the test case run. 20 | Task RunAsync(IMessageBus messageBus, object[] constructorArguments, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/xunit.core/Sdk/IXunitTestCollectionFactory.cs: -------------------------------------------------------------------------------- 1 | using Xunit.Abstractions; 2 | 3 | namespace Xunit.Sdk 4 | { 5 | /// 6 | /// This interface is intended to be implemented by components which generate test collections. 7 | /// End users specify the desired test collection factory by applying 8 | /// at the assembly level. 9 | /// 10 | public interface IXunitTestCollectionFactory 11 | { 12 | /// 13 | /// Gets the display name for the test collection factory. This information is shown to the end 14 | /// user as part of the description of the test environment. 15 | /// 16 | string DisplayName { get; } 17 | 18 | /// 19 | /// Gets the test collection for a given test class. 20 | /// 21 | /// The test class. 22 | /// The test collection. 23 | ITestCollection Get(ITypeInfo testClass); 24 | } 25 | } -------------------------------------------------------------------------------- /src/xunit.core/Sdk/TraitDiscoverer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Xunit.Abstractions; 5 | 6 | namespace Xunit.Sdk 7 | { 8 | /// 9 | /// The implementation of which returns the trait values 10 | /// for . 11 | /// 12 | public class TraitDiscoverer : ITraitDiscoverer 13 | { 14 | /// 15 | public virtual IEnumerable> GetTraits(IAttributeInfo traitAttribute) 16 | { 17 | var ctorArgs = traitAttribute.GetConstructorArguments().Cast().ToList(); 18 | yield return new KeyValuePair(ctorArgs[0], ctorArgs[1]); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/xunit.core/Sdk/TraitDiscovererAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Xunit.Sdk 4 | { 5 | /// 6 | /// An attribute used to decorate classes which implement , 7 | /// to indicate how trait values should be discovered. The discoverer type must implement 8 | /// . 9 | /// 10 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] 11 | public sealed class TraitDiscovererAttribute : Attribute 12 | { 13 | /// 14 | /// Initializes an instance of . 15 | /// 16 | /// The fully qualified type name of the discoverer 17 | /// (f.e., 'Xunit.Sdk.TraitDiscoverer') 18 | /// The name of the assembly that the discoverer type 19 | /// is located in, without file extension (f.e., 'xunit.execution') 20 | public TraitDiscovererAttribute(string typeName, string assemblyName) { } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/xunit.core/Sdk/XunitTestCaseDiscovererAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Xunit.Sdk 4 | { 5 | /// 6 | /// An attribute used to decorate classes which derive from , 7 | /// to indicate how test cases should be discovered. 8 | /// 9 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] 10 | public sealed class XunitTestCaseDiscovererAttribute : Attribute 11 | { 12 | /// 13 | /// Initializes an instance of the class. 14 | /// 15 | /// The fully qualified type name of the discoverer 16 | /// (f.e., 'Xunit.Sdk.FactDiscoverer') 17 | /// The name of the assembly that the discoverer type 18 | /// is located in, without file extension (f.e., 'xunit.execution') 19 | public XunitTestCaseDiscovererAttribute(string typeName, string assemblyName) { } 20 | } 21 | } -------------------------------------------------------------------------------- /src/xunit.core/TestCaseOrdererAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Xunit 4 | { 5 | /// 6 | /// Used to decorate an assembly, test collection, or test class to allow 7 | /// the use a custom . 8 | /// 9 | [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class, Inherited = true, AllowMultiple = false)] 10 | public sealed class TestCaseOrdererAttribute : Attribute 11 | { 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | /// The type name of the orderer class (that implements ). 16 | /// The assembly that exists in. 17 | public TestCaseOrdererAttribute(string ordererTypeName, string ordererAssemblyName) { } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/xunit.core/TestFrameworkAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Xunit 4 | { 5 | /// 6 | /// Used to decorate an assembly to allow the use a custom . 7 | /// 8 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)] 9 | public sealed class TestFrameworkAttribute : Attribute 10 | { 11 | /// 12 | /// Initializes an instance of . 13 | /// 14 | /// The fully qualified type name of the test framework 15 | /// (f.e., 'Xunit.Sdk.XunitTestFramework') 16 | /// The name of the assembly that the test framework type 17 | /// is located in, without file extension (f.e., 'xunit.execution') 18 | public TestFrameworkAttribute(string typeName, string assemblyName) { } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/xunit.core/TheoryAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit.Sdk; 3 | 4 | namespace Xunit 5 | { 6 | /// 7 | /// Marks a test method as being a data theory. Data theories are tests which are fed 8 | /// various bits of data from a data source, mapping to parameters on the test method. 9 | /// If the data source contains multiple rows, then the test method is executed 10 | /// multiple times (once with each data row). Data is provided by attributes which 11 | /// derive from (notably, and 12 | /// ). 13 | /// 14 | [XunitTestCaseDiscoverer("Xunit.Sdk.TheoryDiscoverer", "xunit.execution")] 15 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] 16 | public class TheoryAttribute : FactAttribute { } 17 | } -------------------------------------------------------------------------------- /src/xunit.core/TraitAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit.Sdk; 3 | 4 | namespace Xunit 5 | { 6 | /// 7 | /// Attribute used to decorate a test method with arbitrary name/value pairs ("traits"). 8 | /// 9 | [TraitDiscoverer("Xunit.Sdk.TraitDiscoverer", "xunit.core")] 10 | [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true)] 11 | public sealed class TraitAttribute : Attribute, ITraitAttribute 12 | { 13 | /// 14 | /// Creates a new instance of the class. 15 | /// 16 | /// The trait name 17 | /// The trait value 18 | public TraitAttribute(string name, string value) { } 19 | } 20 | } -------------------------------------------------------------------------------- /src/xunit.core/build/xunit.core.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | PreserveNewest 6 | False 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/xunit.core/xunit.core.dll.tdnet: -------------------------------------------------------------------------------- 1 | 2 | xUnit.net {0}.{1}.{2} build {3} 3 | xunit.runner.tdnet.dll 4 | Xunit.Runner.TdNet.TdNetRunner 5 | -------------------------------------------------------------------------------- /src/xunit.empty.ruleset: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/xunit.execution/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Security; 4 | 5 | [assembly: AssemblyTitle("xUnit.net")] 6 | [assembly: CLSCompliant(true)] 7 | -------------------------------------------------------------------------------- /src/xunit.execution/Sdk/DisposalTracker.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Xunit.Sdk 5 | { 6 | /// 7 | /// Tracks disposable objects, and disposes them in the reverse order they were added to 8 | /// the tracker. 9 | /// 10 | public class DisposalTracker : IDisposable 11 | { 12 | readonly Stack toDispose = new Stack(); 13 | 14 | /// 15 | /// Add an object to be disposed. 16 | /// 17 | /// The object to be disposed. 18 | public void Add(IDisposable disposable) 19 | { 20 | toDispose.Push(disposable); 21 | } 22 | 23 | /// 24 | public void Dispose() 25 | { 26 | foreach (var disposable in toDispose) 27 | disposable.Dispose(); 28 | 29 | toDispose.Clear(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/xunit.execution/Sdk/EnvironmentalWarning.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Xunit.Sdk 5 | { 6 | /// 7 | /// Messages reported during test discovery that indicate that there is an issue with the 8 | /// test environment (for example, declaring two test collection classes with the same 9 | /// test collection name). 10 | /// 11 | public class EnvironmentalWarning 12 | { 13 | /// 14 | /// The warning message. 15 | /// 16 | public string Message { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/xunit.execution/Sdk/Frameworks/FactDiscoverer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Xunit.Abstractions; 3 | 4 | namespace Xunit.Sdk 5 | { 6 | /// 7 | /// Implementation of that supports finding test cases 8 | /// on methods decorated with . 9 | /// 10 | public class FactDiscoverer : IXunitTestCaseDiscoverer 11 | { 12 | /// 13 | public IEnumerable Discover(ITestCollection testCollection, IAssemblyInfo assembly, ITypeInfo testClass, IMethodInfo testMethod, IAttributeInfo factAttribute) 14 | { 15 | yield return new XunitTestCase(testCollection, assembly, testClass, testMethod, factAttribute); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /src/xunit.execution/Sdk/Frameworks/TestCollectionComparer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Xunit.Abstractions; 3 | 4 | namespace Xunit.Sdk 5 | { 6 | /// 7 | /// An implementation of for . 8 | /// Compares the IDs of the test collections. 9 | /// 10 | public class TestCollectionComparer : IEqualityComparer 11 | { 12 | /// 13 | /// The singleton instance of the comparer. 14 | /// 15 | public static readonly TestCollectionComparer Instance = new TestCollectionComparer(); 16 | 17 | /// 18 | public bool Equals(ITestCollection x, ITestCollection y) 19 | { 20 | return x.ID == y.ID; 21 | } 22 | 23 | /// 24 | public int GetHashCode(ITestCollection obj) 25 | { 26 | return obj.ID.GetHashCode(); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/xunit.execution/Sdk/Frameworks/XunitTestFramework.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using Xunit.Abstractions; 3 | 4 | namespace Xunit.Sdk 5 | { 6 | /// 7 | /// The implementation of that supports discovery and 8 | /// execution of unit tests linked against xunit.core.dll, using xunit.execution.dll. 9 | /// 10 | public class XunitTestFramework : TestFramework 11 | { 12 | /// 13 | protected override ITestFrameworkDiscoverer CreateDiscoverer(IAssemblyInfo assemblyInfo) 14 | { 15 | return new XunitTestFrameworkDiscoverer(assemblyInfo, SourceInformationProvider); 16 | } 17 | 18 | /// 19 | protected override ITestFrameworkExecutor CreateExecutor(AssemblyName assemblyName) 20 | { 21 | return new XunitTestFrameworkExecutor(assemblyName, SourceInformationProvider); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/xunit.execution/Sdk/Messages/AfterTestFinished.cs: -------------------------------------------------------------------------------- 1 | using Xunit.Abstractions; 2 | 3 | #if XUNIT_CORE_DLL 4 | namespace Xunit.Sdk 5 | #else 6 | namespace Xunit 7 | #endif 8 | { 9 | /// 10 | /// Default implementation of . 11 | /// 12 | public class AfterTestFinished : TestMessage, IAfterTestFinished 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | public AfterTestFinished(ITestCase testCase, string testDisplayName, string attributeName) 18 | : base(testCase, testDisplayName) 19 | { 20 | AttributeName = attributeName; 21 | } 22 | 23 | /// 24 | public string AttributeName { get; private set; } 25 | } 26 | } -------------------------------------------------------------------------------- /src/xunit.execution/Sdk/Messages/AfterTestStarting.cs: -------------------------------------------------------------------------------- 1 | using Xunit.Abstractions; 2 | 3 | #if XUNIT_CORE_DLL 4 | namespace Xunit.Sdk 5 | #else 6 | namespace Xunit 7 | #endif 8 | { 9 | /// 10 | /// Default implementation of . 11 | /// 12 | public class AfterTestStarting : TestMessage, IAfterTestStarting 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | public AfterTestStarting(ITestCase testCase, string testDisplayName, string attributeName) 18 | : base(testCase, testDisplayName) 19 | { 20 | AttributeName = attributeName; 21 | } 22 | 23 | /// 24 | public string AttributeName { get; private set; } 25 | } 26 | } -------------------------------------------------------------------------------- /src/xunit.execution/Sdk/Messages/BaseMessages/TestCaseMessage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using Xunit.Abstractions; 4 | 5 | #if XUNIT_CORE_DLL 6 | namespace Xunit.Sdk 7 | #else 8 | namespace Xunit 9 | #endif 10 | { 11 | /// 12 | /// Default implementation of . 13 | /// 14 | public class TestCaseMessage : TestCollectionMessage, ITestCaseMessage 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | public TestCaseMessage(ITestCase testCase) 20 | : base(testCase.TestCollection) 21 | { 22 | TestCase = testCase; 23 | } 24 | 25 | /// 26 | public ITestCase TestCase { get; private set; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/xunit.execution/Sdk/Messages/BaseMessages/TestClassMessage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using Xunit.Abstractions; 4 | 5 | #if XUNIT_CORE_DLL 6 | namespace Xunit.Sdk 7 | #else 8 | namespace Xunit 9 | #endif 10 | { 11 | /// 12 | /// Default implementation of . 13 | /// 14 | public class TestClassMessage : TestCollectionMessage, ITestClassMessage 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | public TestClassMessage(ITestCollection testCollection, string className) 20 | : base(testCollection) 21 | { 22 | ClassName = className; 23 | } 24 | 25 | /// 26 | public string ClassName { get; private set; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/xunit.execution/Sdk/Messages/BaseMessages/TestCollectionMessage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using Xunit.Abstractions; 4 | 5 | #if XUNIT_CORE_DLL 6 | namespace Xunit.Sdk 7 | #else 8 | namespace Xunit 9 | #endif 10 | { 11 | /// 12 | /// Default implementation of . 13 | /// 14 | public class TestCollectionMessage : LongLivedMarshalByRefObject, ITestCollectionMessage 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | public TestCollectionMessage(ITestCollection testCollection) 20 | { 21 | TestCollection = testCollection; 22 | } 23 | 24 | /// 25 | public ITestCollection TestCollection { get; private set; } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/xunit.execution/Sdk/Messages/BaseMessages/TestMessage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using Xunit.Abstractions; 4 | 5 | #if XUNIT_CORE_DLL 6 | namespace Xunit.Sdk 7 | #else 8 | namespace Xunit 9 | #endif 10 | { 11 | /// 12 | /// Default implementation of . 13 | /// 14 | public class TestMessage : TestCaseMessage, ITestMessage 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | public TestMessage(ITestCase testCase, string testDisplayName) 20 | : base(testCase) 21 | { 22 | TestDisplayName = testDisplayName; 23 | } 24 | 25 | /// 26 | public string TestDisplayName { get; private set; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/xunit.execution/Sdk/Messages/BaseMessages/TestResultMessage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit.Abstractions; 3 | 4 | #if XUNIT_CORE_DLL 5 | namespace Xunit.Sdk 6 | #else 7 | namespace Xunit 8 | #endif 9 | { 10 | /// 11 | /// Default implementation of . 12 | /// 13 | public class TestResultMessage : TestMessage, ITestResultMessage 14 | { 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | public TestResultMessage(ITestCase testCase, string testDisplayName, decimal executionTime, string output) 19 | : base(testCase, testDisplayName) 20 | { 21 | ExecutionTime = executionTime; 22 | Output = output ?? String.Empty; 23 | } 24 | 25 | /// 26 | public decimal ExecutionTime { get; private set; } 27 | 28 | /// 29 | public string Output { get; private set; } 30 | } 31 | } -------------------------------------------------------------------------------- /src/xunit.execution/Sdk/Messages/BeforeTestFinished.cs: -------------------------------------------------------------------------------- 1 | using Xunit.Abstractions; 2 | 3 | #if XUNIT_CORE_DLL 4 | namespace Xunit.Sdk 5 | #else 6 | namespace Xunit 7 | #endif 8 | { 9 | /// 10 | /// Default implementation of . 11 | /// 12 | public class BeforeTestFinished : TestMessage, IBeforeTestFinished 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | public BeforeTestFinished(ITestCase testCase, string testDisplayName, string attributeName) 18 | : base(testCase, testDisplayName) 19 | { 20 | AttributeName = attributeName; 21 | } 22 | 23 | /// 24 | public string AttributeName { get; private set; } 25 | } 26 | } -------------------------------------------------------------------------------- /src/xunit.execution/Sdk/Messages/BeforeTestStarting.cs: -------------------------------------------------------------------------------- 1 | using Xunit.Abstractions; 2 | 3 | #if XUNIT_CORE_DLL 4 | namespace Xunit.Sdk 5 | #else 6 | namespace Xunit 7 | #endif 8 | { 9 | /// 10 | /// Default implementation of . 11 | /// 12 | public class BeforeTestStarting : TestMessage, IBeforeTestStarting 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | public BeforeTestStarting(ITestCase testCase, string testDisplayName, string attributeName) 18 | : base(testCase, testDisplayName) 19 | { 20 | AttributeName = attributeName; 21 | } 22 | 23 | /// 24 | public string AttributeName { get; private set; } 25 | } 26 | } -------------------------------------------------------------------------------- /src/xunit.execution/Sdk/Messages/DiscoveryCompleteMessage.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Xunit.Abstractions; 3 | 4 | #if XUNIT_CORE_DLL 5 | namespace Xunit.Sdk 6 | #else 7 | namespace Xunit 8 | #endif 9 | { 10 | /// 11 | /// Default implementation of . 12 | /// 13 | public class DiscoveryCompleteMessage : LongLivedMarshalByRefObject, IDiscoveryCompleteMessage 14 | { 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | public DiscoveryCompleteMessage(IEnumerable warnings) 19 | { 20 | Warnings = warnings; 21 | } 22 | 23 | /// 24 | public IEnumerable Warnings { get; private set; } 25 | } 26 | } -------------------------------------------------------------------------------- /src/xunit.execution/Sdk/Messages/TestCaseDiscoveryMessage.cs: -------------------------------------------------------------------------------- 1 | using Xunit.Abstractions; 2 | 3 | #if XUNIT_CORE_DLL 4 | namespace Xunit.Sdk 5 | #else 6 | namespace Xunit 7 | #endif 8 | { 9 | /// 10 | /// Default implementation of . 11 | /// 12 | public class TestCaseDiscoveryMessage : TestCaseMessage, ITestCaseDiscoveryMessage 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | public TestCaseDiscoveryMessage(ITestCase testCase) 18 | : base(testCase) { } 19 | } 20 | } -------------------------------------------------------------------------------- /src/xunit.execution/Sdk/Messages/TestCaseStarting.cs: -------------------------------------------------------------------------------- 1 | using Xunit.Abstractions; 2 | 3 | #if XUNIT_CORE_DLL 4 | namespace Xunit.Sdk 5 | #else 6 | namespace Xunit 7 | #endif 8 | { 9 | /// 10 | /// Default implementation of . 11 | /// 12 | public class TestCaseStarting : TestCaseMessage, ITestCaseStarting 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | public TestCaseStarting(ITestCase testCase) 18 | : base(testCase) { } 19 | } 20 | } -------------------------------------------------------------------------------- /src/xunit.execution/Sdk/Messages/TestClassConstructionFinished.cs: -------------------------------------------------------------------------------- 1 | using Xunit.Abstractions; 2 | 3 | #if XUNIT_CORE_DLL 4 | namespace Xunit.Sdk 5 | #else 6 | namespace Xunit 7 | #endif 8 | { 9 | /// 10 | /// Default implementation of . 11 | /// 12 | public class TestClassConstructionFinished : TestMessage, ITestClassConstructionFinished 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | public TestClassConstructionFinished(ITestCase testCase, string testDisplayName) 18 | : base(testCase, testDisplayName) { } 19 | } 20 | } -------------------------------------------------------------------------------- /src/xunit.execution/Sdk/Messages/TestClassConstructionStarting.cs: -------------------------------------------------------------------------------- 1 | using Xunit.Abstractions; 2 | 3 | #if XUNIT_CORE_DLL 4 | namespace Xunit.Sdk 5 | #else 6 | namespace Xunit 7 | #endif 8 | { 9 | /// 10 | /// Default implementation of . 11 | /// 12 | public class TestClassConstructionStarting : TestMessage, ITestClassConstructionStarting 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | public TestClassConstructionStarting(ITestCase testCase, string testDisplayName) 18 | : base(testCase, testDisplayName) { } 19 | } 20 | } -------------------------------------------------------------------------------- /src/xunit.execution/Sdk/Messages/TestClassDisposeFinished.cs: -------------------------------------------------------------------------------- 1 | using Xunit.Abstractions; 2 | 3 | #if XUNIT_CORE_DLL 4 | namespace Xunit.Sdk 5 | #else 6 | namespace Xunit 7 | #endif 8 | { 9 | /// 10 | /// Default implementation of . 11 | /// 12 | public class TestClassDisposeFinished : TestMessage, ITestClassDisposeFinished 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | public TestClassDisposeFinished(ITestCase testCase, string testDisplayName) 18 | : base(testCase, testDisplayName) { } 19 | } 20 | } -------------------------------------------------------------------------------- /src/xunit.execution/Sdk/Messages/TestClassDisposeStarting.cs: -------------------------------------------------------------------------------- 1 | using Xunit.Abstractions; 2 | 3 | #if XUNIT_CORE_DLL 4 | namespace Xunit.Sdk 5 | #else 6 | namespace Xunit 7 | #endif 8 | { 9 | /// 10 | /// Default implementation of . 11 | /// 12 | public class TestClassDisposeStarting : TestMessage, ITestClassDisposeStarting 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | public TestClassDisposeStarting(ITestCase testCase, string testDisplayName) 18 | : base(testCase, testDisplayName) { } 19 | } 20 | } -------------------------------------------------------------------------------- /src/xunit.execution/Sdk/Messages/TestClassStarting.cs: -------------------------------------------------------------------------------- 1 | using Xunit.Abstractions; 2 | 3 | #if XUNIT_CORE_DLL 4 | namespace Xunit.Sdk 5 | #else 6 | namespace Xunit 7 | #endif 8 | { 9 | /// 10 | /// Default implementation of . 11 | /// 12 | public class TestClassStarting : TestClassMessage, ITestClassStarting 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | public TestClassStarting(ITestCollection testCollection, string className) 18 | : base(testCollection, className) { } 19 | } 20 | } -------------------------------------------------------------------------------- /src/xunit.execution/Sdk/Messages/TestCollectionStarting.cs: -------------------------------------------------------------------------------- 1 | using Xunit.Abstractions; 2 | 3 | #if XUNIT_CORE_DLL 4 | namespace Xunit.Sdk 5 | #else 6 | namespace Xunit 7 | #endif 8 | { 9 | /// 10 | /// Default implementation of . 11 | /// 12 | public class TestCollectionStarting : TestCollectionMessage, ITestCollectionStarting 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | public TestCollectionStarting(ITestCollection testCollection) 18 | : base(testCollection) { } 19 | } 20 | } -------------------------------------------------------------------------------- /src/xunit.execution/Sdk/Messages/TestFinished.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit.Abstractions; 3 | 4 | #if XUNIT_CORE_DLL 5 | namespace Xunit.Sdk 6 | #else 7 | namespace Xunit 8 | #endif 9 | { 10 | /// 11 | /// Default implementation of . 12 | /// 13 | public class TestFinished : TestMessage, ITestFinished 14 | { 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | public TestFinished(ITestCase testCase, string testDisplayName, decimal executionTime, string output) 19 | : base(testCase, testDisplayName) 20 | { 21 | ExecutionTime = executionTime; 22 | Output = output ?? String.Empty; 23 | } 24 | 25 | /// 26 | public decimal ExecutionTime { get; private set; } 27 | 28 | /// 29 | public string Output { get; private set; } 30 | } 31 | } -------------------------------------------------------------------------------- /src/xunit.execution/Sdk/Messages/TestMethodFinished.cs: -------------------------------------------------------------------------------- 1 | using Xunit.Abstractions; 2 | 3 | #if XUNIT_CORE_DLL 4 | namespace Xunit.Sdk 5 | #else 6 | namespace Xunit 7 | #endif 8 | { 9 | /// 10 | /// Default implementation of . 11 | /// 12 | public class TestMethodFinished : TestCollectionMessage, ITestMethodFinished 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | public TestMethodFinished(ITestCollection testCollection, string className, string methodName) 18 | : base(testCollection) 19 | { 20 | ClassName = className; 21 | MethodName = methodName; 22 | } 23 | 24 | /// 25 | public string ClassName { get; private set; } 26 | 27 | /// 28 | public string MethodName { get; private set; } 29 | } 30 | } -------------------------------------------------------------------------------- /src/xunit.execution/Sdk/Messages/TestMethodStarting.cs: -------------------------------------------------------------------------------- 1 | using Xunit.Abstractions; 2 | 3 | #if XUNIT_CORE_DLL 4 | namespace Xunit.Sdk 5 | #else 6 | namespace Xunit 7 | #endif 8 | { 9 | /// 10 | /// Default implementation of . 11 | /// 12 | public class TestMethodStarting : TestCollectionMessage, ITestMethodStarting 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | public TestMethodStarting(ITestCollection testCollection, string className, string methodName) 18 | : base(testCollection) 19 | { 20 | ClassName = className; 21 | MethodName = methodName; 22 | } 23 | 24 | /// 25 | public string ClassName { get; private set; } 26 | 27 | /// 28 | public string MethodName { get; private set; } 29 | } 30 | } -------------------------------------------------------------------------------- /src/xunit.execution/Sdk/Messages/TestPassed.cs: -------------------------------------------------------------------------------- 1 | using Xunit.Abstractions; 2 | 3 | #if XUNIT_CORE_DLL 4 | namespace Xunit.Sdk 5 | #else 6 | namespace Xunit 7 | #endif 8 | { 9 | /// 10 | /// Default implementation of . 11 | /// 12 | public class TestPassed : TestResultMessage, ITestPassed 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | public TestPassed(ITestCase testCase, string testDisplayName, decimal executionTime, string output) 18 | : base(testCase, testDisplayName, executionTime, output) { } 19 | } 20 | } -------------------------------------------------------------------------------- /src/xunit.execution/Sdk/Messages/TestSkipped.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit.Abstractions; 3 | 4 | #if XUNIT_CORE_DLL 5 | namespace Xunit.Sdk 6 | #else 7 | namespace Xunit 8 | #endif 9 | { 10 | /// 11 | /// Default implementation of . 12 | /// 13 | public class TestSkipped : TestResultMessage, ITestSkipped 14 | { 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | public TestSkipped(ITestCase testCase, string testDisplayName, string reason) 19 | : base(testCase, testDisplayName, 0, null) 20 | { 21 | Reason = reason; 22 | } 23 | 24 | /// 25 | public string Reason { get; private set; } 26 | } 27 | } -------------------------------------------------------------------------------- /src/xunit.execution/Sdk/Messages/TestStarting.cs: -------------------------------------------------------------------------------- 1 | using Xunit.Abstractions; 2 | 3 | #if XUNIT_CORE_DLL 4 | namespace Xunit.Sdk 5 | #else 6 | namespace Xunit 7 | #endif 8 | { 9 | /// 10 | /// Default implementation of . 11 | /// 12 | public class TestStarting : TestMessage, ITestStarting 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | public TestStarting(ITestCase testCase, string testDisplayName) 18 | : base(testCase, testDisplayName) { } 19 | } 20 | } -------------------------------------------------------------------------------- /src/xunit.execution/Sdk/Reflection/ReflectionParameterInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using Xunit.Abstractions; 3 | 4 | namespace Xunit.Sdk 5 | { 6 | /// 7 | /// Reflection-based implementation of . 8 | /// 9 | public class ReflectionParameterInfo : LongLivedMarshalByRefObject, IReflectionParameterInfo 10 | { 11 | /// 12 | /// Initializes a new instance of the class. 13 | /// 14 | /// The parameter to be wrapped. 15 | public ReflectionParameterInfo(ParameterInfo parameterInfo) 16 | { 17 | ParameterInfo = parameterInfo; 18 | } 19 | 20 | /// 21 | public string Name 22 | { 23 | get { return ParameterInfo.Name; } 24 | } 25 | 26 | /// 27 | public ParameterInfo ParameterInfo { get; private set; } 28 | 29 | /// 30 | public ITypeInfo ParameterType 31 | { 32 | get { return Reflector.Wrap(ParameterInfo.ParameterType); } 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /src/xunit.execution/Sdk/SynchronousMessageBus.cs: -------------------------------------------------------------------------------- 1 | using Xunit.Abstractions; 2 | 3 | namespace Xunit.Sdk 4 | { 5 | /// 6 | /// This is an internal class, and is not intended to be called from end-user code. 7 | /// 8 | public class SynchronousMessageBus : IMessageBus 9 | { 10 | private readonly IMessageSink messageSink; 11 | 12 | /// 13 | public SynchronousMessageBus(IMessageSink messageSink) 14 | { 15 | this.messageSink = messageSink; 16 | } 17 | 18 | /// 19 | public void Dispose() { } 20 | 21 | /// 22 | public bool QueueMessage(IMessageSinkMessage message) 23 | { 24 | return messageSink.OnMessage(message); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/xunit.execution/Sdk/TestClassException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | using System.Runtime.Serialization; 4 | 5 | namespace Xunit.Sdk 6 | { 7 | /// 8 | /// Represents an exception that happened during the process of a test class. This typically 9 | /// means there were problems identifying the correct test class constructor, or problems 10 | /// creating the fixture data for the test class. 11 | /// 12 | [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")] 13 | [Serializable] 14 | public class TestClassException : Exception 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The exception message. 20 | public TestClassException(string message) 21 | : base(message) { } 22 | 23 | /// 24 | protected TestClassException(SerializationInfo info, StreamingContext context) 25 | : base(info, context) { } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/xunit.execution/xunit.execution.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | xunit.execution 5 | 2.0.0-beta 6 | xUnit.net [Test Execution Library] 7 | James Newkirk, Brad Wilson 8 | 9 | Includes the execution framework for xUnit.net (xunit.execution.dll). 10 | Supported platforms: Desktop .NET 4.5+. 11 | 12 | en-US 13 | https://github.com/xunit/xunit 14 | https://raw.githubusercontent.com/xunit/media/master/logo-512-transparent.png 15 | https://raw.githubusercontent.com/xunit/xunit/master/license.txt 16 | false 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/xunit.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | xunit 5 | 2.0.0-beta 6 | xUnit.net 7 | James Newkirk, Brad Wilson 8 | 9 | xUnit.net is a developer testing framework, built to support Test Driven Development, with a design goal of extreme simplicity and alignment with framework features. 10 | Installing this package installs xunit.core and xunit.assert. 11 | 12 | en-US 13 | https://github.com/xunit/xunit 14 | https://raw.githubusercontent.com/xunit/media/master/logo-512-transparent.png 15 | https://raw.githubusercontent.com/xunit/xunit/master/license.txt 16 | false 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/xunit.ruleset: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/xunit.runner.msbuild/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | [assembly: AssemblyTitle("xUnit.net MSBuild Test Runner")] -------------------------------------------------------------------------------- /src/xunit.runner.msbuild/Visitors/MSBuildVisitor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Xml.Linq; 4 | using Microsoft.Build.Utilities; 5 | 6 | namespace Xunit.Runner.MSBuild 7 | { 8 | public class MSBuildVisitor : XmlTestExecutionVisitor 9 | { 10 | public readonly TaskLoggingHelper Log; 11 | 12 | public MSBuildVisitor(TaskLoggingHelper log, XElement assemblyElement, Func cancelThunk) 13 | : base(assemblyElement, cancelThunk) 14 | { 15 | Log = log; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/xunit.runner.tdnet/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | [assembly : AssemblyTitle("xUnit.net Runner for TestDriven.NET")] -------------------------------------------------------------------------------- /src/xunit.runner.utility/Frameworks/IFrontController.cs: -------------------------------------------------------------------------------- 1 | using Xunit.Abstractions; 2 | 3 | namespace Xunit 4 | { 5 | /// 6 | /// Represents a class which acts as a front controller for unit testing frameworks. 7 | /// This allows runners to run tests from multiple unit testing frameworks (in particular, 8 | /// hiding the differences between xUnit.net v1 and v2 tests). 9 | /// 10 | public interface IFrontController : ITestFrameworkDiscoverer, ITestFrameworkExecutor 11 | { 12 | } 13 | } -------------------------------------------------------------------------------- /src/xunit.runner.utility/Frameworks/NullSourceInformationProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit.Abstractions; 3 | 4 | namespace Xunit 5 | { 6 | /// 7 | /// An implementation of that always returns no 8 | /// source information. Useful for test runners which don't need or cannot provide source 9 | /// information during discovery. 10 | /// 11 | public class NullSourceInformationProvider : LongLivedMarshalByRefObject, ISourceInformationProvider 12 | { 13 | /// 14 | public ISourceInformation GetSourceInformation(ITestCase testCase) 15 | { 16 | return new SourceInformation(); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /src/xunit.runner.utility/Frameworks/v1/XmlNodeExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Xml; 4 | using Xunit; 5 | 6 | internal static class XmlNodeExtensions 7 | { 8 | public static Xunit1TestCase ToTestCase(this XmlNode xml, string assemblyFileName) 9 | { 10 | if (xml.Name != "method") 11 | return null; 12 | 13 | var displayName = xml.Attributes["name"].Value; 14 | var type = xml.Attributes["type"].Value; 15 | var method = xml.Attributes["method"].Value; 16 | string skipReason = null; 17 | var traits = new Dictionary>(StringComparer.OrdinalIgnoreCase); 18 | 19 | var skipReasonAttribute = xml.Attributes["skip"]; 20 | if (skipReasonAttribute != null) 21 | skipReason = skipReasonAttribute.Value; 22 | 23 | foreach (XmlNode traitNode in xml.SelectNodes("traits/trait")) 24 | traits.Add(traitNode.Attributes["name"].Value, traitNode.Attributes["value"].Value); 25 | 26 | return new Xunit1TestCase(assemblyFileName, type, method, displayName, traits, skipReason); 27 | } 28 | } -------------------------------------------------------------------------------- /src/xunit.runner.utility/Frameworks/v2/XunitDiscoveryOptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace Xunit 6 | { 7 | /// 8 | /// Represents discovery options for xUnit.net v2 tests. 9 | /// 10 | // TODO: Need to figure out what might go here 11 | public class XunitDiscoveryOptions : TestFrameworkOptions 12 | { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/xunit.runner.utility/Project/XunitProjectAssembly.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Xunit 4 | { 5 | /// 6 | /// Represents an assembly in an . 7 | /// 8 | public class XunitProjectAssembly 9 | { 10 | /// 11 | /// Initializes a new instance of the class. 12 | /// 13 | public XunitProjectAssembly() 14 | { 15 | ShadowCopy = true; 16 | } 17 | 18 | /// 19 | /// Gets or sets the assembly filename. 20 | /// 21 | public string AssemblyFilename { get; set; } 22 | 23 | /// 24 | /// Gets or sets the config filename. 25 | /// 26 | public string ConfigFilename { get; set; } 27 | 28 | /// 29 | /// Gets or sets a value indicating whether to shadow copy the assembly 30 | /// when running the tests. 31 | /// 32 | public bool ShadowCopy { get; set; } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/xunit.runner.utility/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | 4 | [assembly: AssemblyTitle("xUnit.net Runner Utility")] 5 | [assembly: CLSCompliant(true)] -------------------------------------------------------------------------------- /src/xunit.runner.utility/Utility/DiaNavigationData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Xunit 5 | { 6 | internal class DiaNavigationData 7 | { 8 | public string FileName { get; set; } 9 | public int LineNumber { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/xunit.runner.utility/Utility/ExecutionSummary.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit 2 | { 3 | /// 4 | /// Collects execution totals for a group of test cases. 5 | /// 6 | public class ExecutionSummary 7 | { 8 | /// 9 | /// Gets or set the total number of tests run. 10 | /// 11 | public int Total { get; set; } 12 | 13 | /// 14 | /// Gets or sets the number of failed tests. 15 | /// 16 | public int Failed { get; set; } 17 | 18 | /// 19 | /// Gets or sets the number of skipped tests. 20 | /// 21 | public int Skipped { get; set; } 22 | 23 | /// 24 | /// Gets or sets the total execution time for the tests. 25 | /// 26 | public decimal Time { get; set; } 27 | } 28 | } -------------------------------------------------------------------------------- /src/xunit.runner.utility/Utility/LongLivedMarshalByRefObject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Remoting; 3 | using System.Security; 4 | 5 | namespace Xunit 6 | { 7 | /// 8 | /// This class inherits from and reimplements 9 | /// in a way that allows the object to live 10 | /// longer than the remoting default lifetime (5 minutes). 11 | /// 12 | public abstract class LongLivedMarshalByRefObject : MarshalByRefObject, IDisposable 13 | { 14 | /// 15 | [SecurityCritical] 16 | public override sealed Object InitializeLifetimeService() 17 | { 18 | return null; 19 | } 20 | 21 | /// 22 | [SecuritySafeCritical] 23 | public virtual void Dispose() 24 | { 25 | RemotingServices.Disconnect(this); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /src/xunit.runner.utility/Utility/RemotingUtility.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.Remoting.Channels; 2 | 3 | namespace Xunit 4 | { 5 | /// 6 | /// Internal helper class for remoting. 7 | /// 8 | public static class RemotingUtility 9 | { 10 | /// 11 | /// Unregisters any remoting channels. 12 | /// 13 | /// 14 | /// If there are any registered remoting channels, then MarshalByRefObjects 15 | /// don't work. Based on bug #9749, it's clear that MSTest (at least through 16 | /// Visual Studio 2010) registers remoting channels when it runs but doesn't 17 | /// clean them up when it's done. Right now, the only way to reliably surface 18 | /// this issue is through MSBuild (as per the bug repro), so for the moment 19 | /// this work-around code is limited to the MSBuild runner. 20 | /// 21 | public static void CleanUpRegisteredChannels() 22 | { 23 | foreach (IChannel chan in ChannelServices.RegisteredChannels) 24 | ChannelServices.UnregisterChannel(chan); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /src/xunit.runner.visualstudio.settings/Guids.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit.Runner.VisualStudio.Settings 2 | { 3 | public static class Guids 4 | { 5 | public const string Package = "200364A4-BD2D-4CF4-B80D-B1C9761BB6F7"; 6 | public const string PropertyPage = "11CDAE17-7F88-4E07-9B9B-DBE4179E6D3D"; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/xunit.runner.visualstudio.settings/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | [assembly: AssemblyTitle("xUnit.net Runner for Visual Studio (Settings)")] -------------------------------------------------------------------------------- /src/xunit.runner.visualstudio.settings/XunitVisualStudioPackage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using Microsoft.VisualStudio.Shell; 4 | 5 | namespace Xunit.Runner.VisualStudio.Settings 6 | { 7 | [PackageRegistration(UseManagedResourcesOnly = true)] 8 | [ProvideOptionPage(typeof(XunitVisualStudioSettings), "xUnit.net", "xUnit.net Settings", 115, 116, true)] 9 | [InstalledProductRegistration("#110", "#112", "0.99.6", IconResourceID = 400)] 10 | [Guid(Guids.Package)] 11 | public sealed class XunitVisualStudioPackage : Package 12 | { 13 | static XunitVisualStudioSettings settings; 14 | 15 | protected override void Initialize() 16 | { 17 | base.Initialize(); 18 | 19 | settings = GetDialogPage(typeof(XunitVisualStudioSettings)) as XunitVisualStudioSettings; 20 | settings.PropertyChanged += (sender, e) => SettingsProvider.Save(settings); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/xunit.runner.visualstudio.settings/[Content_Types].xml: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /src/xunit.runner.visualstudio.settings/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /src/xunit.runner.visualstudio.settings/xunit.runner.visualstudio.pkgdef: -------------------------------------------------------------------------------- 1 | [$RootKey$\InstalledProducts\xUnit.net] 2 | @="#110" 3 | "Package"="{623f78dd-6d4b-48f3-a2c7-4bbb381bb146}" 4 | "PID"="0.99.6" 5 | "ProductDetails"="#112" 6 | "LogoID"="#400" 7 | 8 | [$RootKey$\Packages\{623f78dd-6d4b-48f3-a2c7-4bbb381bb146}] 9 | @="Xunit.Runner.VisualStudio.Settings.XunitVisualStudioPackage, xunit.runner.visualstudio.settings" 10 | "InprocServer32"="$WinDir$\SYSTEM32\MSCOREE.DLL" 11 | "Class"="Xunit.Runner.VisualStudio.Settings.XunitVisualStudioPackage" 12 | "CodeBase"="$PackageFolder$\xunit.runner.visualstudio.settings.dll" 13 | 14 | [$RootKey$\Menus] 15 | "{623f78dd-6d4b-48f3-a2c7-4bbb381bb146}"=", Menus.ctmenu, 1" 16 | 17 | [$RootKey$\ToolsOptionsPages\xUnit.net] 18 | @="#110" 19 | "Package"="{623f78dd-6d4b-48f3-a2c7-4bbb381bb146}" 20 | 21 | [$RootKey$\ToolsOptionsPages\xUnit.net\Settings] 22 | @="#113" 23 | "Package"="{623f78dd-6d4b-48f3-a2c7-4bbb381bb146}" 24 | "Page"="{11CDAE17-7F88-4E07-9B9B-DBE4179E6D3D}" 25 | 26 | [$RootKey$\AutomationProperties\xUnit.net\Settings] 27 | "Name"="xUnit.net Settings" 28 | "Package"="{623f78dd-6d4b-48f3-a2c7-4bbb381bb146}" 29 | 30 | -------------------------------------------------------------------------------- /src/xunit.runner.visualstudio.testadapter/Constants.cs: -------------------------------------------------------------------------------- 1 | namespace Xunit.Runner.VisualStudio.TestAdapter 2 | { 3 | public static class Constants 4 | { 5 | public const string ExecutorUri = "executor://xunit/VsTestRunner2"; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/xunit.runner.visualstudio.testadapter/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | [assembly: AssemblyTitle("xUnit.net Runner for Visual Studio (Test Adapter)")] -------------------------------------------------------------------------------- /src/xunit.runner.visualstudio.testadapter/Settings/XunitTestRunSettingsProvider.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.Composition; 2 | using System.Xml; 3 | using System.Xml.Serialization; 4 | using Microsoft.VisualStudio.TestPlatform.ObjectModel; 5 | using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; 6 | 7 | namespace Xunit.Runner.VisualStudio.Settings 8 | { 9 | [Export(typeof(ISettingsProvider))] 10 | [SettingsName(XunitTestRunSettings.SettingsName)] 11 | public class XunitTestRunSettingsProvider : ISettingsProvider 12 | { 13 | private readonly XmlSerializer serializer = new XmlSerializer(typeof(XunitTestRunSettings)); 14 | 15 | public XunitTestRunSettings Settings { get; private set; } 16 | 17 | public void Load(XmlReader reader) 18 | { 19 | if (reader.Read() && reader.Name == XunitTestRunSettings.SettingsName) 20 | Settings = serializer.Deserialize(reader) as XunitTestRunSettings; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /src/xunit.runner.visualstudio.testadapter/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /test/GlobalTestAssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using TestDriven.Framework; 2 | using Xunit.Runner.TdNet; 3 | 4 | [assembly: CustomTestRunner(typeof(TdNetRunner))] 5 | -------------------------------------------------------------------------------- /test/test.utility/Abstractions/AssemblyWrapper.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Xunit.Abstractions; 3 | 4 | /// 5 | /// Creates a wrapper around to hide reflection implementations. 6 | /// 7 | public class AssemblyWrapper : IAssemblyInfo 8 | { 9 | readonly IAssemblyInfo inner; 10 | 11 | public AssemblyWrapper(IAssemblyInfo inner) 12 | { 13 | this.inner = inner; 14 | } 15 | 16 | public string AssemblyPath 17 | { 18 | get { return inner.AssemblyPath; } 19 | } 20 | 21 | public string Name { get { return inner.Name; } } 22 | 23 | public IEnumerable GetCustomAttributes(string assemblyQualifiedAttributeTypeName) 24 | { 25 | return inner.GetCustomAttributes(assemblyQualifiedAttributeTypeName); 26 | } 27 | 28 | public ITypeInfo GetType(string typeName) 29 | { 30 | return inner.GetType(typeName); 31 | } 32 | 33 | public IEnumerable GetTypes(bool includePrivateTypes) 34 | { 35 | return inner.GetTypes(includePrivateTypes); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /test/test.utility/Abstractions/AttributeWrapper.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Xunit.Abstractions; 3 | 4 | /// 5 | /// Creates a wrapper around to hide reflection implementations. 6 | /// 7 | public class AttributeWrapper : IAttributeInfo 8 | { 9 | readonly IAttributeInfo inner; 10 | 11 | public AttributeWrapper(IAttributeInfo inner) 12 | { 13 | this.inner = inner; 14 | } 15 | 16 | public IEnumerable GetConstructorArguments() 17 | { 18 | return inner.GetConstructorArguments(); 19 | } 20 | 21 | public IEnumerable GetCustomAttributes(string assemblyQualifiedAttributeTypeName) 22 | { 23 | return inner.GetCustomAttributes(assemblyQualifiedAttributeTypeName); 24 | } 25 | 26 | public TValue GetNamedArgument(string propertyName) 27 | { 28 | return inner.GetNamedArgument(propertyName); 29 | } 30 | } -------------------------------------------------------------------------------- /test/test.utility/Abstractions/TestCase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Xunit.Abstractions; 4 | using Xunit.Sdk; 5 | 6 | public class TestCase : ITestCase 7 | { 8 | public TestCase() 9 | { 10 | Traits = new Dictionary>(StringComparer.OrdinalIgnoreCase); 11 | } 12 | 13 | public TestCase(Type type, string methodName) 14 | : this() 15 | { 16 | Class = Reflector.Wrap(type); 17 | Method = Reflector.Wrap(type.GetMethod(methodName)); 18 | } 19 | 20 | public IAssemblyInfo Assembly { get; set; } 21 | public ITypeInfo Class { get; set; } 22 | public string ClassName { get; set; } 23 | public string DisplayName { get; set; } 24 | public IMethodInfo Method { get; set; } 25 | public string MethodName { get; set; } 26 | public string SkipReason { get; set; } 27 | public ISourceInformation SourceInformation { get; set; } 28 | public ITestCollection TestCollection { get; set; } 29 | public Dictionary> Traits { get; set; } 30 | public string UniqueID { get; set; } 31 | public object[] Arguments { get; set; } 32 | 33 | public void Dispose() { } 34 | } -------------------------------------------------------------------------------- /test/test.utility/Abstractions/TestCollection.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using Xunit.Abstractions; 4 | 5 | public class TestCollection : ITestCollection 6 | { 7 | public TestCollection() 8 | { 9 | ID = Guid.NewGuid(); 10 | } 11 | 12 | public ITypeInfo CollectionDefinition { get; set; } 13 | public string DisplayName { get; set; } 14 | public Guid ID { get; set; } 15 | } -------------------------------------------------------------------------------- /test/test.utility/Abstractions/TestPassed.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit.Abstractions; 3 | 4 | public class TestPassed : ITestPassed 5 | { 6 | public TestPassed() 7 | { 8 | TestCase = new TestCase(); 9 | TestCollection = new TestCollection(); 10 | Output = String.Empty; 11 | } 12 | 13 | public decimal ExecutionTime { get; set; } 14 | public string Output { get; set; } 15 | public ITestCase TestCase { get; set; } 16 | public ITestCollection TestCollection { get; set; } 17 | public string TestDisplayName { get; set; } 18 | 19 | public void Dispose() { } 20 | } -------------------------------------------------------------------------------- /test/test.utility/Abstractions/TestSkipped.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit.Abstractions; 3 | 4 | public class TestSkipped : ITestSkipped 5 | { 6 | public TestSkipped() 7 | { 8 | TestCase = new TestCase(); 9 | TestCollection = new TestCollection(); 10 | Output = String.Empty; 11 | } 12 | 13 | public decimal ExecutionTime { get; set; } 14 | public string Output { get; set; } 15 | public string Reason { get; set; } 16 | public ITestCase TestCase { get; set; } 17 | public ITestCollection TestCollection { get; set; } 18 | public string TestDisplayName { get; set; } 19 | 20 | public void Dispose() { } 21 | } -------------------------------------------------------------------------------- /test/test.utility/CulturedFactAttribute.cs: -------------------------------------------------------------------------------- 1 | using Xunit.Sdk; 2 | 3 | namespace Xunit 4 | { 5 | [XunitTestCaseDiscoverer("TestUtility.CulturedFactAttributeDiscoverer", "test.utility")] 6 | public sealed class CulturedFactAttribute : FactAttribute 7 | { 8 | public CulturedFactAttribute(params string[] cultures) { } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/test.utility/CulturedFactAttributeDiscoverer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using Xunit.Abstractions; 4 | using Xunit.Sdk; 5 | 6 | namespace TestUtility 7 | { 8 | public class CulturedFactAttributeDiscoverer : IXunitTestCaseDiscoverer 9 | { 10 | public IEnumerable Discover(ITestCollection testCollection, IAssemblyInfo assembly, ITypeInfo testClass, IMethodInfo testMethod, IAttributeInfo factAttribute) 11 | { 12 | var ctorArgs = factAttribute.GetConstructorArguments().ToArray(); 13 | var cultures = Reflector.ConvertArguments(ctorArgs, new[] { typeof(string[]) }).Cast().Single(); 14 | 15 | if (cultures == null || cultures.Length == 0) 16 | cultures = new[] { "en-US", "fr-FR" }; 17 | 18 | return cultures.Select(culture => new CulturedXunitTestCase(testCollection, assembly, testClass, testMethod, factAttribute, culture)).ToList(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /test/test.utility/PreserveWorkingDirectoryAttribute.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Reflection; 3 | using Xunit.Sdk; 4 | 5 | public class PreserveWorkingDirectoryAttribute : BeforeAfterTestAttribute 6 | { 7 | string workingDirectory; 8 | 9 | public override void Before(MethodInfo methodUnderTest) 10 | { 11 | workingDirectory = Directory.GetCurrentDirectory(); 12 | } 13 | 14 | public override void After(MethodInfo methodUnderTest) 15 | { 16 | Directory.SetCurrentDirectory(workingDirectory); 17 | } 18 | } -------------------------------------------------------------------------------- /test/test.utility/SerializationUtility.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Runtime.Serialization.Formatters.Binary; 3 | using Xunit; 4 | 5 | public static class SerializationUtility 6 | { 7 | public static T SerializeAndDeserialize(T obj) 8 | { 9 | Assert.NotNull(obj); 10 | 11 | using (var memoryStream = new MemoryStream()) 12 | { 13 | var formatter = new BinaryFormatter(); 14 | 15 | formatter.Serialize(memoryStream, obj); 16 | memoryStream.Seek(0, SeekOrigin.Begin); 17 | object deserialized = formatter.Deserialize(memoryStream); 18 | 19 | Assert.NotNull(deserialized); 20 | return Assert.IsType(deserialized); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test/test.utility/SpyBeforeAfterTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using Xunit.Sdk; 4 | 5 | public class SpyBeforeAfterTest : BeforeAfterTestAttribute 6 | { 7 | public bool ThrowInBefore { get; set; } 8 | public bool ThrowInAfter { get; set; } 9 | 10 | public override void Before(MethodInfo methodUnderTest) 11 | { 12 | if (ThrowInBefore) 13 | throw new BeforeException(); 14 | } 15 | 16 | public override void After(MethodInfo methodUnderTest) 17 | { 18 | if (ThrowInAfter) 19 | throw new AfterException(); 20 | } 21 | 22 | public class BeforeException : Exception { } 23 | 24 | public class AfterException : Exception { } 25 | } 26 | -------------------------------------------------------------------------------- /test/test.utility/SpyMessageBus.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Threading; 4 | using Xunit.Abstractions; 5 | using Xunit.Sdk; 6 | 7 | public class SpyMessageBus : LongLivedMarshalByRefObject, IMessageBus 8 | { 9 | readonly Func cancellationThunk; 10 | 11 | public SpyMessageBus(Func cancellationThunk = null) 12 | { 13 | this.cancellationThunk = cancellationThunk ?? (msg => true); 14 | } 15 | 16 | public ManualResetEvent Finished = new ManualResetEvent(initialState: false); 17 | 18 | public List Messages = new List(); 19 | 20 | /// 21 | public void Dispose() { } 22 | 23 | public bool QueueMessage(IMessageSinkMessage message) 24 | { 25 | Messages.Add(message); 26 | 27 | if (message is TFinalMessage) 28 | Finished.Set(); 29 | 30 | return cancellationThunk(message); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /test/test.utility/SpyMessageSink.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Threading; 4 | using Xunit.Abstractions; 5 | using Xunit.Sdk; 6 | 7 | public class SpyMessageSink : LongLivedMarshalByRefObject, IMessageSink 8 | { 9 | readonly Func cancellationThunk; 10 | 11 | public SpyMessageSink(Func cancellationThunk = null) 12 | { 13 | this.cancellationThunk = cancellationThunk ?? (msg => true); 14 | } 15 | 16 | public ManualResetEvent Finished = new ManualResetEvent(initialState: false); 17 | 18 | public List Messages = new List(); 19 | 20 | /// 21 | public void Dispose() 22 | { 23 | Finished.Dispose(); 24 | } 25 | 26 | public bool OnMessage(IMessageSinkMessage message) 27 | { 28 | Messages.Add(message); 29 | 30 | if (message is TFinalMessage) 31 | Finished.Set(); 32 | 33 | return cancellationThunk(message); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /test/test.utility/TempFile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | public class TempFile : IDisposable 5 | { 6 | public TempFile() 7 | : this(Path.GetTempFileName()) { } 8 | 9 | public TempFile(string fileName) 10 | { 11 | FileName = Path.GetFullPath(Path.Combine(Path.GetTempPath(), fileName)); 12 | File.WriteAllText(FileName, ""); 13 | } 14 | 15 | public string FileName { get; private set; } 16 | 17 | public void Dispose() 18 | { 19 | File.Delete(FileName); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /test/test.utility/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /test/test.xunit.assert/Asserts/Sdk/Exceptions/XunitExceptionTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit; 3 | using Xunit.Sdk; 4 | 5 | public class XunitExceptionTests 6 | { 7 | [Fact] 8 | public void PreservesUserMessage() 9 | { 10 | var ex = new XunitException("UserMessage"); 11 | 12 | Assert.Equal("UserMessage", ex.UserMessage); 13 | } 14 | 15 | [Fact] 16 | public void UserMessageIsTheMessage() 17 | { 18 | var ex = new XunitException("UserMessage"); 19 | 20 | Assert.Equal(ex.UserMessage, ex.Message); 21 | } 22 | } -------------------------------------------------------------------------------- /test/test.xunit.assert/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /test/test.xunit.console/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /test/test.xunit.execution/Sdk/SpyMessageSink.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using NSubstitute; 3 | using Xunit.Abstractions; 4 | 5 | namespace Xunit.Sdk 6 | { 7 | public static class SpyMessageSink 8 | { 9 | public static IMessageSink Create(List messages = null, bool returnResult = true) 10 | { 11 | var result = Substitute.For(); 12 | 13 | result.OnMessage(null).ReturnsForAnyArgs( 14 | callInfo => 15 | { 16 | if (messages != null) 17 | messages.Add((IMessageSinkMessage)callInfo[0]); 18 | 19 | return returnResult; 20 | }); 21 | 22 | return result; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /test/test.xunit.execution/Sdk/SynchronousMessageBusTests.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using NSubstitute; 3 | using Xunit; 4 | using Xunit.Abstractions; 5 | using Xunit.Sdk; 6 | 7 | public class SynchronousMessageBusTests 8 | { 9 | [Fact] 10 | public void MessagesAreDispatchedImmediatelyFromBus() 11 | { 12 | var msg1 = Substitute.For(); 13 | var dispatchedMessages = new List(); 14 | using (var bus = new SynchronousMessageBus(SpyMessageSink.Create(dispatchedMessages))) 15 | { 16 | Assert.True(bus.QueueMessage(msg1)); 17 | } 18 | 19 | Assert.Collection(dispatchedMessages, message => Assert.Same(msg1, message)); 20 | } 21 | 22 | [Fact] 23 | public void BusShouldReportShutdownWhenMessageSinkReturnsFalse() 24 | { 25 | using (var bus = new SynchronousMessageBus(SpyMessageSink.Create(returnResult: false))) 26 | { 27 | Assert.False(bus.QueueMessage(Substitute.For())); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /test/test.xunit.execution/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /test/test.xunit.runner.msbuild/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /test/test.xunit.runner.tdnet/Extensions/TestResultMessageExtensionsTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TestDriven.Framework; 3 | using Xunit; 4 | using Xunit.Runner.TdNet; 5 | 6 | public class TestResultMessageExtensionsTests 7 | { 8 | [Fact] 9 | public void ConvertsDataFromXunitToTdNetFormat() 10 | { 11 | var message = Mocks.TestResult("ConvertsDataFromXunitToTdNetFormat", "Display Name", 123.45M); 12 | 13 | var result = message.ToTdNetTestResult(TestState.Ignored); 14 | 15 | Assert.Same(message.TestCase.GetClass(), result.FixtureType); 16 | Assert.Same(message.TestCase.GetMethod(), result.Method); 17 | Assert.Equal("Display Name", result.Name); 18 | Assert.Equal(TimeSpan.FromTicks(1234500), result.TimeSpan); 19 | Assert.Equal(1, result.TotalTests); 20 | } 21 | } -------------------------------------------------------------------------------- /test/test.xunit.runner.tdnet/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /test/test.xunit.runner.utility/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /test/test.xunit.runner.visualstudio.testadapter/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /test/test.xunit1/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /test/test.xunit1/utility/AcceptanceTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Xunit.Sdk; 5 | 6 | namespace TestUtility 7 | { 8 | public class AcceptanceTest 9 | { 10 | protected IEnumerable RunClass(Type typeUnderTest) 11 | { 12 | ITestClassCommand testClassCommand = new TestClassCommand(typeUnderTest); 13 | 14 | ClassResult classResult = TestClassCommandRunner.Execute(testClassCommand, testClassCommand.EnumerateTestMethods().ToList(), 15 | startCallback: null, resultCallback: null); 16 | 17 | return classResult.Results.OfType(); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /test/test.xunit1/utility/SerializationUtility.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Runtime.Serialization.Formatters.Binary; 3 | using Xunit; 4 | 5 | public static class SerializationUtility 6 | { 7 | public static T SerializeAndDeserialize(T obj) 8 | { 9 | Assert.NotNull(obj); 10 | 11 | using (var memoryStream = new MemoryStream()) 12 | { 13 | var formatter = new BinaryFormatter(); 14 | 15 | formatter.Serialize(memoryStream, obj); 16 | memoryStream.Seek(0, SeekOrigin.Begin); 17 | object deserialized = formatter.Deserialize(memoryStream); 18 | 19 | Assert.NotNull(deserialized); 20 | return Assert.IsType(deserialized); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test/test.xunit1/utility/StubTransformer.cs: -------------------------------------------------------------------------------- 1 | using Xunit; 2 | 3 | public class StubTransformer : IResultXmlTransform 4 | { 5 | public bool Transform__Called; 6 | public string Transform_Xml; 7 | 8 | public string OutputFilename 9 | { 10 | get { return "filename"; } 11 | } 12 | 13 | public void Transform(string xml) 14 | { 15 | Transform__Called = true; 16 | Transform_Xml = xml; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/test.xunit1/utility/TestTimingAttribute.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Reflection; 3 | using Xunit; 4 | 5 | namespace TestUtility 6 | { 7 | public class TestTimingAttribute : BeforeAfterTestAttribute 8 | { 9 | Stopwatch sw = new Stopwatch(); 10 | 11 | public override void Before(MethodInfo methodUnderTest) 12 | { 13 | sw.Start(); 14 | } 15 | 16 | public override void After(MethodInfo methodUnderTest) 17 | { 18 | sw.Stop(); 19 | Trace.WriteLine(string.Format("Time spent in execution: {0}ms", sw.ElapsedMilliseconds)); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/test.xunit1/xunit.extensions/DataTheories/AcceptanceTests/AcceptanceTestData.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamarin/xunit/ddd38e486e722ac3ded0435068f8e33f1d4f87d1/test/test.xunit1/xunit.extensions/DataTheories/AcceptanceTests/AcceptanceTestData.xls -------------------------------------------------------------------------------- /test/test.xunit1/xunit.extensions/DataTheories/AcceptanceTests/PropertyDataAcceptanceTests.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using TestUtility; 4 | using Xunit; 5 | using Xunit.Extensions; 6 | using Xunit.Sdk; 7 | 8 | namespace Xunit1.Extensions 9 | { 10 | public class PropertyDataAcceptanceTests : AcceptanceTest 11 | { 12 | [Fact] 13 | public void PropertyDataTest() 14 | { 15 | MethodResult result = RunClass(typeof(PropertyDataTestClass)).Single(); 16 | 17 | Assert.IsType(result); 18 | Assert.Equal(@"Xunit1.Extensions.PropertyDataAcceptanceTests+PropertyDataTestClass.PassingTestData(foo: 1, bar: ""hello world"", baz: 2.3)", result.DisplayName); 19 | } 20 | 21 | class PropertyDataTestClass 22 | { 23 | public static IEnumerable MyTestData 24 | { 25 | get { yield return new object[] { 1, "hello world", 2.3 }; } 26 | } 27 | 28 | [Theory, PropertyData("MyTestData")] 29 | public void PassingTestData(int foo, string bar, double baz) 30 | { 31 | } 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /test/test.xunit1/xunit.extensions/DataTheories/UnitTestData.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamarin/xunit/ddd38e486e722ac3ded0435068f8e33f1d4f87d1/test/test.xunit1/xunit.extensions/DataTheories/UnitTestData.xls -------------------------------------------------------------------------------- /test/test.xunit1/xunit/AcceptanceTests/ApartmentAcceptanceTests.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using Xunit; 3 | 4 | namespace Xunit1 5 | { 6 | public class ApartmentAcceptanceTests 7 | { 8 | [Fact] 9 | public void TestsRunsInTheSingleThreadedApartment() 10 | { 11 | Assert.Equal(ApartmentState.STA, Thread.CurrentThread.GetApartmentState()); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /test/test.xunit1/xunit/AcceptanceTests/ConfigFileAcceptanceTests.cs: -------------------------------------------------------------------------------- 1 | using System.Xml; 2 | using TestUtility; 3 | using Xunit; 4 | 5 | namespace Xunit1 6 | { 7 | public class ConfigFileAcceptanceTests : AcceptanceTestInNewAppDomain 8 | { 9 | [Fact] 10 | public void LackOfConfigurationFileBugInCLR4() // http://xunit.codeplex.com/workitem/9696 11 | { 12 | string code = @" 13 | using System; 14 | using Xunit; 15 | 16 | public class ConfigurationFileExample 17 | { 18 | [Fact] 19 | public void Test() 20 | { 21 | new Uri(""http://localhost:58080/indexes/categoriesByName?query=CategoryName%3ABeverages&start=0&pageSize=25""); 22 | } 23 | }"; 24 | 25 | XmlNode assemblyNode = Execute(code); 26 | 27 | ResultXmlUtility.AssertResult(assemblyNode, "Pass", "ConfigurationFileExample.Test"); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /test/test.xunit1/xunit/AcceptanceTests/ExecutorAssemblyNodeCallbackAcceptanceTests.cs: -------------------------------------------------------------------------------- 1 | using System.Xml; 2 | using TestUtility; 3 | using Xunit; 4 | 5 | namespace Xunit1 6 | { 7 | public class ExecutorAssemblyNodeCallbackAcceptanceTests : AcceptanceTestInNewAppDomain 8 | { 9 | [Fact] 10 | public void AssemblyFilenameInXmlMatchesOriginallyPassedNameToExecutor() 11 | { 12 | using (MockAssembly mockAssembly = new MockAssembly()) 13 | { 14 | mockAssembly.Compile(""); 15 | XmlNode assemblyNode = mockAssembly.Run(null); 16 | ResultXmlUtility.AssertAttribute(assemblyNode, "name", mockAssembly.FileName); 17 | } 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /test/test.xunit1/xunit/AcceptanceTests/FactMethodWithArgumentsTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using TestUtility; 4 | using Xunit; 5 | using Xunit.Sdk; 6 | 7 | namespace Xunit1 8 | { 9 | public class FactMethodWithArgumentsTests : AcceptanceTest 10 | { 11 | [Fact] 12 | public void FactMethodsCannotHaveArguments() 13 | { 14 | MethodResult result = RunClass(typeof(ClassUnderTest)).Single(); 15 | 16 | FailedResult failedResult = Assert.IsType(result); 17 | Assert.Equal(typeof(InvalidOperationException).FullName, failedResult.ExceptionType); 18 | Assert.Equal("System.InvalidOperationException : Fact method Xunit1.FactMethodWithArgumentsTests+ClassUnderTest.FactWithParameters cannot have parameters", failedResult.Message); 19 | } 20 | 21 | class ClassUnderTest 22 | { 23 | [Fact] 24 | public void FactWithParameters(int x) { } 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /test/test.xunit1/xunit/AcceptanceTests/FailureTimingAcceptanceTests.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Threading; 3 | using TestUtility; 4 | using Xunit; 5 | using Xunit.Sdk; 6 | 7 | namespace Xunit1 8 | { 9 | public class FailureTimingAcceptanceTests : AcceptanceTest 10 | { 11 | [Fact] 12 | public void TimingForFailedTestShouldReflectActualRunTime() 13 | { 14 | MethodResult result = RunClass(typeof(ClassUnderTest)).Single(); 15 | 16 | Assert.IsType(result); 17 | Assert.NotEqual(0.0, result.ExecutionTime); 18 | } 19 | 20 | class ClassUnderTest 21 | { 22 | [Fact] 23 | public void TwoNumbersAreNotEqual() 24 | { 25 | Thread.Sleep(100); 26 | Assert.Equal(2, 3); 27 | } 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /test/test.xunit1/xunit/AcceptanceTests/SkipAcceptanceTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using TestUtility; 4 | using Xunit; 5 | using Xunit.Sdk; 6 | 7 | namespace Xunit1 8 | { 9 | public class SkipAcceptanceTests : AcceptanceTest 10 | { 11 | [Fact] 12 | public void TestClassIsNotInstantiatedForSkippedTests() 13 | { 14 | MethodResult result = RunClass(typeof(ClassUnderTest)).Single(); 15 | 16 | // If we ran the constructor, we would get a failure instead of a skip. 17 | Assert.IsType(result); 18 | } 19 | 20 | class ClassUnderTest 21 | { 22 | public ClassUnderTest() 23 | { 24 | throw new Exception("Should not reach me!"); 25 | } 26 | 27 | [Fact(Skip = "the reason")] 28 | public void TestThatShouldBeSkipped() 29 | { 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /test/test.xunit1/xunit/AcceptanceTests/TestTimeoutTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Threading; 4 | using TestUtility; 5 | using Xunit; 6 | using Xunit.Sdk; 7 | 8 | namespace Xunit1 9 | { 10 | public class TestTimeoutFixture : AcceptanceTest 11 | { 12 | [Fact] 13 | public void TestHasTimeoutAndExceeds() 14 | { 15 | MethodResult result = RunClass(typeof(ClassUnderTest)).Single(); 16 | 17 | FailedResult failedResult = Assert.IsType(result); 18 | Assert.InRange(failedResult.ExecutionTime, 0.049, 0.051); 19 | Assert.Equal("Test execution time exceeded: 50ms", failedResult.Message); 20 | } 21 | 22 | class ClassUnderTest 23 | { 24 | [Fact(Timeout = 50)] 25 | public void TestShouldTimeout() 26 | { 27 | Thread.Sleep(120); 28 | Assert.Equal(2, 2); 29 | } 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /test/test.xunit1/xunit/DoesNotThrowTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit; 3 | using Xunit.Sdk; 4 | 5 | namespace Xunit1 6 | { 7 | public class DoesNotThrowTests 8 | { 9 | [Fact] 10 | public void CorrectExceptionType() 11 | { 12 | DoesNotThrowException ex = 13 | Assert.Throws( 14 | () => Assert.DoesNotThrow( 15 | () => { throw new NotImplementedException("Exception Message"); })); 16 | 17 | Assert.Equal("Assert.DoesNotThrow() failure", ex.UserMessage); 18 | Assert.Equal("(No exception)", ex.Expected); 19 | Assert.Equal("System.NotImplementedException: Exception Message", ex.Actual); 20 | } 21 | 22 | [Fact] 23 | public void PassingTest() 24 | { 25 | Assert.DoesNotThrow(() => { }); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /test/test.xunit1/xunit/FalseTests.cs: -------------------------------------------------------------------------------- 1 | using Xunit; 2 | using Xunit.Sdk; 3 | 4 | namespace Xunit1 5 | { 6 | public class FalseTests 7 | { 8 | [Fact] 9 | public void AssertFalse() 10 | { 11 | Assert.False(false); 12 | } 13 | 14 | [Fact] 15 | public void AssertFalseThrowsExceptionWhenTrue() 16 | { 17 | try 18 | { 19 | Assert.False(true); 20 | } 21 | catch (AssertException exception) 22 | { 23 | Assert.Equal("Assert.False() Failure", exception.UserMessage); 24 | } 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /test/test.xunit1/xunit/IsNotTypeTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit; 3 | using Xunit.Sdk; 4 | 5 | namespace Xunit1 6 | { 7 | public class IsNotTypeTests 8 | { 9 | [Fact] 10 | public void IsNotType() 11 | { 12 | InvalidCastException expected = new InvalidCastException(); 13 | Assert.IsNotType(typeof(Exception), expected); 14 | Assert.IsNotType(expected); 15 | } 16 | 17 | [Fact] 18 | public void IsNotTypeThrowsExceptionWhenWrongType() 19 | { 20 | AssertException exception = 21 | Assert.Throws(() => Assert.IsNotType(new InvalidCastException())); 22 | 23 | Assert.Equal("Assert.IsNotType() Failure", exception.UserMessage); 24 | } 25 | 26 | [Fact] 27 | public void NullObjectDoesNotThrow() 28 | { 29 | Assert.DoesNotThrow(() => Assert.IsNotType(null)); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /test/test.xunit1/xunit/NotEmptyTests.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Xunit; 3 | using Xunit.Sdk; 4 | 5 | namespace Xunit1 6 | { 7 | public class NotEmptyTests 8 | { 9 | [Fact] 10 | public void ContainerIsEmpty() 11 | { 12 | List list = new List(); 13 | 14 | NotEmptyException ex = 15 | Assert.Throws(() => Assert.NotEmpty(list)); 16 | 17 | Assert.Equal("Assert.NotEmpty() failure", ex.Message); 18 | } 19 | 20 | [Fact] 21 | public void ContainerIsNotEmpty() 22 | { 23 | List list = new List(); 24 | list.Add(42); 25 | 26 | Assert.NotEmpty(list); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /test/test.xunit1/xunit/NotNullTests.cs: -------------------------------------------------------------------------------- 1 | using Xunit; 2 | using Xunit.Sdk; 3 | 4 | namespace Xunit1 5 | { 6 | public class NotNullTests 7 | { 8 | [Fact] 9 | public void NotNull() 10 | { 11 | Assert.NotNull(new object()); 12 | } 13 | 14 | [Fact] 15 | public void NotNullThrowsException() 16 | { 17 | Assert.Throws(() => Assert.NotNull(null)); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /test/test.xunit1/xunit/NotSameTests.cs: -------------------------------------------------------------------------------- 1 | using Xunit; 2 | using Xunit.Sdk; 3 | 4 | namespace Xunit1 5 | { 6 | public class NotSameTests 7 | { 8 | [Fact] 9 | public void NotSameFailsWith() 10 | { 11 | object actual = new object(); 12 | 13 | try 14 | { 15 | Assert.NotSame(actual, actual); 16 | } 17 | catch (NotSameException exception) 18 | { 19 | Assert.Equal("Assert.NotSame() Failure", exception.UserMessage); 20 | } 21 | } 22 | 23 | [Fact] 24 | public void ValuesAreNotTheSame() 25 | { 26 | Assert.NotSame("bob", "jim"); 27 | } 28 | 29 | [Fact] 30 | public void ValuesAreTheSame() 31 | { 32 | string jim = "jim"; 33 | 34 | Assert.Throws(() => Assert.NotSame(jim, jim)); 35 | } 36 | 37 | [Fact] 38 | public void ValueTypesGetBoxedTwice() 39 | { 40 | int index = 0; 41 | 42 | Assert.NotSame(index, index); 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /test/test.xunit1/xunit/NullTests.cs: -------------------------------------------------------------------------------- 1 | using Xunit; 2 | using Xunit.Sdk; 3 | 4 | namespace Xunit1 5 | { 6 | public class NullTests 7 | { 8 | [Fact] 9 | public void Null() 10 | { 11 | Assert.Null(null); 12 | } 13 | 14 | [Fact] 15 | public void NullThrowsExceptionWhenNotNull() 16 | { 17 | try 18 | { 19 | Assert.Null(new object()); 20 | } 21 | catch (AssertException exception) 22 | { 23 | Assert.Equal("Assert.Null() Failure", exception.UserMessage); 24 | } 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /test/test.xunit1/xunit/Sdk/Commands/TestCommands/SkipCommandTests.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using Xunit; 3 | using Xunit.Sdk; 4 | 5 | namespace Xunit1 6 | { 7 | public class SkipCommandTests 8 | { 9 | [Fact] 10 | public void SkipReturnSkipResult() 11 | { 12 | MethodInfo method = typeof(SpyStub).GetMethod("Skip"); 13 | SkipCommand command = new SkipCommand(Reflector.Wrap(method), null, "reason"); 14 | 15 | MethodResult result = command.Execute(new SpyStub()); 16 | 17 | SkipResult skipResult = Assert.IsType(result); 18 | Assert.Equal("reason", skipResult.Reason); 19 | } 20 | 21 | internal class SpyStub : FixtureSpy 22 | { 23 | public void Skip() { } 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /test/test.xunit1/xunit/Sdk/Exceptions/DoesNotThrowExceptionTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | using Xunit; 4 | using Xunit.Sdk; 5 | 6 | namespace Xunit1 7 | { 8 | public class DoesNotThrowExceptionTests 9 | { 10 | [Fact] 11 | public void SerializesCustomProperties() 12 | { 13 | var originalException = new TestableDoesNotThrowException("Stack Trace"); 14 | 15 | var deserializedException = SerializationUtility.SerializeAndDeserialize(originalException); 16 | 17 | Assert.Equal(originalException.StackTrace, deserializedException.StackTrace); 18 | } 19 | 20 | [Serializable] 21 | class TestableDoesNotThrowException : DoesNotThrowException 22 | { 23 | public TestableDoesNotThrowException(string stackTrace) 24 | : base(stackTrace) { } 25 | 26 | protected TestableDoesNotThrowException(SerializationInfo info, StreamingContext context) 27 | : base(info, context) { } 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /test/test.xunit1/xunit/Sdk/Exceptions/InRangeExceptionTests.cs: -------------------------------------------------------------------------------- 1 | using Xunit; 2 | using Xunit.Sdk; 3 | 4 | namespace Xunit1 5 | { 6 | public class InRangeExceptionTests 7 | { 8 | [Fact] 9 | public void SerializesCustomProperties() 10 | { 11 | var originalException = new InRangeException("Actual", "Low", "High"); 12 | 13 | var deserializedException = SerializationUtility.SerializeAndDeserialize(originalException); 14 | 15 | Assert.Equal(originalException.Actual, deserializedException.Actual); 16 | Assert.Equal(originalException.Low, deserializedException.Low); 17 | Assert.Equal(originalException.High, deserializedException.High); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /test/test.xunit1/xunit/Sdk/Exceptions/NotInRangeExceptionTests.cs: -------------------------------------------------------------------------------- 1 | using Xunit; 2 | using Xunit.Sdk; 3 | 4 | namespace Xunit1 5 | { 6 | public class NotInRangeExceptionTests 7 | { 8 | [Fact] 9 | public void SerializesCustomProperties() 10 | { 11 | var originalException = new NotInRangeException("Actual", "Low", "High"); 12 | 13 | var deserializedException = SerializationUtility.SerializeAndDeserialize(originalException); 14 | 15 | Assert.Equal(originalException.Actual, deserializedException.Actual); 16 | Assert.Equal(originalException.Low, deserializedException.Low); 17 | Assert.Equal(originalException.High, deserializedException.High); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /test/test.xunit1/xunit/Sdk/Exceptions/ThrowsExceptionTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | using Xunit; 4 | using Xunit.Sdk; 5 | 6 | namespace Xunit1 7 | { 8 | public class ThrowsExceptionTests 9 | { 10 | [Fact] 11 | public void SerializesCustomProperties() 12 | { 13 | var originalException = new TestableThrowsException("Stack Trace"); 14 | 15 | var deserializedException = SerializationUtility.SerializeAndDeserialize(originalException); 16 | 17 | Assert.Equal(originalException.StackTrace, deserializedException.StackTrace); 18 | } 19 | 20 | [Serializable] 21 | class TestableThrowsException : ThrowsException 22 | { 23 | public TestableThrowsException(string stackTrace) 24 | : base(typeof(object), "Actual", "Actual Message", stackTrace) { } 25 | 26 | protected TestableThrowsException(SerializationInfo info, StreamingContext context) 27 | : base(info, context) { } 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /test/test.xunit1/xunit/Sdk/Results/PassedResultTests.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Xml; 3 | using Xunit; 4 | using Xunit.Sdk; 5 | 6 | namespace Xunit1 7 | { 8 | public class PassedResultTests 9 | { 10 | [Fact] 11 | public void ToXml() 12 | { 13 | XmlDocument doc = new XmlDocument(); 14 | doc.LoadXml(""); 15 | XmlNode parentNode = doc.ChildNodes[0]; 16 | MethodInfo method = typeof(StubClass).GetMethod("StubMethod"); 17 | PassedResult passedResult = new PassedResult(Reflector.Wrap(method), null); 18 | passedResult.ExecutionTime = 1.2; 19 | 20 | XmlNode resultNode = passedResult.ToXml(parentNode); 21 | 22 | Assert.Equal("Pass", resultNode.Attributes["result"].Value); 23 | Assert.Equal("1.200", resultNode.Attributes["time"].Value); 24 | Assert.Null(resultNode.SelectSingleNode("failure")); 25 | Assert.Null(resultNode.SelectSingleNode("reason")); 26 | } 27 | 28 | internal class StubClass 29 | { 30 | public void StubMethod() { } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /test/test.xunit1/xunit/Sdk/Results/SkipResultTests.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Xml; 3 | using Xunit; 4 | using Xunit.Sdk; 5 | 6 | namespace Xunit1 7 | { 8 | public class SkipResultTests 9 | { 10 | [Fact] 11 | public void ToXml() 12 | { 13 | XmlDocument doc = new XmlDocument(); 14 | doc.LoadXml(""); 15 | XmlNode parentNode = doc.ChildNodes[0]; 16 | MethodInfo method = typeof(StubClass).GetMethod("StubMethod"); 17 | SkipResult skipResult = new SkipResult(Reflector.Wrap(method), null, "the reason"); 18 | 19 | XmlNode resultNode = skipResult.ToXml(parentNode); 20 | 21 | Assert.Equal("Skip", resultNode.Attributes["result"].Value); 22 | Assert.Null(resultNode.Attributes["success"]); 23 | Assert.Null(resultNode.Attributes["time"]); 24 | Assert.Null(resultNode.SelectSingleNode("failure")); 25 | Assert.Equal("the reason", resultNode.SelectSingleNode("reason/message").InnerText); 26 | } 27 | 28 | internal class StubClass 29 | { 30 | public void StubMethod() { } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /test/test.xunit1/xunit/SerializationTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Runtime.Serialization.Formatters.Binary; 4 | using Xunit; 5 | 6 | namespace Xunit1 7 | { 8 | public class SerializationTests 9 | { 10 | [Serializable] 11 | class SerializableObject { } 12 | 13 | [Fact] 14 | void CanSerializeAndDeserializeObjectsInATest() 15 | { 16 | BinaryFormatter bf = new BinaryFormatter(); 17 | 18 | using (Stream ms = new MemoryStream()) 19 | { 20 | bf.Serialize(ms, new SerializableObject()); 21 | ms.Position = 0; 22 | object o = bf.Deserialize(ms); 23 | 24 | Assert.IsType(typeof(SerializableObject), o); 25 | Assert.DoesNotThrow(delegate { SerializableObject o2 = (SerializableObject)o; }); 26 | } 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /test/test.xunit1/xunit/Stubs/StubTestCommand.cs: -------------------------------------------------------------------------------- 1 | using System.Xml; 2 | using Xunit.Sdk; 3 | 4 | public class StubTestCommand : ITestCommand 5 | { 6 | public bool Execute__Called; 7 | public MethodResult Execute__Result; 8 | public object Execute_TestClass; 9 | public string Name__Result; 10 | public bool ShouldCreateInstance__Result = true; 11 | public int Timeout__Result; 12 | public XmlNode ToStartXml__Result; 13 | 14 | public string DisplayName 15 | { 16 | get { return Name__Result; } 17 | } 18 | 19 | public bool ShouldCreateInstance 20 | { 21 | get { return ShouldCreateInstance__Result; } 22 | } 23 | 24 | public int Timeout 25 | { 26 | get { return Timeout__Result; } 27 | } 28 | 29 | public MethodResult Execute(object testClass) 30 | { 31 | Execute__Called = true; 32 | Execute_TestClass = testClass; 33 | 34 | return Execute__Result; 35 | } 36 | 37 | public XmlNode ToStartXml() 38 | { 39 | return ToStartXml__Result; 40 | } 41 | } -------------------------------------------------------------------------------- /test/test.xunit1/xunit/TrueTests.cs: -------------------------------------------------------------------------------- 1 | using Xunit; 2 | using Xunit.Sdk; 3 | 4 | namespace Xunit1 5 | { 6 | public class TrueTests 7 | { 8 | [Fact] 9 | public void AssertTrue() 10 | { 11 | Assert.True(true); 12 | } 13 | 14 | [Fact] 15 | public void AssertTrueThrowsExceptionWhenFalse() 16 | { 17 | TrueException exception = Assert.Throws(() => Assert.True(false)); 18 | 19 | Assert.Equal("Assert.True() Failure", exception.UserMessage); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /tools/TestDriven.Framework.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamarin/xunit/ddd38e486e722ac3ded0435068f8e33f1d4f87d1/tools/TestDriven.Framework.dll -------------------------------------------------------------------------------- /tools/xunit.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $(MSBuildThisFileDirectory) 5 | 6 | 7 | Release 8 | 9 | 10 | ..\..\src\xunit.empty.ruleset 11 | 12 | --------------------------------------------------------------------------------