예제 #1
0
        public void MethodManager_GetTestsInTestClass_Will_Find_Five_Unit_Tests_And_One_Integration_Test_In_Current_Type_Test()
        {
            IList <TestMethod> tests = manager.GetTestsInTestClass(typeof(MethodManagerTest), TestType.All, null);

            Confirm.Equal(6, tests.Count);

            TestMethod method = tests.Where(t => t.Name == "MethodManager_GetTestsInTestClass_Will_Find_Test_Setup_Method_On_For_Every_Test").Single();

            EnsureCorrectTestResult(method);

            method = tests.Where(t => t.Name == "MethodManager_GetTestsInTestClass_Will_Find_Test_Tear_Down_Method_On_For_Every_Test").Single();
            EnsureCorrectTestResult(method);


            method = tests.Where(t => t.Name == "MethodManager_GetTestsInTestClass_Will_Find_One_Integration_Test_In_Current_Type_Test").Single();
            EnsureCorrectTestResult(method);

            method = tests.Where(t => t.Name == "MethodManager_GetTestsInTestClass_Will_Find_Five_Unit_Tests_And_One_Integration_Test_In_Current_Type_Test").Single();
            EnsureCorrectTestResult(method);
            Confirm.Equal(System.Reflection.MethodBase.GetCurrentMethod(), method.MemberInfo);

            method = tests.Where(t => t.Name == "MethodManager_GetTestsInTestClass_Will_Find_Five_Unit_Tests_In_Current_Type_Test").Single();
            EnsureCorrectTestResult(method);

            method = tests.Where(t => t.Name == "MethodManager_GetTestsInTestClass_Will_Throw_Exception_Argument_Exception_If_Test_Type_Is_Undefined_Test").Single();
            EnsureCorrectTestResult(method);
        }
예제 #2
0
        public void RunTestCommand_Will_Execute_Passing_Test()
        {
            TestMethodViewModel viewModel = new TestMethodViewModel(AddResultControl, ClearResultControl);

            MockTestManager testManager = new MockTestManager();

            testManager.PassTests = true;

            viewModel.TestManager = testManager;

            TestFixture fixture = new TestFixture();

            TestMethod testMethod = new TestMethod();

            testMethod.Name = "test1";
            fixture.Tests   = new List <TestMethod>();
            fixture.Tests.Add(testMethod);

            viewModel.Tests = new List <TestFixture>();
            viewModel.Tests.Add(fixture);

            viewModel.RunTestsCommand.Execute(null);

            Thread.Sleep(5000);

            Confirm.Equal(1, viewModel.TestsPassed);
            Confirm.Equal(0, viewModel.TestsFailed);
        }
예제 #3
0
 public void ConfirmThrowsEqualityExceptionForComparisonBetweenUnequalStringsTest()
 {
     try
     {
         Confirm.Equal("test", "test2");
         throw new Exception();
     }
     catch (EqualityException) { }
 }
예제 #4
0
        public void ExceptionIsExcepted_Returns_True_For_Expected_Exception_Test()
        {
            Exception ex = new Exception("", new DivideByZeroException());

            Confirm.Equal(true, AttributeManager.ExceptionIsExcepted(System.Reflection.MethodBase.GetCurrentMethod(), ex));

            // must do this to satisfy DivideByZeroException check
            throw new DivideByZeroException();
        }
예제 #5
0
        public void TestCategoryTest_Will_Parse_List_Of_Attributes()
        {
            TestCategory category = new TestCategory("Cat1,Cat2");

            Confirm.IsTrue(category.Categories.Count == 2);

            Confirm.Equal("Cat1", category.Categories[0]);
            Confirm.Equal("Cat2", category.Categories[1]);
        }
예제 #6
0
 public void ConfirmThrowsEqualityExceptionForComparisonBetweenUnequalIntegersTest()
 {
     try
     {
         Confirm.Equal(1, 4);
         throw new Exception();
     }
     catch (EqualityException) { }
 }
예제 #7
0
        public void DurationVisibility_Will_Return_Visibility_Visible_If_Test_Passed_Test()
        {
            TestResult result = new TestResult();

            result.Passed = true;
            TestResultViewModel viewModel = new TestResultViewModel(result);

            Confirm.Equal(Visibility.Visible, viewModel.DurationVisibility);
        }
예제 #8
0
        public void ErrorVisibility_Will_Return_Visibility_Visible_If_Test_Failed_Test()
        {
            TestResult result = new TestResult();

            result.Passed = false;
            TestResultViewModel viewModel = new TestResultViewModel(result);

            Confirm.Equal(Visibility.Visible, viewModel.ErrorVisibility);
        }
예제 #9
0
        public void ErrorVisibility_Will_Return_Visibility_Colapsed_If_Test_Passed_Test()
        {
            TestResult result = new TestResult();

            result.Passed = true;
            TestResultViewModel viewModel = new TestResultViewModel(result);

            Confirm.Equal(Visibility.Collapsed, viewModel.ErrorVisibility);
        }
