public void Test_ShouldHaveDisplayName_WithSpecifiedValue_WhenValueNotEqual_ShouldAssertFalse() { //---------------Set up test pack------------------- var propDef = GetPropDef(); const string expectedDisplayName = "AnotherDisplayName"; var actualDisplayName = RandomValueGen.GetRandomString(); propDef.Stub(def => def.DisplayName).Return(actualDisplayName); var tester = new PropDefTester(propDef); //---------------Assert Precondition---------------- Assert.IsNotNullOrEmpty(propDef.PropertyName); Assert.IsNotNullOrEmpty(propDef.ClassName); Assert.AreNotEqual(expectedDisplayName, propDef.DisplayName); //---------------Test Result ----------------------- try { tester.ShouldHaveDisplayName(expectedDisplayName); 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 DisplayName of '{2}' but has a DisplayName of '{3}'", propDef.PropertyName, propDef.ClassName, expectedDisplayName, actualDisplayName); StringAssert.Contains(expected, ex.Message); } }
public void Test_ShouldHaveDisplayName_WithSpecifiedValue_WhenHasDisplayName_ShouldAssertTrue() { //---------------Set up test pack------------------- var propDef = GetPropDef(); var displayName = RandomValueGen.GetRandomString(); propDef.Stub(def => def.DisplayName).Return(displayName); var tester = new PropDefTester(propDef); //---------------Assert Precondition---------------- Assert.IsNotNull(propDef.DisplayName); //---------------Execute Test ---------------------- tester.ShouldHaveDisplayName(displayName); //---------------Test Result ----------------------- Assert.IsTrue(true, "If it has got here then passed"); }