public override bool Equals(object o)
            {
                if (o == this)
                {
                    return(true);
                }
                if (!(o is TestSubObject))
                {
                    return(false);
                }
                TestSubObject rhs = (TestSubObject)o;

                return(base.Equals(o) && (b == rhs.b));
            }
        public void testReflectionHierarchyEquals(bool testTransients)
        {
            TestObject         to1     = new TestObject(4);
            TestObject         to1Bis  = new TestObject(4);
            TestObject         to1Ter  = new TestObject(4);
            TestObject         to2     = new TestObject(5);
            TestEmptySubObject teso    = new TestEmptySubObject(4);
            TestTSubObject     ttso    = new TestTSubObject(4, 1);
            TestTTSubObject    tttso   = new TestTTSubObject(4, 1, 2);
            TestTTLeafObject   ttlo    = new TestTTLeafObject(4, 1, 2, 3);
            TestSubObject      tso1    = new TestSubObject(1, 4);
            TestSubObject      tso1bis = new TestSubObject(1, 4);
            TestSubObject      tso1ter = new TestSubObject(1, 4);
            TestSubObject      tso2    = new TestSubObject(2, 5);

            testReflectionEqualsEquivalenceRelationship(to1, to1Bis, to1Ter, to2, new TestObject(), testTransients);
            testReflectionEqualsEquivalenceRelationship(tso1, tso1bis, tso1ter, tso2, new TestSubObject(),
                                                        testTransients);

            // More sanity checks:

            // same values
            Assert.IsTrue(EqualsBuilder.ReflectionEquals(ttlo, ttlo, testTransients));
            Assert.IsTrue(EqualsBuilder.ReflectionEquals(new TestSubObject(1, 10), new TestSubObject(1, 10),
                                                         testTransients));
            // same super values, diff sub values
            Assert.IsTrue(
                !EqualsBuilder.ReflectionEquals(new TestSubObject(1, 10), new TestSubObject(1, 11), testTransients));
            Assert.IsTrue(
                !EqualsBuilder.ReflectionEquals(new TestSubObject(1, 11), new TestSubObject(1, 10), testTransients));
            // diff super values, same sub values
            Assert.IsTrue(
                !EqualsBuilder.ReflectionEquals(new TestSubObject(0, 10), new TestSubObject(1, 10), testTransients));
            Assert.IsTrue(
                !EqualsBuilder.ReflectionEquals(new TestSubObject(1, 10), new TestSubObject(0, 10), testTransients));

            // mix super and sub types: equals
            Assert.IsTrue(EqualsBuilder.ReflectionEquals(to1, teso, testTransients));
            Assert.IsTrue(EqualsBuilder.ReflectionEquals(teso, to1, testTransients));

            Assert.IsTrue(EqualsBuilder.ReflectionEquals(to1, ttso, false));
            // Force testTransients = false for this assert
            Assert.IsTrue(EqualsBuilder.ReflectionEquals(ttso, to1, false));
            // Force testTransients = false for this assert

            Assert.IsTrue(EqualsBuilder.ReflectionEquals(to1, tttso, false));
            // Force testTransients = false for this assert
            Assert.IsTrue(EqualsBuilder.ReflectionEquals(tttso, to1, false));
            // Force testTransients = false for this assert

            Assert.IsTrue(EqualsBuilder.ReflectionEquals(ttso, tttso, false));
            // Force testTransients = false for this assert
            Assert.IsTrue(EqualsBuilder.ReflectionEquals(tttso, ttso, false));
            // Force testTransients = false for this assert

            // mix super and sub types: NOT equals
            Assert.IsTrue(!EqualsBuilder.ReflectionEquals(new TestObject(0), new TestEmptySubObject(1), testTransients));
            Assert.IsTrue(!EqualsBuilder.ReflectionEquals(new TestEmptySubObject(1), new TestObject(0), testTransients));

            Assert.IsTrue(!EqualsBuilder.ReflectionEquals(new TestObject(0), new TestTSubObject(1, 1), testTransients));
            Assert.IsTrue(!EqualsBuilder.ReflectionEquals(new TestTSubObject(1, 1), new TestObject(0), testTransients));

            Assert.IsTrue(!EqualsBuilder.ReflectionEquals(new TestObject(1), new TestSubObject(0, 10), testTransients));
            Assert.IsTrue(!EqualsBuilder.ReflectionEquals(new TestSubObject(0, 10), new TestObject(1), testTransients));

            Assert.IsTrue(!EqualsBuilder.ReflectionEquals(to1, ttlo));
            Assert.IsTrue(!EqualsBuilder.ReflectionEquals(tso1, this));
        }
        public void testReflectionHierarchyEquals(bool testTransients)
        {
            TestObject to1 = new TestObject(4);
            TestObject to1Bis = new TestObject(4);
            TestObject to1Ter = new TestObject(4);
            TestObject to2 = new TestObject(5);
            TestEmptySubObject teso = new TestEmptySubObject(4);
            TestTSubObject ttso = new TestTSubObject(4, 1);
            TestTTSubObject tttso = new TestTTSubObject(4, 1, 2);
            TestTTLeafObject ttlo = new TestTTLeafObject(4, 1, 2, 3);
            TestSubObject tso1 = new TestSubObject(1, 4);
            TestSubObject tso1bis = new TestSubObject(1, 4);
            TestSubObject tso1ter = new TestSubObject(1, 4);
            TestSubObject tso2 = new TestSubObject(2, 5);

            testReflectionEqualsEquivalenceRelationship(to1, to1Bis, to1Ter, to2, new TestObject(), testTransients);
            testReflectionEqualsEquivalenceRelationship(tso1, tso1bis, tso1ter, tso2, new TestSubObject(),
                                                        testTransients);

            // More sanity checks:

            // same values
            Assert.IsTrue(EqualsBuilder.ReflectionEquals(ttlo, ttlo, testTransients));
            Assert.IsTrue(EqualsBuilder.ReflectionEquals(new TestSubObject(1, 10), new TestSubObject(1, 10),
                                                         testTransients));
            // same super values, diff sub values
            Assert.IsTrue(
                !EqualsBuilder.ReflectionEquals(new TestSubObject(1, 10), new TestSubObject(1, 11), testTransients));
            Assert.IsTrue(
                !EqualsBuilder.ReflectionEquals(new TestSubObject(1, 11), new TestSubObject(1, 10), testTransients));
            // diff super values, same sub values
            Assert.IsTrue(
                !EqualsBuilder.ReflectionEquals(new TestSubObject(0, 10), new TestSubObject(1, 10), testTransients));
            Assert.IsTrue(
                !EqualsBuilder.ReflectionEquals(new TestSubObject(1, 10), new TestSubObject(0, 10), testTransients));

            // mix super and sub types: equals
            Assert.IsTrue(EqualsBuilder.ReflectionEquals(to1, teso, testTransients));
            Assert.IsTrue(EqualsBuilder.ReflectionEquals(teso, to1, testTransients));

            Assert.IsTrue(EqualsBuilder.ReflectionEquals(to1, ttso, false));
            // Force testTransients = false for this assert
            Assert.IsTrue(EqualsBuilder.ReflectionEquals(ttso, to1, false));
            // Force testTransients = false for this assert

            Assert.IsTrue(EqualsBuilder.ReflectionEquals(to1, tttso, false));
            // Force testTransients = false for this assert
            Assert.IsTrue(EqualsBuilder.ReflectionEquals(tttso, to1, false));
            // Force testTransients = false for this assert

            Assert.IsTrue(EqualsBuilder.ReflectionEquals(ttso, tttso, false));
            // Force testTransients = false for this assert
            Assert.IsTrue(EqualsBuilder.ReflectionEquals(tttso, ttso, false));
            // Force testTransients = false for this assert

            // mix super and sub types: NOT equals
            Assert.IsTrue(!EqualsBuilder.ReflectionEquals(new TestObject(0), new TestEmptySubObject(1), testTransients));
            Assert.IsTrue(!EqualsBuilder.ReflectionEquals(new TestEmptySubObject(1), new TestObject(0), testTransients));

            Assert.IsTrue(!EqualsBuilder.ReflectionEquals(new TestObject(0), new TestTSubObject(1, 1), testTransients));
            Assert.IsTrue(!EqualsBuilder.ReflectionEquals(new TestTSubObject(1, 1), new TestObject(0), testTransients));

            Assert.IsTrue(!EqualsBuilder.ReflectionEquals(new TestObject(1), new TestSubObject(0, 10), testTransients));
            Assert.IsTrue(!EqualsBuilder.ReflectionEquals(new TestSubObject(0, 10), new TestObject(1), testTransients));

            Assert.IsTrue(!EqualsBuilder.ReflectionEquals(to1, ttlo));
            Assert.IsTrue(!EqualsBuilder.ReflectionEquals(tso1, this));
        }