[Ignore("This is ideally how it should work but Current this is not the case so will need to reevaluate as I refactor: Brett")] //TODO Brett 29 Jun 2010: Ignored Test - This is ideally how it should work but Current this is not the case so will need to reevaluate as I refactor: Brett public void Test_GetPropertyValue_WhenPropertyNull_ShouldRaiseError() { //---------------Set up test pack------------------- const string propName = "Surname"; BOPropertyMapperSpy boPropertyMapper = new BOPropertyMapperSpy(propName); var contactPersonTestBO = new ContactPersonTestBO(); boPropertyMapper.BusinessObject = contactPersonTestBO; boPropertyMapper.SetBOProp(null); //---------------Assert Precondition---------------- Assert.IsNull(boPropertyMapper.Property); Assert.AreEqual(propName, boPropertyMapper.PropertyName); Assert.IsNull(contactPersonTestBO.Surname); //---------------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}' but there is no BOProp for this prop" , propName); StringAssert.Contains(expectedErrorMessage, ex.Message); } }
public void Test_InvalidMessage_ShouldReturnPropInvalidMessage() { //---------------Set up test pack------------------- BOPropertyMapperSpy propMapper = new BOPropertyMapperSpy(); var boPropStub = MockRepository.GenerateStub <IBOProp>(); boPropStub.Stub(prop => prop.InvalidReason).Return(RandomValueGen.GetRandomString()); propMapper.SetBOProp(boPropStub); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var invalidMessage = propMapper.InvalidReason; //---------------Test Result ----------------------- Assert.AreEqual(boPropStub.InvalidReason, invalidMessage); }
public void Test_InvalidMessage_WhenPropNull_ShouldReturnStdMessage() { //---------------Set up test pack------------------- BOPropertyMapperSpy propMapper = new BOPropertyMapperSpy(); IBOProp boPropStub = null; propMapper.SetBOProp(boPropStub); //---------------Assert Precondition---------------- Assert.IsNull(propMapper.Property); //---------------Execute Test ---------------------- var invalidMessage = propMapper.InvalidReason; //---------------Test Result ----------------------- var expectedMessage = string.Format("The Property '{0}' is not available" , propMapper.PropertyName); Assert.AreEqual(expectedMessage, invalidMessage); }
public void Test_SetPropertyValue_WhenPropertyNull_ShouldDoNothing() { //Ideally this should raise an error but code this is replacing behaves like this // I will review in the future Brett: 01 Jul 2010 //---------------Set up test pack------------------- const string propName = "Surname"; BOPropertyMapperSpy boPropertyMapper = new BOPropertyMapperSpy(propName); var contactPersonTestBO = new ContactPersonTestBO(); boPropertyMapper.BusinessObject = contactPersonTestBO; boPropertyMapper.SetBOProp(null); //---------------Assert Precondition---------------- Assert.IsNull(boPropertyMapper.Property); Assert.AreEqual(propName, boPropertyMapper.PropertyName); Assert.IsNull(contactPersonTestBO.Surname); //---------------Execute Test ---------------------- boPropertyMapper.SetPropertyValue(RandomValueGen.GetRandomString()); //---------------Test Result ----------------------- Assert.IsNull(contactPersonTestBO.Surname); }
public void Test_InvalidMessage_WhenPropNull_ShouldReturnStdMessage() { //---------------Set up test pack------------------- BOPropertyMapperSpy propMapper = new BOPropertyMapperSpy(); IBOProp boPropStub = null; propMapper.SetBOProp(boPropStub); //---------------Assert Precondition---------------- Assert.IsNull(propMapper.Property); //---------------Execute Test ---------------------- var invalidMessage = propMapper.InvalidReason; //---------------Test Result ----------------------- var expectedMessage = string.Format("The Property '{0}' is not available" , propMapper.PropertyName ); Assert.AreEqual(expectedMessage, invalidMessage); }
public void Test_InvalidMessage_ShouldReturnPropInvalidMessage() { //---------------Set up test pack------------------- BOPropertyMapperSpy propMapper = new BOPropertyMapperSpy(); var boPropStub = MockRepository.GenerateStub<IBOProp>(); boPropStub.Stub(prop => prop.InvalidReason).Return(RandomValueGen.GetRandomString()); propMapper.SetBOProp(boPropStub); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var invalidMessage = propMapper.InvalidReason; //---------------Test Result ----------------------- Assert.AreEqual(boPropStub.InvalidReason, invalidMessage); }