예제 #10
0
        public void IsDetailedSectionVisibile_Is_Colapsed_By_Default_Test()
        {
            TestResult result = new TestResult();

            result.Passed = true;
            TestResultViewModel viewModel = new TestResultViewModel(result);

            Confirm.Equal(Visibility.Collapsed, viewModel.IsDetailedSectionVisibile);
        }
예제 #11
0
        public void DurationVisibility_Will_Return_Visibility_Colapsed_If_Test_Failed_Test()
        {
            TestResult result = new TestResult();

            result.Passed = false;
            TestResultViewModel viewModel = new TestResultViewModel(result);

            Confirm.Equal(Visibility.Collapsed, viewModel.DurationVisibility);
        }
예제 #12
0
 public void ConfirmThrowsEqualityExceptionForComparisonBetweenIntegerAndNullTest()
 {
     try
     {
         Confirm.Equal(null, 4);
         throw new Exception();
     }
     catch (EqualityException) { }
 }
예제 #13
0
 public void ConfirmThrowsEqualityExceptionForComparisonBetweenEmptyStringAndNull()
 {
     try
     {
         Confirm.Equal(null, string.Empty);
         throw new Exception();
     }
     catch (EqualityException) { }
 }
예제 #14
0
        private void EnsureCorrectTestResult(TestMethod method)
        {
            Confirm.IsTrue(method.TestSetup.Name == "TestSetup");

            Confirm.IsTrue(method.TestTearDown.Name == "TestTearDown");

            Confirm.Equal(typeof(MethodManagerTest), method.Type);
            Confirm.Equal("Yellow", method.Color);
        }
예제 #15
0
 public void ConfirmEqualityExceptionThrownForDifferentIntegersTest()
 {
     try
     {
         Confirm.Equal(1, 2);
         throw new EqualityException(1, 2);
     }
     catch (EqualityException) { }
 }
예제 #16
0
        public void SectionVisibilityCommand_Will_Fire_And_Toggle_Detail_Section_To_Visible_Test()
        {
            TestResult result = new TestResult();

            result.Passed = true;
            TestResultViewModel viewModel = new TestResultViewModel(result);

            viewModel.SectionVisibilityCommand.Execute(null);
            Confirm.Equal(Visibility.Visible, viewModel.IsDetailedSectionVisibile);
        }
예제 #17
0
        public void MethodManagerTest2_Will_Find_Test_Of_Single_Category()
        {
            MethodManager manager = new MethodManager();

            IList <TestMethod> tests = manager.GetTestsInTestClass(typeof(MethodManagerTest2), TestType.UnitTest, "Category1");

            Confirm.IsTrue(tests.Count == 1);

            Confirm.Equal("MethodManagerTest2_Will_Find_Test_Of_Single_Category", tests[0].Name);
        }
예제 #18
0
        public void MethodManager_GetTestsInTestClass_Will_Find_One_Integration_Test_In_Current_Type_Test()
        {
            IList <TestMethod> tests = manager.GetTestsInTestClass(typeof(MethodManagerTest), TestType.IntegrationTest, null);

            Confirm.Equal(1, tests.Count);
            TestMethod method = tests.Where(t => t.Name == "MethodManager_GetTestsInTestClass_Will_Find_One_Integration_Test_In_Current_Type_Test").Single();

            Confirm.Equal(System.Reflection.MethodBase.GetCurrentMethod(), method.MemberInfo);
            EnsureCorrectTestResult(method);
        }
예제 #19
0
        public void ConfirmThatCollectionsAreEqualWhenCollectionTypeOverridesEqualsToCompareListElementsTest()
        {
            SameCollection col1 = new SameCollection();
            SameCollection col2 = new SameCollection();

            string str = "test";

            col1.Add(str);
            col2.Add(str);

            Confirm.Equal(col1, col2);
        }
예제 #20
0
        public void Test_That_Mock_Certificate_Can_Sign_And_Verify_Xml_Signature_Test()
        {
            SecurityManager manager = new SecurityManager();
            XmlDocument     doc     = new XmlDocument();

            doc.LoadXml(xml);

            MockX509Certificate cert = manager.CreateMockX509Certificate();

            SignXml(doc, cert.PrivateKey);

            Confirm.Equal(true, VerifyXml(doc, cert.PublicKey));
        }
예제 #21
0
        public void TestManager_RunTest_Will_Run_Passing_Test_Test()
        {
            TestManager manager = new TestManager();
            TestMethod  method  = new TestMethod();

            method.Name       = "PassingStub";
            method.Type       = typeof(TestManagerTest);
            method.MemberInfo = PassingStub();

            TestResult res = manager.RunTest(method);

            Confirm.Equal(true, res.Passed);
            Confirm.Equal("PassingStub (PASSED)", res.ResultText);
        }
