Ejemplo n.º 1
0
        public void GivenThereIsTwoTestMethodsInTheSameTestClassAndTwoRunnersThenEachRunnerShouldRunOneOfTheMethods()
        {
            var methodRunner1 = new Mock<IMethodRunner>();
            var methodRunner2 = new Mock<IMethodRunner>();
            var type = new TestAssembly("").AddTestClass("");
            TestMethod method1 = type.AddTestMethod("method1");
            TestMethod method2 = type.AddTestMethod("method2");

            var runner = new Runner()
            {
                MethodRunners = new List<IMethodRunner>
                {
                    methodRunner1.Object, methodRunner2.Object
                },
                Assemblies = new List<TestAssembly>()
                {
                    type.TestAssembly
                },
            };

            var report1 = new SuccessMethodExecutionReport() { Method = method1, ConsoleOutput = "Executed 1" };
            var report2 = new SuccessMethodExecutionReport() { Method = method2, ConsoleOutput = "Executed 2" };
            var reportForRunner1 = new List<MethodExecutionReport> { report1 };
            var reportForRunner2 = new List<MethodExecutionReport> { report2 };
            methodRunner1.Setup(m => m.Invoke(It.Is<IEnumerable<Method>>(e => e.SequenceEqual(new List<Method> { method1 })))).Returns(reportForRunner1);
            methodRunner2.Setup(m => m.Invoke(It.Is<IEnumerable<Method>>(e => e.SequenceEqual(new List<Method> { method2 })))).Returns(reportForRunner2);

            var actualReport = runner.Run();
            Assert.AreEqual(actualReport.Count(), 2);
            Assert.IsTrue(actualReport.Contains(report1));
            Assert.IsTrue(actualReport.Contains(report2));
        }
Ejemplo n.º 2
0
        public void GivenThereIsTwoTestMethodsInTheSameTestClassAndOneRunnerThenItShouldRunTheseMethods()
        {
            var methodRunner = new Mock<IMethodRunner>();
            var type = new TestAssembly("").AddTestClass("");
            TestMethod method1 = type.AddTestMethod("method1");
            TestMethod method2 = type.AddTestMethod("method2");

            var runner = new Runner()
            {
                MethodRunners = new List<IMethodRunner>
                {
                    methodRunner.Object
                },
                Assemblies = new List<TestAssembly>()
                {
                    type.TestAssembly
                },
            };
            runner.Run();
            methodRunner.Verify(m => m.Invoke(It.Is<IEnumerable<Method>>(e => e.SequenceEqual(new List<Method> { method1, method2 }))), Times.Once());

            var report1 = new SuccessMethodExecutionReport() { Method = method1, ConsoleOutput = "Executed 1" };
            var report2 = new SuccessMethodExecutionReport() { Method = method2, ConsoleOutput = "Executed 2" };
            var expectedReport = new List<MethodExecutionReport>
            {
                report1,
                report2
            };
            methodRunner.Setup(m => m.Invoke(It.Is<IEnumerable<Method>>(e => e.SequenceEqual(new List<Method> { method1, method2 })))).Returns(expectedReport);

            var actualReport = runner.Run();
            Assert.AreEqual(actualReport.Count(), 2);
            Assert.IsTrue(actualReport.Contains(report1));
            Assert.IsTrue(actualReport.Contains(report2));
        }