Beispiel #1
0
        public void Report_contains_all_tests_reports()
        {
            //Arange
            testFixture = new Core.TestFixture();

            var mockReport = new TestReport();
            var passedTest = new Mock <ITest>();

            passedTest.Setup(test => test.GetReport()).Returns(mockReport);

            var mockReport2 = new TestReport();
            var failedTest  = new Mock <ITest>();

            failedTest.Setup(test => test.GetReport()).Returns(mockReport2);

            testFixture.Add(failedTest.Object);
            testFixture.Add(passedTest.Object);

            //Act
            testFixture.Run();
            var report = testFixture.GetReport();

            //Assert
            Assert.Contains(mockReport, report.SubReports);
            Assert.Contains(mockReport2, report.SubReports);
        }
Beispiel #2
0
        public void Run_all_tests()
        {
            //Arrange
            testFixture = new Core.TestFixture();
            var tests = new Mock <ITest>[]
            {
                new Mock <ITest>(),
                new Mock <ITest>()
            };

            foreach (var test in tests)
            {
                test.Setup(t => t.GetReport()).Returns(new TestReport());

                testFixture.Add(test.Object);
            }

            //Act
            testFixture.Run();

            //Assert
            foreach (var test in tests)
            {
                test.Verify(t => t.Run(), Times.Once());
            }
        }
Beispiel #3
0
        public ITest CreateTests(MethodInfo[] testMethodsInfo, MethodInfo setupInfo)
        {
            if (testMethodsInfo.Length > 1)
            {
                var fixture = new TestFixture();

                var setup = GetAction(setupInfo);

                foreach (var testInfo in testMethodsInfo)
                {
                    var test = GetAction(testInfo);
                    fixture.Add(new TestCase(test, setup));
                }

                return(fixture);
            }

            if (testMethodsInfo.Length > 0)
            {
                var setup = GetAction(setupInfo);

                var test = GetAction(testMethodsInfo[0]);

                return(new TestCase(test, setup));
            }

            throw new InvalidOperationException();
        }
Beispiel #4
0
        public void Whole_fixture_pass_after_all_tests_passed()
        {
            //Arrange
            testFixture = new Core.TestFixture();
            var failedTest      = new Core.TestCase(() => { }, () => { });
            var succsessfulTest = new Core.TestCase(() => { }, () => { });

            testFixture.Add(succsessfulTest);
            testFixture.Add(failedTest);

            //Act
            testFixture.Run();
            var report = testFixture.GetReport();

            //Assert
            Assert.Equal(TestResult.Passed, report.Result);
        }
Beispiel #5
0
        public void Whole_fixture_fails_after_at_least_one_test_fails()
        {
            //Arrange
            testFixture = new Core.TestFixture();
            var failedTest      = new Core.TestCase(() => { }, () => throw new Exception());
            var succsessfulTest = new Core.TestCase(() => { }, () => { });

            testFixture.Add(succsessfulTest);
            testFixture.Add(failedTest);

            //Act
            testFixture.Run();
            var report = testFixture.GetReport();

            //Assert
            Assert.Equal(TestResult.Failed, report.Result);
        }
Beispiel #6
0
        public void Fixture_contains_newly_added_test()
        {
            testFixture = new Core.TestFixture();
            var newTest = new Core.TestCase(() => { }, () => { });

            testFixture.Add(newTest);
            var tesetFromCollection = testFixture.Get(0);

            Assert.Equal(newTest, tesetFromCollection);
        }