예제 #22
0
        public void Test_Error_Message_For_Equal_Without_Custom_Error_Message()
        {
            try
            {
                Confirm.Equal("a", "b");
            }
            catch (EqualityException ex)
            {
                Confirm.Equal(string.Format("The expected value is: [{0}], but the actual value is: [{1}]", "a", "b"), ex.Message);
                return;
            }

            throw new Exception("Error");
        }
예제 #23
0
        public void Test_Error_Message_For_Different_Without_Custom_Error_Message()
        {
            try
            {
                Confirm.Different("a", "a");
            }
            catch (UnequalException ex)
            {
                Confirm.Equal(string.Format("The the actual value should not be equal to {0}", "a"), ex.Message);
                return;
            }

            throw new Exception("Error");
        }
예제 #24
0
        private void TestBody()
        {
            TestMethodViewModel viewModel = new TestMethodViewModel(AddResultControl, ClearResultControl);

            viewModel.Tests = new List <TestFixture>();
            Confirm.Equal(0, viewModel.Tests.Count);

            ComboBoxItem item = new ComboBoxItem();

            item.Name = "UnitTests";
            viewModel.SelectedItem = item;

            Confirm.Different(0, viewModel.Tests.Count);
        }
예제 #25
0
        public void Test_That_Mock_Certificate_Can_Reject_Xml_That_Has_Been_Modified_After_Signing_Test()
        {
            SecurityManager manager = new SecurityManager();
            XmlDocument     doc     = new XmlDocument();

            doc.LoadXml(xml);

            MockX509Certificate cert = manager.CreateMockX509Certificate();

            SignXml(doc, cert.PrivateKey);

            doc.GetElementsByTagName("test1")[0].InnerText = "change after signing";

            Confirm.Equal(false, VerifyXml(doc, cert.PublicKey));
        }
예제 #26
0
        public void Test_Error_Message_For_Different_With_Custom_Error_Message()
        {
            string errorMessage = "The two strings are not different";

            try
            {
                Confirm.Different("a", "a", errorMessage);
            }
            catch (UnequalException ex)
            {
                Confirm.Equal(string.Format("The the actual value should not be equal to {0} Error: {1}", "a", errorMessage), ex.Message);
                return;
            }

            throw new Exception("Error");
        }
예제 #27
0
        public void Test_Error_Message_For_Equal_With_Custom_Error_Message()
        {
            string errorMessage = "The two strings are not equal";

            try
            {
                Confirm.Equal("a", "b", errorMessage);
            }
            catch (EqualityException ex)
            {
                Confirm.Equal(string.Format("The expected value is: [{0}], but the actual value is: [{1}] Error: {2}", "a", "b", errorMessage), ex.Message);
                return;
            }

            throw new Exception("Error");
        }
예제 #28
0
        public void Test_Error_Message_For_IsNull_With_ErrorMessage()
        {
            string errorMessage = "Object is not null";

            try
            {
                Confirm.IsNull("a", errorMessage);
            }
            catch (EqualityException ex)
            {
                Confirm.Equal(string.Format("The expected value is: [{0}], but the actual value is: [{1}] Error: {2}", "null", "a", errorMessage), ex.Message);
                return;
            }

            throw new Exception("Error");
        }
예제 #29
0
        public void TestManager_RunTest_Will_Run_Failing_Test_When_Confirm_Different_Fails_Test()
        {
            TestManager manager = new TestManager();
            TestMethod  method  = new TestMethod();

            method.Name = "FailingStubWithFailingConfirmDifferent";
            method.Type = typeof(TestManagerTest);

            Type t = typeof(TestManagerTest);
            var  q = from m in t.GetMembers()
                     where m.Name == "FailingStubWithFailingConfirmDifferent"
                     select m;

            method.MemberInfo = q.Single <MemberInfo>();

            TestResult res = manager.RunTest(method);

            Confirm.Equal("The the actual value should not be equal to Not Expected Value", res.ResultText);
            Confirm.Equal(false, res.Passed);
        }
예제 #30
0
        public void TestManager_RunTest_Will_Run_Failing_Test_When_Confirm_Equals_Fails_Test()
        {
            TestManager manager = new TestManager();
            TestMethod  method  = new TestMethod();

            method.Name = "FailingStubWithFailingConfirmEquals";
            method.Type = typeof(TestManagerTest);

            Type t = typeof(TestManagerTest);
            var  q = from m in t.GetMembers()
                     where m.Name == "FailingStubWithFailingConfirmEquals"
                     select m;

            method.MemberInfo = q.Single <MemberInfo>();

            TestResult res = manager.RunTest(method);

            Confirm.Equal("The expected value is: [1], but the actual value is: [2]", res.ResultText);
            Confirm.Equal(false, res.Passed);
        }