public void Test_ShouldHaveDefault_WhenNotHasDefault_ShouldAssertFalse() { //---------------Set up test pack------------------- var propDef = GetPropDef(); var tester = new PropDefTester(propDef); //---------------Assert Precondition---------------- Assert.IsNull(propDef.DefaultValueString); Assert.IsNotNullOrEmpty(propDef.PropertyName); Assert.IsNotNullOrEmpty(propDef.ClassName); //---------------Test Result ----------------------- try { tester.ShouldHaveDefault(); Assert.Fail("Expected to throw an AssertionException"); } //---------------Test Result ----------------------- catch (AssertionException ex) { var expected = string.Format( "The Property '{0}' for class '{1}' should have a default but does not", propDef.PropertyName, propDef.ClassName); StringAssert.Contains(expected, ex.Message); } }
public void Test_ShouldHaveDefault_WithSpecifiedValue_WhenValueNotEqual_ShouldAssertFalse() { //---------------Set up test pack------------------- var propDef = GetPropDef(); const string defaultValueString = "aToday"; propDef.DefaultValueString = "Today"; var tester = new PropDefTester(propDef); //---------------Assert Precondition---------------- Assert.IsNotNullOrEmpty(propDef.PropertyName); Assert.IsNotNullOrEmpty(propDef.ClassName); Assert.AreNotEqual(defaultValueString, propDef.DefaultValueString); //---------------Test Result ----------------------- try { tester.ShouldHaveDefault(defaultValueString); Assert.Fail("Expected to throw an AssertionException"); } //---------------Test Result ----------------------- catch (AssertionException ex) { var expected = string.Format( "The Property '{0}' for class '{1}' should have a default of '{2}' but has a default value of '{3}'", propDef.PropertyName, propDef.ClassName, defaultValueString, propDef.DefaultValueString); StringAssert.Contains(expected, ex.Message); } }
public void Test_ShouldHaveDefault_WhenHasDefault_ShouldAssertTrue() { //---------------Set up test pack------------------- var propDef = GetPropDef(); propDef.DefaultValueString = "fdafasdfasd"; var tester = new PropDefTester(propDef); //---------------Assert Precondition---------------- Assert.IsNotNull(propDef.DefaultValueString); //---------------Execute Test ---------------------- tester.ShouldHaveDefault(); //---------------Test Result ----------------------- Assert.IsTrue(true, "If it has got here then passed"); }