public static async void SkipsDataAttributesWithSkipReason() { var messageBus = new SpyMessageBus(); var runner = TestableXunitDelayEnumeratedTheoryTestCaseRunner.Create <ClassUnderTest>("TestWithSomeDataSkipped", messageBus, "Display Name"); var summary = await runner.RunAsync(); Assert.NotEqual(0m, summary.Time); Assert.Equal(6, summary.Total); Assert.Equal(3, summary.Skipped); Assert.Equal(2, summary.Failed); Assert.Collection( messageBus.Messages.OfType <_TestPassed>().Select(p => messageBus.Messages.OfType <_TestStarting>().Single(s => s.TestUniqueID == p.TestUniqueID).TestDisplayName).OrderBy(x => x), displayName => Assert.Equal($"Display Name(x: 1, y: {2.1:G17}, z: \"not skipped\")", displayName) ); Assert.Collection( messageBus.Messages.OfType <_TestFailed>().Select(p => messageBus.Messages.OfType <_TestStarting>().Single(s => s.TestUniqueID == p.TestUniqueID).TestDisplayName).OrderBy(x => x), displayName => Assert.Equal("Display Name(x: 0, y: 0, z: \"also not skipped\")", displayName), displayName => Assert.Equal("Display Name(x: 0, y: 0, z: \"SomeData2 not skipped\")", displayName) ); Assert.Collection( messageBus.Messages.OfType <_TestSkipped>().Select(p => messageBus.Messages.OfType <_TestStarting>().Single(s => s.TestUniqueID == p.TestUniqueID).TestDisplayName).OrderBy(x => x), displayName => Assert.Equal("Display Name(x: 0, y: 0, z: \"World!\")", displayName), displayName => Assert.Equal($"Display Name(x: 18, y: {36.48:G17}, z: \"SomeData2 skipped\")", displayName), displayName => Assert.Equal($"Display Name(x: 42, y: {21.12:G17}, z: \"Hello\")", displayName) ); }
public static async void DisposesArguments() { ClassUnderTest.DataWasDisposed = false; var messageBus = new SpyMessageBus(); var runner = TestableXunitDelayEnumeratedTheoryTestCaseRunner.Create <ClassUnderTest>("TestWithDisposableData", messageBus); await runner.RunAsync(); Assert.True(ClassUnderTest.DataWasDisposed); }
public async void ThrowingToString() { var messageBus = new SpyMessageBus(); var runner = TestableXunitDelayEnumeratedTheoryTestCaseRunner.Create <ClassWithThrowingToString>("Test", messageBus, "Display Name"); await runner.RunAsync(); var passed = messageBus.Messages.OfType <_TestPassed>().Single(); var passedStarting = messageBus.Messages.OfType <_TestStarting>().Where(ts => ts.TestUniqueID == passed.TestUniqueID).Single(); Assert.Equal("Display Name(c: TargetInvocationException was thrown formatting an object of type \"XunitDelayEnumeratedTheoryTestCaseRunnerTests+ClassWithThrowingToString\")", passedStarting.TestDisplayName); }
public async void ThrowingEnumerator() { var messageBus = new SpyMessageBus(); var runner = TestableXunitDelayEnumeratedTheoryTestCaseRunner.Create <ClassWithThrowingEnumerator>("Test", messageBus, "Display Name"); var summary = await runner.RunAsync(); var passed = messageBus.Messages.OfType <_TestPassed>().Single(); var passedStarting = messageBus.Messages.OfType <_TestStarting>().Where(ts => ts.TestUniqueID == passed.TestUniqueID).Single(); Assert.Equal("Display Name(c: [ClassWithThrowingEnumerator { }])", passedStarting.TestDisplayName); }
public static async void DiscovererWhichThrowsReturnsASingleFailedTest() { var messageBus = new SpyMessageBus(); var runner = TestableXunitDelayEnumeratedTheoryTestCaseRunner.Create <ClassUnderTest>("TestWithThrowingData", messageBus, "Display Name"); var summary = await runner.RunAsync(); Assert.Equal(0m, summary.Time); Assert.Equal(1, summary.Total); Assert.Equal(1, summary.Failed); var failed = messageBus.Messages.OfType <_TestFailed>().Single(); var failedStarting = messageBus.Messages.OfType <_TestStarting>().Single(ts => ts.TestUniqueID == failed.TestUniqueID); Assert.Equal("Display Name", failedStarting.TestDisplayName); Assert.Equal("System.DivideByZeroException", failed.ExceptionTypes.Single()); Assert.Equal("Attempted to divide by zero.", failed.Messages.Single()); Assert.Contains("ClassUnderTest.get_ThrowingData", failed.StackTraces.Single()); }
public static async void EnumeratesDataAtRuntimeAndExecutesOneTestForEachDataRow() { var messageBus = new SpyMessageBus(); var runner = TestableXunitDelayEnumeratedTheoryTestCaseRunner.Create <ClassUnderTest>("TestWithData", messageBus, "Display Name"); var summary = await runner.RunAsync(); Assert.NotEqual(0m, summary.Time); Assert.Equal(2, summary.Total); Assert.Equal(1, summary.Failed); var passed = messageBus.Messages.OfType <_TestPassed>().Single(); var passedStarting = messageBus.Messages.OfType <_TestStarting>().Single(ts => ts.TestUniqueID == passed.TestUniqueID); Assert.Equal($"Display Name(x: 42, y: {21.12:G17}, z: \"Hello\")", passedStarting.TestDisplayName); var failed = messageBus.Messages.OfType <_TestFailed>().Single(); var failedStarting = messageBus.Messages.OfType <_TestStarting>().Single(ts => ts.TestUniqueID == failed.TestUniqueID); Assert.Equal("Display Name(x: 0, y: 0, z: \"World!\")", failedStarting.TestDisplayName); }
public static async void OnlySkipsDataRowsWithSkipReason() { var messageBus = new SpyMessageBus(); var runner = TestableXunitDelayEnumeratedTheoryTestCaseRunner.Create <ClassUnderTest>("TestWithSomeDataSkipped", messageBus, "Display Name"); var summary = await runner.RunAsync(); Assert.NotEqual(0m, summary.Time); Assert.Equal(4, summary.Total); Assert.Equal(2, summary.Skipped); Assert.Equal(1, summary.Failed); var passed = messageBus.Messages.OfType <_TestPassed>().Single(); var passedStarting = messageBus.Messages.OfType <_TestStarting>().Single(ts => ts.TestUniqueID == passed.TestUniqueID); Assert.Equal($"Display Name(x: 1, y: {2.1}, z: \"not skipped\")", passedStarting.TestDisplayName); var failed = messageBus.Messages.OfType <_TestFailed>().Single(); var failedStarting = messageBus.Messages.OfType <_TestStarting>().Single(ts => ts.TestUniqueID == failed.TestUniqueID); Assert.Equal("Display Name(x: 0, y: 0, z: \"also not skipped\")", failedStarting.TestDisplayName); Assert.Contains(messageBus.Messages.OfType <_TestSkipped>(), skipped => messageBus.Messages.OfType <_TestStarting>().Single(s => s.TestUniqueID == skipped.TestUniqueID).TestDisplayName == $"Display Name(x: 42, y: {21.12}, z: \"Hello\")"); Assert.Contains(messageBus.Messages.OfType <_TestSkipped>(), skipped => messageBus.Messages.OfType <_TestStarting>().Single(s => s.TestUniqueID == skipped.TestUniqueID).TestDisplayName == "Display Name(x: 0, y: 0, z: \"World!\")"); }