public void DecodeMemberAccessExpressionOfShouldReturnMemberOfRequiredClass()
        {
            var mi1 = TypeExtensions.DecodeMemberAccessExpressionOf <MyClass>(mc => mc.BaseProperty);

            Assert.That(mi1.DeclaringType, Is.EqualTo(typeof(MyBaseClass)));
            Assert.That(mi1.ReflectedType, Is.EqualTo(typeof(MyClass)));

            var mi2 = TypeExtensions.DecodeMemberAccessExpressionOf <MyClass>(mc => mc.BaseBool);

            Assert.That(mi2.DeclaringType, Is.EqualTo(typeof(MyBaseClass)));
            Assert.That(mi2.ReflectedType, Is.EqualTo(typeof(MyClass)));
        }
        public void GenericDecodeMemberAccessExpressionShouldReturnMemberOfDeclaringClass()
        {
            var mi1 = TypeExtensions.DecodeMemberAccessExpression <MyClass, string>(mc => mc.BaseProperty);

            Assert.That(mi1.DeclaringType, Is.EqualTo(typeof(MyBaseClass)));
            Assert.That(mi1.ReflectedType, Is.EqualTo(typeof(MyBaseClass)));

            var mi2 = TypeExtensions.DecodeMemberAccessExpression <MyClass, bool>(mc => mc.BaseBool);

            Assert.That(mi2.DeclaringType, Is.EqualTo(typeof(MyBaseClass)));
            Assert.That(mi2.ReflectedType, Is.EqualTo(typeof(MyBaseClass)));
        }
        public void DecodeMemberAccessExpressionOfWithGenericShouldReturnMemberOfRequiredClass()
        {
            var mi1 = TypeExtensions.DecodeMemberAccessExpressionOf <MyEntity>(mc => mc.Id);

            Assert.That(mi1.DeclaringType, Is.EqualTo(typeof(BaseEntity)));
            Assert.That(mi1.ReflectedType, Is.EqualTo(typeof(MyEntity)));

            var mi2 = TypeExtensions.DecodeMemberAccessExpressionOf <MyEntity>(mc => mc.BaseBool);

            Assert.That(mi2.DeclaringType, Is.EqualTo(typeof(BaseEntity)));
            Assert.That(mi2.ReflectedType, Is.EqualTo(typeof(MyEntity)));
        }
 public void WhenDecodeMemberAccessExpressionOfOnInheritedEntityInterfaceThenDecodeMember()
 {
     Assert.That(TypeExtensions.DecodeMemberAccessExpressionOf <IMyEntity>(m => m.Id), Is.Not.Null);
     Assert.That(TypeExtensions.DecodeMemberAccessExpressionOf <IMyEntity, Guid>(m => m.Id), Is.Not.Null);
 }
Example #5
0
 public static IGeneratorDef Foreign <TEntity>(Expression <Func <TEntity, object> > property)
 {
     return(new ForeignGeneratorDef(TypeExtensions.DecodeMemberAccessExpression(property)));
 }