public void Test_ShouldBeCompulsory_WhenIsNot_ShouldAssertFalse() { //---------------Set up test pack------------------- var propDef = GetMockPropDef(); propDef.PropertyName = GetRandomString(); var className = GetRandomString(); propDef.Stub(def => def.ClassName).Return(className); propDef.Compulsory = false; var tester = new PropDefTester(propDef); //---------------Assert Precondition---------------- Assert.IsFalse(propDef.Compulsory); //---------------Execute Test ---------------------- try { tester.ShouldBeCompulsory(); Assert.Fail("Expected to throw an AssertionException"); } //---------------Test Result ----------------------- catch (AssertionException ex) { var expected = string.Format("The Property '{0}' for class '{1}' should be compulsory", propDef.PropertyName, className); StringAssert.Contains(expected, ex.Message); } }
public void Test_ShouldBeCompulsory_WhenIs_ShouldAssertTrue() { //---------------Set up test pack------------------- var propDef = GetMockPropDef(); propDef.Compulsory = true; var tester = new PropDefTester(propDef); //---------------Assert Precondition---------------- Assert.IsTrue(propDef.Compulsory); //---------------Execute Test ---------------------- tester.ShouldBeCompulsory(); //---------------Test Result ----------------------- Assert.IsTrue(true, "If it has got here then passed"); }