public void Test_MustBeMapped_WhenPropIsInherited_ShouldRetFalse()
        {
            //---------------Set up test pack-------------------
            var propertyWrapper = MockRepository.GenerateStub <FakePropertyWrapper>();

            propertyWrapper.Stub(wrapper => wrapper.IsPublic).Return(true);
            propertyWrapper.Stub(wrapper => wrapper.IsInherited).Return(true);
            propertyWrapper.Stub(wrapper => wrapper.IsSingleRelationship).Return(true);
            ManyToOneAutoMapper mapper = new ManyToOneAutoMapper(propertyWrapper);

            //---------------Assert Precondition----------------
            Assert.IsFalse(propertyWrapper.IsStatic);
            Assert.IsTrue(propertyWrapper.IsPublic);
            Assert.IsFalse(propertyWrapper.HasManyToOneAttribute);
            Assert.IsTrue(propertyWrapper.IsSingleRelationship);
            Assert.IsFalse(propertyWrapper.HasIgnoreAttribute);
            Assert.IsFalse(propertyWrapper.HasOneToOneAttribute);

            Assert.IsTrue(propertyWrapper.IsInherited);
            //---------------Execute Test ----------------------
            var mustBeMapped = mapper.MustBeMapped();

            //---------------Test Result -----------------------
            Assert.IsFalse(mustBeMapped);
        }
        public void Test_GetRelatedPropName_WhenRelatedClassInheritsFromGenericBO_ShouldUseGenericTypeToDetermineName()
        {
            //---------------Set up test pack-------------------
            var type = typeof(FakeBOGeneric);
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var relatedPropName = ManyToOneAutoMapper.GetRelatedPropName(type.ToTypeWrapper());

            //---------------Test Result -----------------------
            Assert.AreEqual("FakeBOGenericID", relatedPropName);
        }
        public void Test_GetRelatatedPropName_WhenNoProp_ShouldReturnStdNamingProp()
        {
            //---------------Set up test pack-------------------
            var type = typeof(FakeBONoPK);
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var relatedPropName = ManyToOneAutoMapper.GetRelatedPropName(type.ToTypeWrapper());

            //---------------Test Result -----------------------
            Assert.AreEqual("FakeBONoPKID", relatedPropName);
        }
        public void Test_GetRelatatedPropName_WhenStdNamingPropAndRelDeclaredProp_ShouldReturnDeclaredPropName()
        {
            //---------------Set up test pack-------------------
            var type = typeof(FakeBOAttributePKAndPKNaming);
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var relatedPropName = ManyToOneAutoMapper.GetRelatedPropName(type.ToTypeWrapper());

            //---------------Test Result -----------------------
            Assert.AreEqual("PublicGuidProp", relatedPropName);
        }
        public void Test_GetRelatedPropName_WhenRelatedClassHasAttributeDeclaredIdProp_ShouldUseDeclaredIDPropName()
        {
            //---------------Set up test pack-------------------
            var type = typeof(FakeBOAttributePK);
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var relatedPropName = ManyToOneAutoMapper.GetRelatedPropName(type.ToTypeWrapper());

            //---------------Test Result -----------------------
            Assert.AreEqual("PublicGuidProp", relatedPropName);
        }
        public void Test_Map_WhenOverridenProp_ShouldReturnNull()
        {
            //When Prop overrides from another class the base
            // declaration of the prop will be mapped as part of the base class
            // and should not be mapped as part of this class.
            //---------------Set up test pack-------------------
            var          classType       = typeof(FakeBOSubClassWithOverridenProps);
            PropertyInfo propertyInfo    = classType.GetProperty("ManyToOneRelationshipOverridden");
            var          autoMapper      = new ManyToOneAutoMapper(propertyInfo);
            var          propertyWrapper = propertyInfo.ToPropertyWrapper();

            //---------------Assert Precondition----------------
            Assert.IsNotNull(propertyInfo);
            Assert.IsFalse(propertyWrapper.HasIgnoreAttribute);

            Assert.IsTrue(propertyWrapper.IsPublic);
            Assert.IsTrue(propertyWrapper.IsOverridden);
            //---------------Execute Test ----------------------
            var propDef = autoMapper.MapManyToOne();

            //---------------Test Result -----------------------
            Assert.IsNull(propDef);
        }