コード例 #1
0
        public void CanCompareBaseObjects()
        {
            var comparer = new BaseObjectEqualityComparer<BaseObject>();

            var object1 = new ConcreteBaseObject { Name = "Whatever" };
            var object2 = new ConcreteBaseObject { Name = "Whatever" };
            Assert.That(comparer.Equals(object1, object2));

            object2.Name = "Mismatch";
            Assert.That(comparer.Equals(object1, object2), Is.False);
        }
コード例 #2
0
        public void CannotSuccessfullyCompareDifferentlyTypedObjectsThatDeriveFromBaseObject() {
            BaseObjectEqualityComparer<BaseObject> comparer = new BaseObjectEqualityComparer<BaseObject>();

            ConcreteBaseObject object1 = new ConcreteBaseObject() {
                Name = "Whatever"
            };
            ConcreteValueObject object2 = new ConcreteValueObject() {
                Name = "Whatever"
            };

            Assert.That(comparer.Equals(object1, object2), Is.False);
        }
        public void CannotSuccessfullyCompareDifferentlyTypedObjectsThatDeriveFromBaseObject()
        {
            var comparer = new BaseObjectEqualityComparer <BaseObject>();

            var object1 = new ConcreteBaseObject {
                Name = "Whatever"
            };
            var object2 = new ConcreteValueObject {
                Name = "Whatever"
            };

            Assert.That(comparer.Equals(object1, object2), Is.False);
        }
コード例 #4
0
        public void CannotSuccessfullyCompareDifferentlyTypedObjectsThatDeriveFromBaseObject()
        {
            var comparer = new BaseObjectEqualityComparer <BaseObject>();

            var obj1 = new ConcreteBaseObject {
                Name = "Whatever"
            };
            var obj2 = new ConcreteValueObject {
                Name = "Whatever"
            };

            comparer.Equals(obj1, obj2).Should().BeFalse();
        }
        public void CanCompareBaseObjects()
        {
            var comparer = new BaseObjectEqualityComparer <BaseObject>();

            var object1 = new ConcreteBaseObject {
                Name = "Whatever"
            };
            var object2 = new ConcreteBaseObject {
                Name = "Whatever"
            };

            Assert.That(comparer.Equals(object1, object2));

            object2.Name = "Mismatch";
            Assert.That(comparer.Equals(object1, object2), Is.False);
        }
コード例 #6
0
        public void CanCompareBaseObjects()
        {
            var comparer = new BaseObjectEqualityComparer <BaseObject>();

            var obj1 = new ConcreteBaseObject {
                Name = "Whatever"
            };
            var obj2 = new ConcreteBaseObject {
                Name = "Whatever"
            };

            comparer.Equals(obj1, obj2).Should().BeTrue();

            obj2.Name = "Mismatch";
            comparer.Equals(obj1, obj2).Should().BeFalse();
        }