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 void Start_test_fixture_with_empty_list()
        {
            testFixture = new Core.TestFixture();

            var tesetFromCollection = testFixture.Get(0);

            Assert.Null(tesetFromCollection);
        }
Beispiel #4
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);
        }
Beispiel #5
0
        public void Result_not_run_if_fixture_not_run()
        {
            //Arrange
            testFixture = new Core.TestFixture();

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

            //Assert
            Assert.Equal(TestResult.NotRun, report.Result);
        }
Beispiel #6
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 #7
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);
        }