Пример #1
0
        private static bool ExecuteIfExists(TestRunner runner, MethodInfo m)
        {
            if (m != null)
            {
                Write(string.Format("  Executing: {0}", m.Name), ConsoleColor.DarkGray);
                if (!runner.Execute(m))
                {
                    WriteLine("  Failed", ConsoleColor.Red);
                    return false;
                }

                Console.WriteLine();
            }

            return true;
        }
Пример #2
0
 private static void ExecuteTest(ref int apassed, ref int afailed, TestRunner runner, ref int cpassed, ref int cfailed, System.Reflection.MethodInfo m)
 {
     Console.Write("  {0}: ", m.Name);
     var result = runner.Execute(m);
     if (result)
     {
         WriteLine("Passed", ConsoleColor.Green);
         cpassed++;
         apassed++;
     }
     else
     {
         WriteLine("Failed", ConsoleColor.Red);
         cfailed++;
         afailed++;
     }
 }
Пример #3
0
 public void TestRunnerShouldRunMultipleTestsOnSameInstance()
 {
     var runner = new TestRunner(typeof(TestDemoClass));
     runner.Execute(typeof(TestDemoClass).GetMethod("MultipleFirst"));
     var result = runner.Execute(typeof(TestDemoClass).GetMethod("MultipleSecond"));
     Assert.IsTrue(result);
 }
Пример #4
0
        public void TestRunnerExecuteClassInitializeOnStatic()
        {
            object instance = new TestDemoClass();
            var runner = new TestRunner(instance);
            bool result = runner.Execute(typeof(TestDemoClass).GetMethod("ClassInit"));

            Assert.IsTrue(result);
            Assert.IsTrue(TestDemoClass.IsInitialized);
        }
Пример #5
0
        public void TestExecuteOfTestMethod()
        {
            var runner = new TestRunner(typeof(TestDemoClass));
            bool result = runner.Execute(typeof(TestDemoClass).GetMethod("MyTestMethod"));

            Assert.IsTrue(result);
        }
Пример #6
0
        public void ExecuteOfMethodThrowingExpectedExceptionShouldReturnTrue()
        {
            var runner = new TestRunner(typeof(TestDemoClass));
            bool result = runner.Execute(typeof(TestDemoClass).GetMethod("ThrowsExpectedException"));

            Assert.IsTrue(result);
        }
Пример #7
0
        public void ExecuteOfFailingTestShouldReturnFalse()
        {
            var runner = new TestRunner(typeof(TestDemoClass));
            bool result = runner.Execute(typeof(TestDemoClass).GetMethod("FailingTest"));

            Assert.IsFalse(result);
        }