コード例 #1
0
        public void Compares_collections()
        {
            var x = new[]
            {
                new C {
                    a = 42, b = "123"
                },
                new C {
                    a = 142, b = "123"
                },
            };

            var y = new[]
            {
                new C {
                    a = 42, b = "12344"
                },
                new C {
                    a = 142, b = "12344"
                },
            };

            var comparer = new HarshRecursiveEqualityComparer();

            comparer.AddProperty <C>(c => c.a);

            Assert.True(comparer.Equals(x, y));

            comparer.AddProperty <C>(c => c.b);
            Assert.False(comparer.Equals(x, y));
        }
コード例 #2
0
        public void Compares_simple_objects()
        {
            var x = new C {
                a = 42, b = "123"
            };
            var y = new C {
                a = 32, b = "123"
            };

            var comparer = new HarshRecursiveEqualityComparer();

            comparer.AddProperty <C>(c => c.b);

            Assert.True(comparer.Equals(x, y));

            comparer.AddProperty <C>(c => c.a);
            Assert.False(comparer.Equals(x, y));
        }