예제 #1
0
        public void DiscovererWhichThrowsReturnsASingleFailedTest()
        {
            var testCase = TestableXunitTheoryTestCase.Create(typeof(ClassUnderTest), "TestWithThrowingData");
            var bus      = new SpyMessageBus <ITestCaseFinished>();

            testCase.Run(bus);
            bus.Finished.WaitOne();

            var resultMessages = bus.Messages.OfType <ITestResultMessage>();
            var failed         = (ITestFailed)Assert.Single(resultMessages);

            Assert.Equal("XunitTheoryTestCaseTests+Run+ClassUnderTest.TestWithThrowingData", failed.TestDisplayName);
            Assert.Equal("System.DivideByZeroException : Attempted to divide by zero.", failed.Message);
            Assert.Contains("XunitTheoryTestCaseTests.Run.ClassUnderTest.get_ThrowingData()", failed.StackTrace);
        }
예제 #2
0
        public void EnumeratesDataAtRuntimeAndExecutesOneTestForEachDataRow()
        {
            var testCase = TestableXunitTheoryTestCase.Create(typeof(ClassUnderTest), "TestWithData");
            var bus      = new SpyMessageBus <ITestCaseFinished>();

            testCase.Run(bus);
            bus.Finished.WaitOne();

            var resultMessages = bus.Messages.OfType <ITestResultMessage>();

            Assert.Equal(2, resultMessages.Count());
            var passed = (ITestPassed)Assert.Single(resultMessages, msg => msg is ITestPassed);

            Assert.Equal("XunitTheoryTestCaseTests+Run+ClassUnderTest.TestWithData(x: 42, y: 21.12, z: \"Hello\")", passed.TestDisplayName);
            var failed = (ITestFailed)Assert.Single(resultMessages, msg => msg is ITestFailed);

            Assert.Equal("XunitTheoryTestCaseTests+Run+ClassUnderTest.TestWithData(x: 0, y: 0, z: \"World!\")", failed.TestDisplayName);
        }