private IValueObjectProcessor Create(ValueObjectMetadata <TValueObject, TEntityKey> metadata)
 {
     return(new ValueObjectProcessor <TValueObject>(
                new DataChangesDetector <TValueObject>(
                    metadata.MapSpecificationProviderForSource,
                    metadata.MapSpecificationProviderForTarget,
                    _comparerFactory.CreateCompleteComparer <TValueObject>(),
                    _query),
                _repositoryFactory.Create <TValueObject>(),
                new ValueObjectFindSpecificationProvider <TValueObject, TEntityKey>(metadata)));
 }
        public void GetHashCodeShouldBeEqaulToResharperGenerated(int id, int? nullable, string name)
        {
            var provider = new Mock<IObjectPropertyProvider>();
            var props = typeof(SampleEntity).GetProperties();
            provider.Setup(x => x.GetProperties<SampleEntity>()).Returns(props);
            provider.Setup(x => x.GetPrimaryKeyProperties<SampleEntity>()).Returns(new List<PropertyInfo>());

            var factory = new EqualityComparerFactory(provider.Object);
            var comparer = factory.CreateCompleteComparer<SampleEntity>();

            var left = new SampleEntity { Id = id, NullableId = nullable, Name = name };

            Assert.That(comparer.GetHashCode(left), Is.EqualTo(left.GetHashCode()));
        }
Exemple #3
0
        public void GetHashCodeShouldBeEqaulToResharperGenerated(int id, int?nullable, string name)
        {
            var provider = new Mock <IObjectPropertyProvider>();
            var props    = typeof(SampleEntity).GetProperties();

            provider.Setup(x => x.GetProperties <SampleEntity>()).Returns(props);
            provider.Setup(x => x.GetPrimaryKeyProperties <SampleEntity>()).Returns(new List <PropertyInfo>());

            var factory  = new EqualityComparerFactory(provider.Object);
            var comparer = factory.CreateCompleteComparer <SampleEntity>();

            var left = new SampleEntity {
                Id = id, NullableId = nullable, Name = name
            };

            Assert.That(comparer.GetHashCode(left), Is.EqualTo(left.GetHashCode()));
        }
        public void EqualityShouldRespectProvidedComparers(int idLeft, int idRight, bool expected)
        {
            var provider = new Mock <IObjectPropertyProvider>();
            var props    = typeof(SampleEntity).GetProperties();

            provider.Setup(x => x.GetProperties <SampleEntity>()).Returns(props);
            provider.Setup(x => x.GetPrimaryKeyProperties <SampleEntity>()).Returns(new List <PropertyInfo>());

            var factory  = new EqualityComparerFactory(provider.Object, new CustomIntegerComparer());
            var comparer = factory.CreateCompleteComparer <SampleEntity>();

            var left = new SampleEntity {
                Id = idLeft
            };
            var right = new SampleEntity {
                Id = idRight
            };

            Assert.AreEqual(expected, comparer.GetHashCode(left) == comparer.GetHashCode(right));
            Assert.AreEqual(expected, comparer.Equals(left, right));
        }