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); }
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); }
public void ConfirmThrowsEqualityExceptionForComparisonBetweenUnequalStringsTest() { try { Confirm.Equal("test", "test2"); throw new Exception(); } catch (EqualityException) { } }
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(); }
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]); }
public void ConfirmThrowsEqualityExceptionForComparisonBetweenUnequalIntegersTest() { try { Confirm.Equal(1, 4); throw new Exception(); } catch (EqualityException) { } }
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); }
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); }
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); }
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); }
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); }
public void ConfirmThrowsEqualityExceptionForComparisonBetweenIntegerAndNullTest() { try { Confirm.Equal(null, 4); throw new Exception(); } catch (EqualityException) { } }
public void ConfirmThrowsEqualityExceptionForComparisonBetweenEmptyStringAndNull() { try { Confirm.Equal(null, string.Empty); throw new Exception(); } catch (EqualityException) { } }
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); }
public void ConfirmEqualityExceptionThrownForDifferentIntegersTest() { try { Confirm.Equal(1, 2); throw new EqualityException(1, 2); } catch (EqualityException) { } }
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); }
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); }
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); }
public void ConfirmThatCollectionsAreEqualWhenCollectionTypeOverridesEqualsToCompareListElementsTest() { SameCollection col1 = new SameCollection(); SameCollection col2 = new SameCollection(); string str = "test"; col1.Add(str); col2.Add(str); Confirm.Equal(col1, col2); }
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)); }
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); }
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"); }
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"); }
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); }
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)); }
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"); }
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"); }
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"); }
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); }
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); }