예제 #1
0
        public void ImplementingIEquatableOnABaseClassOrInterfaceThroughInterface()
        {
            IEquatableObject obj1 = new InheritedEquatableObject {
                SomeProperty = 1
            };
            IEquatableObject obj2 = new InheritedEquatableObject {
                SomeProperty = 1
            };

            var n         = new NUnitEqualityComparer();
            var tolerance = Tolerance.Exact;

            Assert.That(n.AreEqual(obj1, obj2, ref tolerance), Is.True);
            Assert.That(n.AreEqual(obj2, obj1, ref tolerance), Is.True);
        }
예제 #2
0
        public void CanHandleMultipleImplementationsOfIEquatable()
        {
            IEquatableObject obj1 = new InheritedEquatableObject {
                SomeProperty = 1
            };
            IEquatableObject obj2 = new MultipleIEquatables {
                SomeProperty = 1
            };
            var obj3 = new EquatableObject {
                SomeProperty = 1
            };

            var n         = new NUnitEqualityComparer();
            var tolerance = Tolerance.Exact;

            Assert.That(n.AreEqual(obj1, obj2, ref tolerance), Is.True);
            Assert.That(n.AreEqual(obj2, obj1, ref tolerance), Is.True);
            Assert.That(n.AreEqual(obj1, obj3, ref tolerance), Is.False);
            Assert.That(n.AreEqual(obj3, obj1, ref tolerance), Is.False);
            Assert.That(n.AreEqual(obj2, obj3, ref tolerance), Is.True);
            Assert.That(n.AreEqual(obj3, obj2, ref tolerance), Is.True);
        }