Exemplo n.º 1
0
        public void TestBasicTypesEqualityOuterUsingPrivateFields()
        {
            Sample5 obj1 = new Sample5();
            Sample5 obj2 = new Sample5();

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

            helper.Add("IntProp").Add("StringProp");

            helper.ObjectEquals(obj1, obj2).Should().Be.True();
        }
Exemplo n.º 2
0
        public void TestBasicTypesEqualityOuterUsingPrivateProperties()
        {
            Sample4 obj1 = new Sample4();
            Sample4 obj2 = new Sample4();

            EqualityHelper helper = new EqualityHelper <Sample4>();

            helper.Add("IntProp").Add("StringProp");

            helper.ObjectEquals(obj1, obj2).Should().Be.True();
        }
Exemplo n.º 3
0
        public void TestBasicTypesEqualityOuterWithCustomComparer()
        {
            Sample1 obj1 = new Sample1();
            Sample1 obj2 = new Sample1();

            var helper = new EqualityHelper <Sample1>();

            helper.Add(x => x.StringProp, StringComparer.InvariantCultureIgnoreCase);

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

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

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

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