Exemple #1
0
        public void GetMember_Instance_MemberExpression_OverridingProperty()
        {
            var member = NormalizingMemberInfoFromExpressionUtility.GetMember((DomainType obj) => obj.OverridingProperty);

            var expected = typeof(DomainType).GetProperty("OverridingProperty");

            Assert.That(member, Is.EqualTo(expected));
        }
Exemple #2
0
        public void GetMember_Instance_MethodCallExpression()
        {
            var member = NormalizingMemberInfoFromExpressionUtility.GetMember((DomainType obj) => obj.InstanceMethod());

            var expected = typeof(DomainType).GetMember("InstanceMethod").Single();

            Assert.That(member, Is.EqualTo(expected));
        }
Exemple #3
0
        public void GetMember_Static_NewExpression()
        {
            var member = NormalizingMemberInfoFromExpressionUtility.GetMember(() => new DomainType());

            var expected = typeof(DomainType).GetMember(".ctor").Single();

            Assert.That(member, Is.EqualTo(expected));
        }
Exemple #4
0
        public void GetMember_Static_MethodCallExpression()
        {
            var member = NormalizingMemberInfoFromExpressionUtility.GetMember(() => DomainType.StaticMethod());

            var expected = typeof(DomainType).GetMember("StaticMethod").Single();

            Assert.That(member, Is.EqualTo(expected));
        }
Exemple #5
0
        public void GetCustomAttributes_AttributesOnOriginalMemberAreNotFiltered()
        {
            var member           = NormalizingMemberInfoFromExpressionUtility.GetMember((DomainType obj) => obj.MethodOnDomainType());
            var customAttributes = TypePipeCustomAttributeData.GetCustomAttributes(member, true);

            var customAttributeTypes = customAttributes.Select(a => a.Type).ToArray();

            Assert.That(customAttributeTypes, Is.EquivalentTo(new[] { typeof(InheritableAttribute), typeof(NonInheritableAttribute) }));
        }
Exemple #6
0
        public void SetUp()
        {
            _comparer = new MemberNameAndSignatureEqualityComparer();

            _member = NormalizingMemberInfoFromExpressionUtility.GetMember(() => Member(""));
            _memberDifferentSignature   = NormalizingMemberInfoFromExpressionUtility.GetMember(() => Member(7));
            _memberDifferentName        = NormalizingMemberInfoFromExpressionUtility.GetMember(() => OtherMember(""));
            _memberSameNameAndSignature = NormalizingMemberInfoFromExpressionUtility.GetMember((ISomeInterface obj) => obj.Member(""));
        }
Exemple #7
0
        public void GetNameForExplicitImplementation()
        {
            var member = NormalizingMemberInfoFromExpressionUtility.GetMember((NestedType o) => o.Property);

            var result = MemberImplementationUtility.GetNameForExplicitImplementation(member);

            Assert.That(
                result, Is.EqualTo("Remotion.TypePipe.UnitTests.MutableReflection.Implementation.MemberImplementationUtilityTest.NestedType.Property"));
        }
Exemple #8
0
        public void IsDefined()
        {
            var member = NormalizingMemberInfoFromExpressionUtility.GetMember(() => IsDefinedMemberWithDerivedAttribute());

            Assert.That(member.IsDefined(typeof(UnrelatedAttribute), false), Is.False);
            Assert.That(member.IsDefined(typeof(DerivedAttribute), false), Is.True);
            Assert.That(member.IsDefined(typeof(BaseAttribute), false), Is.True);
            Assert.That(member.IsDefined(typeof(IDerivedAttributeInterface), false), Is.True);
        }
Exemple #9
0
        public void GetCustomAttributes_WithAllowMultipleFiltering_AttributesOnBaseOnly()
        {
            var member = NormalizingMemberInfoFromExpressionUtility.GetMember((DomainType obj) => obj.AttributesOnBaseOnly());

            var attributes = TypePipeCustomAttributeData.GetCustomAttributes(member, true);

            var attributeTypes = attributes.Select(d => d.Type).ToArray();

            Assert.That(attributeTypes, Is.EquivalentTo(new[] { typeof(InheritableAllowMultipleAttribute), typeof(InheritableNonMultipleAttribute) }));
        }
Exemple #10
0
        public void GetCustomAttributes_WithAllowMultipleFiltering_AttributesOnBaseAndDerived()
        {
            var member = NormalizingMemberInfoFromExpressionUtility.GetMember((DomainType obj) => obj.AttributesOnBaseAndDerived());

            var attributes = TypePipeCustomAttributeData.GetCustomAttributes(member, true);

            var attributeTypesAndCtorArgs         = attributes.Select(d => new { d.Type, Arg = (string)d.ConstructorArguments.Single() }).ToArray();
            var expectedAttributeTypesAndCtorArgs =
                new[]
            {
                new { Type = typeof(InheritableNonMultipleAttribute), Arg = "derived" },
                new { Type = typeof(InheritableAllowMultipleAttribute), Arg = "base" },
                new { Type = typeof(InheritableAllowMultipleAttribute), Arg = "derived" }
            };

            Assert.That(attributeTypesAndCtorArgs, Is.EquivalentTo(expectedAttributeTypesAndCtorArgs));
        }
Exemple #11
0
 public void GetMember_Static_InvalidExpression()
 {
     NormalizingMemberInfoFromExpressionUtility.GetMember(() => 1);
 }
Exemple #12
0
 public void GetMember_Instance_InvalidExpression()
 {
     NormalizingMemberInfoFromExpressionUtility.GetMember((DomainType obj) => 1);
 }
Exemple #13
0
        private FetchOneRequest CreateFetchOneRequest <TSource, TDest> (Expression <Func <TSource, TDest> > memberExpression)
        {
            var relationMember = NormalizingMemberInfoFromExpressionUtility.GetMember(memberExpression);

            return(new FetchOneRequest(relationMember));
        }