Esempio n. 1
0
        public void DatabaseComparison(Type dataObjectType, StorageDescriptor sourceDescriptor, StorageDescriptor destDescriptor)
        {
            var detector = ChangeDetector.Create(dataObjectType);
            var changes  = detector.ProcessTwice(sourceDescriptor, destDescriptor);

            Assert.That(AsJson(changes.SourceOnly), Is.Empty, "Extra items in Source");
            Assert.That(AsJson(changes.DestOnly), Is.Empty, "Extra items in Dest");
            Assert.That(AsJson(changes.SourceChanged), Is.EquivalentTo(AsJson(changes.DestChanged)), "Items changed in Source and Dest");
        }
Esempio n. 2
0
 private EntityChanges <T> Process(StorageDescriptor sourceDescriptor, StorageDescriptor destDescriptor)
 {
     using (var source = new DataConnection(sourceDescriptor.ConnectionStringName).AddMappingSchema(sourceDescriptor.MappingSchema))
         using (var dest = new DataConnection(destDescriptor.ConnectionStringName).AddMappingSchema(destDescriptor.MappingSchema))
         {
             var accessorTypes   = TypeProvider.GetAccessorTypes(destDescriptor.MappingSchema, typeof(T));
             var completeChanges = new EntityChanges <T>(_objectReader.ReadSource(source, accessorTypes), _objectReader.ReadDest(dest), CompleteComparer);
             var changes         = new EntityChanges <T>(completeChanges.SourceOnly, completeChanges.DestOnly, IdentityComparer);
             return(changes);
         }
 }
Esempio n. 3
0
            public override EntityChangesDto ProcessTwice(StorageDescriptor sourceDescriptor, StorageDescriptor destDescriptor)
            {
                var changes1 = Process(sourceDescriptor, destDescriptor);

                Thread.Sleep(WaitBetweenProcess);
                var changes2 = Process(sourceDescriptor, destDescriptor);

                // SourceChanged => Intersect
                return(new EntityChangesDto
                {
                    SourceOnly = new EntityChanges <T>(changes1.SourceOnly, changes2.SourceOnly, IdentityComparer).SourceChanged,
                    DestOnly = new EntityChanges <T>(changes1.DestOnly, changes2.DestOnly, IdentityComparer).SourceChanged,
                    SourceChanged = new EntityChanges <T>(changes1.SourceChanged, changes2.SourceChanged, IdentityComparer).SourceChanged,
                    DestChanged = new EntityChanges <T>(changes1.DestChanged, changes2.DestChanged, IdentityComparer).SourceChanged
                });
            }
Esempio n. 4
0
 private static IEnumerable <TestCaseData> TestCaseDataFor(StorageDescriptor sourceDescriptor, StorageDescriptor destDescriptor)
 => TypeProvider.GetDataObjectTypes(destDescriptor.MappingSchema)
 .Where(x => !ExcludedTypes.Contains(x))
 .Select(x => new TestCaseData(x, sourceDescriptor, destDescriptor)
         .SetName(TestName(x)));
Esempio n. 5
0
 public abstract EntityChangesDto ProcessTwice(StorageDescriptor sourceDescriptor, StorageDescriptor destDescriptor);
Esempio n. 6
0
 private static IEnumerable <TestCaseData> TestCaseDataFor(StorageDescriptor sourceDescriptor, StorageDescriptor destDescriptor)
 => TypeProvider.GetDataObjectTypes(destDescriptor.MappingSchema)
 //.Where(x => x == typeof(NuClear.ValidationRules.Storage.Model.Facts.Position))
 .Select(x => new TestCaseData(x, sourceDescriptor, destDescriptor)
         .SetName($"{destDescriptor.ConnectionStringName}.{x.Name}"));