Example #1
0
        public void TestInheritanceOuter()
        {
            Sample1 obj1 = new Sample1();
            Sample2 obj2 = new Sample2();

            EqualityHelper helper = new EqualityHelper(typeof(Sample1));

            helper.AddAllProperties();

            helper.ObjectEquals(obj1, obj2).Should().Be.True();

            obj1.IntProp = obj2.IntProp = 42;
            helper.ObjectEquals(obj1, obj2).Should().Be.True();
            helper.ObjectGetHashCode(obj2).Should().Be(helper.ObjectGetHashCode(obj1));

            obj1.StringProp = "A";
            helper.ObjectEquals(obj1, obj2).Should().Be.False();

            obj2.StringProp = "B";
            helper.ObjectEquals(obj1, obj2).Should().Be.False();

            obj1.StringProp = "B";
            helper.ObjectEquals(obj1, obj2).Should().Be.True();
            helper.ObjectGetHashCode(obj2).Should().Be(helper.ObjectGetHashCode(obj1));
        }