public void GetHashCode_should_use_custom_logic_for_generic_type()
        {
            var instance = new CustomGenericEquals <int>();

            instance.Prop = 1;

            var result = instance.GetHashCode();

            Assert.Equal(42, result);
        }
        public void Equals_should_use_custom_logic_for_generic_type()
        {
            var first = new CustomGenericEquals <int>();

            first.Prop = 1;
            var second = new CustomGenericEquals <int>();

            second.Prop = 1;
            var third = new CustomGenericEquals <int>();

            third.Prop = 2;

            Assert.True(first.Equals(second));
            Assert.False(first.Equals(third));
            Assert.True(first.CustomCalled);
        }
Esempio n. 3
0
 bool Custom(CustomGenericEquals <T> other)
 {
     return(Equals(Prop, other.Prop));
 }
 bool CustomEquals(CustomGenericEquals <T> other)
 {
     this.CustomCalled = true;
     return(Equals(Prop, other.Prop));
 }