public void Test_SetPropertyValue_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.SetPropertyValue(RandomValueGen.GetRandomString()); Assert.Fail("Expected to throw an HabaneroApplicationException"); } //---------------Test Result ----------------------- catch (HabaneroApplicationException ex) { string expectedErrorMessage = string.Format( "Tried to Set Property Value 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_SetPropertyValue_ShouldSetBOPropsValue() { //---------------Set up test pack------------------- ContactPersonTestBO contactPersonTestBO = new ContactPersonTestBO(); const string propName = "Surname"; BOPropertyMapper boPropertyMapper = new BOPropertyMapper(propName) {BusinessObject = contactPersonTestBO}; //---------------Assert Precondition---------------- Assert.IsNotNull(boPropertyMapper.Property); Assert.IsNull(boPropertyMapper.Property.Value); //---------------Execute Test ---------------------- var expectedPropValue = RandomValueGen.GetRandomString(); boPropertyMapper.SetPropertyValue(expectedPropValue); //---------------Test Result ----------------------- Assert.AreEqual(expectedPropValue, boPropertyMapper.Property.Value); Assert.AreEqual(expectedPropValue, contactPersonTestBO.Surname); }