public void Test_ShouldHavePropRuleDate_WhenSpecifyMinAndMaxString_WhenMaxDoesNotMatch_ShouldAssertFalse() { //---------------Set up test pack------------------- IPropDef propDef = new PropDefFake(); var minDate = ""; var maxDate = "Tomorrow"; propDef.AddPropRule(GetPropRuleDate(minDate, maxDate)); var tester = new PropDefTester(propDef); //---------------Assert Precondition---------------- Assert.AreEqual(1, propDef.PropRules.Count); Assert.IsInstanceOf <PropRuleDate>(propDef.PropRules[0]); //---------------Execute Test ---------------------- try { tester.ShouldHaveRuleDate(minDate, "Today"); Assert.Fail("Expected to throw an AssertionException"); } //---------------Test Result ----------------------- catch (AssertionException ex) { var expected = string.Format("The Property '{0}' for class '{1}'", propDef.PropertyName, propDef.ClassName); StringAssert.Contains(expected, ex.Message); StringAssert.Contains("MaxValue Should Be ", ex.Message); } }
public void Test_ShouldHavePropRuleDate_WhenSpecifyMinAndMaxString_WhenRuleMatches_ShouldAssertTrue() { //---------------Set up test pack------------------- var propDef = new PropDefFake(); var minDate = "Today"; var maxDate = "Tomorrow"; propDef.AddPropRule(GetPropRuleDate(minDate, maxDate)); var tester = new PropDefTester(propDef); //---------------Assert Precondition---------------- Assert.AreEqual(1, propDef.PropRules.Count); Assert.IsInstanceOf <PropRuleDate>(propDef.PropRules[0]); //---------------Execute Test ---------------------- var expectedMaxDate = maxDate; tester.ShouldHaveRuleDate(minDate, expectedMaxDate); //---------------Test Result ----------------------- Assert.IsTrue(true, "If it has got here then passed"); }