Пример #1
0
        public void RunTestsInAssembly_Failed()
        {
            SimpleTestFramework<JustATest_TestClassAttribute, JustATest_TestMethod_FailedAttribute, JustATest_Exception> simpleTestFramework
                = new SimpleTestFramework<JustATest_TestClassAttribute, JustATest_TestMethod_FailedAttribute, JustATest_Exception>();

            TestAssemblyResults testAssemblyResults = simpleTestFramework.RunTestsInAssembly(Assembly.GetExecutingAssembly());

            Assert.AreEqual(TestResultStatus.Failed, testAssemblyResults.Status);
            Assert.AreEqual(                      1, testAssemblyResults.TestClassResults.Count());

            TestClassResults testClassResults = testAssemblyResults.TestClassResults.Single();
            Assert.AreEqual(TestResultStatus.Failed     , testClassResults.Status);
            Assert.AreEqual("TestOf_SimpleTestFramework", testClassResults.ClassName);
            Assert.AreEqual(                           1, testClassResults.TestMethodResults.Count());

            TestMethodResult testMethodResult = testClassResults.TestMethodResults.Single();
            Assert.AreEqual (TestResultStatus.Failed, testMethodResult.Status);
            Assert.AreEqual ("JustATest_Failed"     , testMethodResult.MethodName);
            Assert.IsNotNull(                         testMethodResult.Exception);
            Assert.IsInstanceOfType(testMethodResult.Exception, typeof(JustATest_Exception));
        }
Пример #2
0
        public void RunTestsInAssembly_Events()
        {
            bool classStarted   = false;
            bool methodStarted  = false;
            bool methodFinished = false;
            bool classFinished  = false;

            SimpleTestFramework<JustATest_TestClassAttribute, JustATest_TestMethod_PassedAttribute, JustATest_Exception> simpleTestFramework
                = new SimpleTestFramework<JustATest_TestClassAttribute, JustATest_TestMethod_PassedAttribute, JustATest_Exception>();

            simpleTestFramework.TestClassStarted   += (sender, eventArgs) => { classStarted   = true; };
            simpleTestFramework.TestMethodStarted  += (sender, eventArgs) => { methodStarted  = true; };
            simpleTestFramework.TestMethodFinished += (sender, eventArgs) => { methodFinished = true; };
            simpleTestFramework.TestClassFinished  += (sender, eventArgs) => { classFinished  = true; };

            simpleTestFramework.RunTestsInAssembly(Assembly.GetExecutingAssembly());

            Assert.IsTrue(classStarted  , "TestClassStarted"   + " was never invoked");
            Assert.IsTrue(methodStarted , "TestMethodStarted"  + " was never invoked");
            Assert.IsTrue(methodFinished, "TestMethodFinished" + " was never invoked");
            Assert.IsTrue(classFinished , "TestClassFinished"  + " was never invoked");
        }