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);
        }
        public void CanCompareEntitiesWithDomainSignatureProperties()
        {
            var comparer = new BaseObjectEqualityComparer<Entity>();

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

            object2.Name = "Mismatch";
            Assert.That(comparer.Equals(object1, object2), Is.False);

            EntityIdSetter.SetIdOf(object1, 1);
            EntityIdSetter.SetIdOf(object2, 1);
            Assert.That(comparer.Equals(object1, object2));
        }
        public void CanCompareEntitiesWithNoDomainSignatureProperties() {
            BaseObjectEqualityComparer<BaseObject> comparer = new BaseObjectEqualityComparer<BaseObject>();

            ConcreteEntityWithNoDomainSignatureProperties object1 = new ConcreteEntityWithNoDomainSignatureProperties() {
                Name = "Whatever"
            };
            ConcreteEntityWithNoDomainSignatureProperties object2 = new ConcreteEntityWithNoDomainSignatureProperties() {
                Name = "asdf"
            };
            Assert.That(comparer.Equals(object1, object2), Is.False);

            EntityIdSetter.SetIdOf<int>(object1, 1);
            EntityIdSetter.SetIdOf<int>(object2, 1);
            Assert.That(comparer.Equals(object1, object2));
        }
Beispiel #4
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);
        }
        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();
        }
        public void CanCompareEntitiesWithNoDomainSignatureProperties()
        {
            var comparer = new BaseObjectEqualityComparer <BaseObject>();

            var object1 = new ConcreteEntityWithNoDomainSignatureProperties {
                Name = "Whatever"
            };
            var object2 = new ConcreteEntityWithNoDomainSignatureProperties {
                Name = @"asdf"
            };

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

            EntityIdSetter.SetIdOf(object1, 1);
            EntityIdSetter.SetIdOf(object2, 1);
            Assert.That(comparer.Equals(object1, object2));
        }
Beispiel #7
0
        public void CanCompareEntitiesWithNoDomainSignatureProperties()
        {
            var comparer = new BaseObjectEqualityComparer <BaseObject>();

            var obj1 = new ConcreteEntityWithNoDomainSignatureProperties {
                Name = "Whatever"
            };
            var obj2 = new ConcreteEntityWithNoDomainSignatureProperties {
                Name = @"asdf"
            };

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

            EntityIdSetter.SetIdOf(obj1, 1);
            EntityIdSetter.SetIdOf(obj2, 1);
            comparer.Equals(obj1, obj2).Should().BeTrue();
        }
        public void CanCompareEntitiesWithDomainSignatureProperties()
        {
            var comparer = new BaseObjectEqualityComparer <EntityWithTypedId <int> >();

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

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

            object2.Name = "Mismatch";
            Assert.That(comparer.Equals(object1, object2), Is.False);

            EntityIdSetter.SetIdOf(object1, 1);
            EntityIdSetter.SetIdOf(object2, 1);
            Assert.That(comparer.Equals(object1, object2));
        }
        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);
        }
Beispiel #11
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 CanCompareNulls()
 {
     var comparer = new BaseObjectEqualityComparer<BaseObject>();
     Assert.That(comparer.Equals(null, null));
     Assert.That(comparer.Equals(null, new ConcreteBaseObject()), Is.False);
     Assert.That(comparer.Equals(new ConcreteBaseObject(), null), Is.False);
 }
        public void CanCompareEntitiesWithNoDomainSignatureProperties()
        {
            var comparer = new BaseObjectEqualityComparer<BaseObject>();

            var object1 = new ConcreteEntityWithNoDomainSignatureProperties
                              {
                                  Name = "Whatever"
                              };
            var object2 = new ConcreteEntityWithNoDomainSignatureProperties
                              {
                                  Name = "asdf"
                              };
            Assert.IsFalse(comparer.Equals(object1, object2));

            EntityIdSetter.SetIdOf(object1, 1);
            EntityIdSetter.SetIdOf(object2, 1);
            Assert.IsTrue(comparer.Equals(object1, object2));
        }
        public void CanCompareNulls()
        {
            var comparer = new BaseObjectEqualityComparer<BaseObject>();

            Assert.IsTrue(comparer.Equals(null, null));
            Assert.IsFalse(comparer.Equals(null, new ConcreteBaseObject()));
            Assert.IsFalse(comparer.Equals(new ConcreteBaseObject(), null));
        }