public void CanBeUsedByLinqSetOperatorsSuchAsIntersect()
        {
            IList<ConcreteEntityWithDomainSignatureProperties> objects1 =
                new List<ConcreteEntityWithDomainSignatureProperties>();
            var object1 = new ConcreteEntityWithDomainSignatureProperties { Name = "Billy McCafferty", };
            EntityIdSetter.SetIdOf(object1, 2);
            objects1.Add(object1);

            IList<ConcreteEntityWithDomainSignatureProperties> objects2 =
                new List<ConcreteEntityWithDomainSignatureProperties>();
            var object2 = new ConcreteEntityWithDomainSignatureProperties { Name = "Jimi Hendrix", };
            EntityIdSetter.SetIdOf(object2, 1);
            objects2.Add(object2);
            var object3 = new ConcreteEntityWithDomainSignatureProperties
                {
                    Name =
                        "Doesn't Matter since the Id will match and the presedence of the domain signature will go overridden", 
                };
            EntityIdSetter.SetIdOf(object3, 2);
            objects2.Add(object3);

            Assert.That(
                objects1.Intersect(
                    objects2, new BaseObjectEqualityComparer<ConcreteEntityWithDomainSignatureProperties>()).Count(), 
                Is.EqualTo(1));
            Assert.AreEqual(
                objects1.Intersect(
                    objects2, new BaseObjectEqualityComparer<ConcreteEntityWithDomainSignatureProperties>()).First(), 
                object1);
            Assert.AreEqual(
                objects1.Intersect(
                    objects2, new BaseObjectEqualityComparer<ConcreteEntityWithDomainSignatureProperties>()).First(), 
                object3);
        }
        public void CanBeUsedByLinqSetOperatorsSuchAsIntersect()
        {
            IList <ConcreteEntityWithDomainSignatureProperties> objects1 = new List <ConcreteEntityWithDomainSignatureProperties>();
            ConcreteEntityWithDomainSignatureProperties         object1  = new ConcreteEntityWithDomainSignatureProperties()
            {
                Name = "Billy McCafferty",
            };

            EntityIdSetter.SetIdOf <int>(object1, 2);
            objects1.Add(object1);

            IList <ConcreteEntityWithDomainSignatureProperties> objects2 = new List <ConcreteEntityWithDomainSignatureProperties>();
            ConcreteEntityWithDomainSignatureProperties         object2  = new ConcreteEntityWithDomainSignatureProperties()
            {
                Name = "Jimi Hendrix",
            };

            EntityIdSetter.SetIdOf <int>(object2, 1);
            objects2.Add(object2);
            ConcreteEntityWithDomainSignatureProperties object3 = new ConcreteEntityWithDomainSignatureProperties()
            {
                Name = "Doesn't Matter since the Id will match and the presedence of the domain signature will go overridden",
            };

            EntityIdSetter.SetIdOf <int>(object3, 2);
            objects2.Add(object3);

            Assert.That(objects1.Intersect(objects2,
                                           new BaseObjectEqualityComparer <ConcreteEntityWithDomainSignatureProperties>()).Count(),
                        Is.EqualTo(1));
            Assert.AreEqual(objects1.Intersect(objects2,
                                               new BaseObjectEqualityComparer <ConcreteEntityWithDomainSignatureProperties>()).First(), object1);
            Assert.AreEqual(objects1.Intersect(objects2,
                                               new BaseObjectEqualityComparer <ConcreteEntityWithDomainSignatureProperties>()).First(), object3);
        }
        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 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));
        }
Exemplo n.º 5
0
        public void CanCompareEntitiesWithDomainSignatureProperties()
        {
            var comparer = new BaseObjectEqualityComparer <Entity <int> >();

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

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

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

            EntityIdSetter.SetIdOf(obj1, 1);
            EntityIdSetter.SetIdOf(obj2, 1);
            comparer.Equals(obj1, obj2).Should().BeTrue();
        }
Exemplo n.º 6
0
        public void CanBeUsedByLinqSetOperatorsSuchAsIntersect()
        {
            IList <ConcreteEntityWithDomainSignatureProperties> objects1 =
                new List <ConcreteEntityWithDomainSignatureProperties>();
            var obj1 = new ConcreteEntityWithDomainSignatureProperties {
                Name = @"Billy McCafferty"
            };

            EntityIdSetter.SetIdOf(obj1, 2);
            objects1.Add(obj1);

            IList <ConcreteEntityWithDomainSignatureProperties> objects2 =
                new List <ConcreteEntityWithDomainSignatureProperties>();
            var obj2 = new ConcreteEntityWithDomainSignatureProperties {
                Name = @"Jimi Hendrix"
            };

            EntityIdSetter.SetIdOf(obj2, 1);
            objects2.Add(obj2);
            var obj3 = new ConcreteEntityWithDomainSignatureProperties
            {
                Name =
                    "Doesn't Matter since the Id will match and the presence of the domain signature will go overridden"
            };

            EntityIdSetter.SetIdOf(obj3, 2);
            objects2.Add(obj3);

            objects1.Intersect(
                objects2, new BaseObjectEqualityComparer <ConcreteEntityWithDomainSignatureProperties>())
            .Should().HaveCount(1);

            objects1.Intersect(
                objects2, new BaseObjectEqualityComparer <ConcreteEntityWithDomainSignatureProperties>()).First()
            .Equals(obj1).Should().BeTrue();

            objects1.Intersect(
                objects2, new BaseObjectEqualityComparer <ConcreteEntityWithDomainSignatureProperties>()).First()
            .Equals(obj3).Should().BeTrue();
        }