public void Test_ShouldNotHaveDefault_WithLambda_WhenNotHasDefault_ShouldAssertTrue() { //---------------Set up test pack------------------- SetupClassDef <BOFakeWithDefault>(); BOTester <BOFakeWithDefault> boTester = CreateGenericTester <BOFakeWithDefault>(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- boTester.ShouldNotHaveDefault(bo => bo.NonDefaultProp); //---------------Test Result ----------------------- Assert.IsTrue(true, "If it has got here then passed"); }
public void Test_ShouldNotHaveDefault_WithLambda_WithSpecifiedValue_WhenNotHasDefault_ShouldAssertTrue() { //---------------Set up test pack------------------- IClassDef classDef = SetupClassDef <BOFakeWithDefault>(); BOTester <BOFakeWithDefault> boTester = CreateGenericTester <BOFakeWithDefault>(); const string propName = "NonDefaultProp"; const string defaultValueString = "SomeValue"; IPropDef propDef = classDef.GetPropDef(propName); //---------------Assert Precondition---------------- Assert.IsNullOrEmpty(propDef.DefaultValueString); //---------------Execute Test ---------------------- boTester.ShouldNotHaveDefault(bo => bo.NonDefaultProp, defaultValueString); //---------------Test Result ----------------------- Assert.IsTrue(true, "If it has got here then passed"); }
public void Test_ShouldNotHaveDefault_WithLambda_WhenHasDefault_ShouldAssertFalse() { //---------------Set up test pack------------------- SetupClassDefWithAddProperty <BOFakeWithDefault>(); const string propName = "DefaultProp"; BOTester <BOFakeWithDefault> boTester = CreateGenericTester <BOFakeWithDefault>(); //---------------Assert Precondition---------------- //---------------Test Result ----------------------- try { boTester.ShouldNotHaveDefault(bo => bo.DefaultProp); Assert.Fail("Expected to throw an AssertionException"); } //---------------Test Result ----------------------- catch (AssertionException ex) { string expected = string.Format("The Property '{0}' for class '{1}' should not have a default but does", propName, "BOFakeWithDefault"); StringAssert.Contains(expected, ex.Message); } }