public void Test_SetPropertyValue_ShouldSetBOPropsValue() { //---------------Set up test pack------------------- ContactPersonTestBO contactPersonTestBO = new ContactPersonTestBO(); const string propName = "ReflectiveProp"; IBOPropertyMapper boPropertyMapper = new ReflectionPropertyMapper(propName) { BusinessObject = contactPersonTestBO }; //---------------Assert Precondition---------------- Assert.IsNull(contactPersonTestBO.ReflectiveProp); //---------------Execute Test ---------------------- var expectedPropValue = RandomValueGen.GetRandomString(); boPropertyMapper.SetPropertyValue(expectedPropValue); //---------------Test Result ----------------------- Assert.AreEqual(expectedPropValue, contactPersonTestBO.ReflectiveProp); }
public void Test_SetPropertyValue_WhenBONull_ShouldRaiseError() { //---------------Set up test pack------------------- const string propName = "ReflectiveProp"; ReflectionPropertyMapper boPropertyMapper = new ReflectionPropertyMapper(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 ReflectionPropertyMapper for Property '{0}' when the BusinessObject is not set " , propName); StringAssert.Contains(expectedErrorMessage, ex.Message); } }