コード例 #1
0
        public void MemberInfoComparer_EqualsExtension_Subclass()
        {
            var eq = new MyMemberComparer();

            var m = new MyMemberInfo();

            Assert.IsTrue(eq.Equals(m, m));
            Assert.AreEqual(42, eq.GetHashCode(m));
        }
コード例 #2
0
        public void MemberInfoComparer_ResolveMembers_Succeed()
        {
            var eq = new MyMemberComparer();

            var members = new[]
            {
                typeof(Foo).GetConstructor(new[] { typeof(int) }),
                typeof(Foo).GetEvent("Changed"),
                ReflectionHelpers.InfoOf((Foo foo) => foo.Field1),
                ReflectionHelpers.InfoOf((Foo foo) => foo.Property1),
                ReflectionHelpers.InfoOf((Foo foo) => foo.Method1()),
                typeof(Foo).GetNestedType("Bar"),
            };

            foreach (var member in members)
            {
                Assert.IsNotNull(eq.ResolveMember(typeof(Foo), member));
            }
        }