コード例 #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
ファイル: ErrorTests.cs プロジェクト: thelgevold/ExpressUnit
        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
ファイル: ErrorTests.cs プロジェクト: thelgevold/ExpressUnit
        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
ファイル: ErrorTests.cs プロジェクト: thelgevold/ExpressUnit
        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
ファイル: ErrorTests.cs プロジェクト: thelgevold/ExpressUnit
        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
ファイル: ErrorTests.cs プロジェクト: thelgevold/ExpressUnit
        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);
        }