コード例 #1
0
        public void Equals_should_ignore_properties_in_base_class_when_class_is_marked()
        {
            var instance = new IgnoreBaseClass();

            instance.A = 1;
            instance.B = 2;

            var instance2 = new IgnoreBaseClass();

            instance2.A = 3;
            instance2.B = 2;

            var result = instance.Equals(instance2);

            Assert.True(result);
        }
        public void GetHashCode_should_ignore_properties_in_base_class_when_class_is_marked()
        {
            var instance = new IgnoreBaseClass();

            instance.A = 1;
            instance.B = 2;

            var instance2 = new IgnoreBaseClass();

            instance2.A = 3;
            instance2.B = 2;

            var first  = instance.GetHashCode();
            var second = instance2.GetHashCode();

            Assert.Equal(first, second);
        }