public void Test_Create_WhenReflectiveProp_WhenNotDefinedWithDash_ShouldCreateReflectivePropMapper()
        {
            //---------------Set up test pack-------------------
            const string propName = "ReflectiveProp";
            var          bo       = new ContactPersonTestBO();
            //---------------Assert Precondition----------------
            var propertyInfo = ReflectionUtilities.GetPropertyInfo(bo.GetType(), propName);

            Assert.IsNotNull(propertyInfo);
            //---------------Execute Test ----------------------
            IBOPropertyMapper propMapper = BOPropMapperFactory.CreateMapper(bo, propName);

            //---------------Test Result -----------------------
            Assert.IsInstanceOf <ReflectionPropertyMapper>(propMapper);
            Assert.AreEqual(propName, propMapper.PropertyName);
            Assert.AreSame(bo, propMapper.BusinessObject);
        }
        public void Test_Create_WhenReflectiveProp_WhenReflectivePropNotExists_ShouldCreateReflectivePropMapper()
        {
            //---------------Set up test pack-------------------
            const string propName = "NonExistentReflectiveProp";
            var          bo       = new ContactPersonTestBO();
            //---------------Assert Precondition----------------
            var propertyInfo = ReflectionUtilities.GetPropertyInfo(bo.GetType(), propName);

            Assert.IsNull(propertyInfo);
            //---------------Execute Test ----------------------
            try
            {
                BOPropMapperFactory.CreateMapper(bo, propName);
                Assert.Fail("Expected to throw an InvalidPropertyException");
            }
            //---------------Test Result -----------------------
            catch (InvalidPropertyException ex)
            {
                StringAssert.Contains("The property 'NonExistentReflectiveProp' on 'ContactPersonTestBO' cannot be found", ex.Message);
            }
        }
        public void Test_Create_WhenReflectiveProp_WhenReflectivePropNotExists_ShouldCreateReflectivePropMapper()
        {
            //---------------Set up test pack-------------------
            const string propName = "NonExistentReflectiveProp";
            var bo = new ContactPersonTestBO();
            //---------------Assert Precondition----------------
            var propertyInfo = ReflectionUtilities.GetPropertyInfo(bo.GetType(), propName);
            Assert.IsNull(propertyInfo);
            //---------------Execute Test ----------------------
            try
            {
                BOPropMapperFactory.CreateMapper(bo, propName);
                Assert.Fail("Expected to throw an InvalidPropertyException");
            }
                //---------------Test Result -----------------------
            catch (InvalidPropertyException ex)
            {
                StringAssert.Contains("The property 'NonExistentReflectiveProp' on 'ContactPersonTestBO' cannot be found", ex.Message);
            }

        }
 public void Test_SetValue__NewObject_DifferentType_NotInList()
 {
     //---------------Set up test pack-------------------
     MyBO.LoadDefaultClassDef();
     BOProp boProp = new BOPropLookupList(_propDefGuid);
     ContactPersonTestBO.LoadDefaultClassDef();
     ContactPersonTestBO newContactPersonTestBO = new ContactPersonTestBO();
     //---------------Assert Precondition----------------
     Assert.IsNull(boProp.Value);
     //---------------Execute Test ----------------------
     boProp.Value = newContactPersonTestBO.ID.GetAsValue();
     //---------------Test Result -----------------------
     Assert.IsNotNull(boProp.Value);
     Assert.IsInstanceOf(typeof(Guid), boProp.Value);
     Assert.AreEqual(newContactPersonTestBO.ID.GetAsValue(), boProp.Value);
     string expectedErrorMessage = String.Format
         ("{0}' is not valid. The Business object '{1}' returned for this ID is not a type of 'Habanero.Test.MyBO'.",
          boProp.DisplayName, newContactPersonTestBO.GetType());
     StringAssert.Contains(expectedErrorMessage, boProp.InvalidReason);
     Assert.IsFalse(boProp.IsValid);
 }
 public void Test_Create_WhenReflectiveProp_WhenNotDefinedWithDash_ShouldCreateReflectivePropMapper()
 {
     //---------------Set up test pack-------------------
     const string propName = "ReflectiveProp";
     var bo = new ContactPersonTestBO();
     //---------------Assert Precondition----------------
     var propertyInfo = ReflectionUtilities.GetPropertyInfo(bo.GetType(), propName);
     Assert.IsNotNull(propertyInfo);
     //---------------Execute Test ----------------------
     IBOPropertyMapper propMapper = BOPropMapperFactory.CreateMapper(bo, propName);
     //---------------Test Result -----------------------
     Assert.IsInstanceOf<ReflectionPropertyMapper>(propMapper);
     Assert.AreEqual(propName, propMapper.PropertyName);
     Assert.AreSame(bo, propMapper.BusinessObject);
 }