public void Test_GetPropertyValue_WhenBONull_ShouldRaiseError() { //---------------Set up test pack------------------- const string propName = "Surname"; BOPropertyMapper boPropertyMapper = new BOPropertyMapper(propName); //---------------Assert Precondition---------------- Assert.IsNull(boPropertyMapper.BusinessObject); //---------------Execute Test ---------------------- try { boPropertyMapper.GetPropertyValue(); Assert.Fail("Expected to throw an HabaneroApplicationException"); } //---------------Test Result ----------------------- catch (HabaneroApplicationException ex) { string expectedErrorMessage = string.Format( "Tried to GetPropertyValue the BOPropertyMapper for Property '{0}' when the BusinessObject is not set " , propName); StringAssert.Contains(expectedErrorMessage, ex.Message); } }
public void Test_SetPropertyDisplayValue_WithIntString_ShouldBeAbleGetString() { //---------------Set up test pack------------------- ClassDef.ClassDefs.Clear(); MyBO.LoadDefaultClassDef(); const string propName = "TestProp"; var testBo = new MyBO(); var boMapper = new BOPropertyMapper(propName) { BusinessObject = testBo }; boMapper.SetPropertyValue("7"); //---------------Assert Precondition---------------- Assert.AreEqual("7", boMapper.GetPropertyValue().ToString()); //---------------Execute Test ---------------------- boMapper.SetPropertyValue("3"); //---------------Test Result ----------------------- Assert.AreEqual("3", boMapper.GetPropertyValue().ToString()); Assert.AreEqual("3", testBo.TestProp); }
public void Test_GetPropertyValue_ShouldSetBOPropsValue() { //---------------Set up test pack------------------- ContactPersonTestBO contactPersonTestBO = new ContactPersonTestBO(); const string propName = "Surname"; BOPropertyMapper boPropertyMapper = new BOPropertyMapper(propName) { BusinessObject = contactPersonTestBO }; var expectedPropValue = RandomValueGen.GetRandomString(); boPropertyMapper.Property.Value = expectedPropValue; //---------------Assert Precondition---------------- Assert.IsNotNull(boPropertyMapper.Property); Assert.AreEqual(expectedPropValue, boPropertyMapper.Property.Value); //---------------Execute Test ---------------------- object actualValue = boPropertyMapper.GetPropertyValue(); //---------------Test Result ----------------------- Assert.AreEqual(expectedPropValue, actualValue); Assert.AreEqual(expectedPropValue, contactPersonTestBO.Surname); }