public void Test() { IMetadataRepository metadataRepository = new OldToNewMetadataRepository(RepositoryTestHelper.GetSourcePathForOracleTest(), new ConfigurationValues()); IDataSource dataSource = metadataRepository.DataSourceGet(); foreach (IContextDocument contextDocument in dataSource.ContextDocuments) { Debug.WriteLine(contextDocument.NameTarget); } Debug.WriteLine(string.Empty); Debug.WriteLine(string.Empty); foreach (IView view in dataSource.Views) { Debug.WriteLine(view.Description); Debug.WriteLine(view.SqlQuery); Debug.WriteLine(string.Empty); } }
public void TestThatDataSourceGetGetsDataSource() { var oldToNewMetadataRepository = new OldToNewMetadataRepository(RepositoryTestHelper.GetSourcePathForOracleTest(), GetConfigurationValuesMock(new Fixture())); Assert.That(oldToNewMetadataRepository, Is.Not.Null); var dataSource = oldToNewMetadataRepository.DataSourceGet(); Assert.That(dataSource, Is.Not.Null); Assert.That(dataSource.NameSource, Is.Not.Null); Assert.That(dataSource.NameSource, Is.Not.Empty); Assert.That(dataSource.NameSource, Is.EqualTo("Civil-, Straffe-, Foged-, Auktions- og Skiftesystem")); Assert.That(dataSource.NameTarget, Is.Not.Null); Assert.That(dataSource.NameTarget, Is.Not.Empty); Assert.That(dataSource.NameTarget, Is.EqualTo("Civil-, Straffe-, Foged-, Auktions- og Skiftesystem")); Assert.That(dataSource.Description, Is.Not.Null); Assert.That(dataSource.Description, Is.Not.Empty); Assert.That(dataSource.Description, Is.EqualTo("Civil-, Straffe-, Foged-, Auktions- og Skiftesystem")); Assert.That(dataSource.ArchiveInformationPackageId, Is.Not.Empty); Assert.That(dataSource.ArchiveInformationPackageId, Is.Not.Null); Assert.That(dataSource.ArchiveInformationPackageId, Is.EqualTo("12549")); Assert.That(dataSource.ArchiveInformationPackageIdPrevious, Is.EqualTo(10701)); Assert.That(dataSource.ArchivePeriodStart, Is.EqualTo(new DateTime(1994, 5, 24, 0, 0, 0))); Assert.That(dataSource.ArchivePeriodEnd, Is.EqualTo(new DateTime(2009, 6, 30, 0, 0, 0))); Assert.That(dataSource.Creators, Is.Not.Null); Assert.That(dataSource.Creators.Count, Is.EqualTo(1)); Assert.That(dataSource.Creators.ElementAt(0).NameSource, Is.Not.Null); Assert.That(dataSource.Creators.ElementAt(0).NameSource, Is.Not.Empty); Assert.That(dataSource.Creators.ElementAt(0).NameSource, Is.EqualTo("Retten i Åbenrå (retskreds 43)")); Assert.That(dataSource.Creators.ElementAt(0).NameTarget, Is.Not.Null); Assert.That(dataSource.Creators.ElementAt(0).NameTarget, Is.Not.Empty); Assert.That(dataSource.Creators.ElementAt(0).NameTarget, Is.EqualTo("Retten i Åbenrå (retskreds 43)")); Assert.That(dataSource.Creators.ElementAt(0).Description, Is.Null); Assert.That(dataSource.Creators.ElementAt(0).PeriodStart, Is.EqualTo(dataSource.ArchivePeriodStart)); Assert.That(dataSource.Creators.ElementAt(0).PeriodEnd, Is.EqualTo(dataSource.ArchivePeriodEnd)); Assert.That(dataSource.Tables, Is.Not.Null); Assert.That(dataSource.Tables.Count, Is.EqualTo(54)); Assert.That(dataSource.ContextDocuments, Is.Not.Null); Assert.That(dataSource.ContextDocuments.Count, Is.EqualTo(5)); }
private IDeliveryEngine CreateSut(bool useDataValidators, IExceptionHandler exceptionHandler) { if (exceptionHandler == null) { throw new ArgumentNullException(nameof(exceptionHandler)); } IContainer containerMock = MockRepository.GenerateMock <IContainer>(); IInformationLogger informationLoggerMock = MockRepository.GenerateMock <IInformationLogger>(); informationLoggerMock.Expect(m => m.LogInformation(Arg <string> .Is.NotNull)) .WhenCalled(e => Debug.WriteLine(e.Arguments.ElementAt(0))) .Repeat.Any(); informationLoggerMock.Expect(m => m.LogWarning(Arg <string> .Is.NotNull)) .WhenCalled(e => Debug.WriteLine(e.Arguments.ElementAt(0))) .Repeat.Any(); IConfigurationRepository configurationRepositoryMock = MockRepository.GenerateMock <IConfigurationRepository>(); IMetadataRepository metadataRepository = new OldToNewMetadataRepository(RepositoryTestHelper.GetSourcePathForOracleTest(), new ConfigurationValues()); containerMock.Expect(m => m.Resolve <IMetadataRepository>()) .Return(metadataRepository) .Repeat.Any(); ICollection <IDataManipulator> dataManipulatorCollection; using (var windsorContainer = new WindsorContainer()) { windsorContainer.Register(Component.For <IContainer>().Instance(containerMock).LifeStyle.Transient); windsorContainer.Register(Component.For <IInformationLogger>().Instance(informationLoggerMock).LifeStyle.Transient); windsorContainer.Register(Component.For <IMetadataRepository>().Instance(metadataRepository).LifeStyle.Transient); IConfigurationProvider dataManipulatorsConfigurationProvider = new DataManipulatorsConfigurationProvider(); dataManipulatorsConfigurationProvider.AddConfiguration(windsorContainer); dataManipulatorCollection = windsorContainer.ResolveAll <IDataManipulator>(); windsorContainer.Dispose(); } containerMock.Expect(m => m.ResolveAll <IDataManipulator>()) .Return(dataManipulatorCollection.ToArray()) .Repeat.Any(); IDataRepository dataRepository = new OracleDataRepository(new OracleClientFactory(), new DataManipulators(containerMock)); containerMock.Expect(m => m.Resolve <IDataRepository>()) .Return(dataRepository) .Repeat.Any(); IDocumentRepository documentRepositoryMock = MockRepository.GenerateMock <IDocumentRepository>(); IArchiveVersionRepository archiveRepository = new ArchiveVersionRepository(new DirectoryInfo(ConfigurationManager.AppSettings["ArchivePath"])); ICollection <IDataValidator> dataValidatorCollection = useDataValidators ? new Collection <IDataValidator> { new PrimaryKeyDataValidator(dataRepository), new ForeignKeysDataValidator(dataRepository), new MappingDataValidator() } : new Collection <IDataValidator>(); containerMock.Expect(m => m.ResolveAll <IDataValidator>()) .Return(dataValidatorCollection.ToArray()) .Repeat.Any(); IDataValidators dataValidators = new DataValidators(containerMock); return(new DeliveryEngine.BusinessLogic.DeliveryEngine(configurationRepositoryMock, metadataRepository, dataRepository, documentRepositoryMock, dataValidators, archiveRepository, exceptionHandler)); }
public void TestThatConstructorThrowsArgumentNullExceptionIfConfigurationValuesIsNull() { Assert.Throws <ArgumentNullException>(() => new OldToNewMetadataRepository(RepositoryTestHelper.GetSourcePathForOracleTest(), null)); }
public void TestThatConstructorInitializeOldToNewMetadataRepository() { var oldToNewMetadataRepository = new OldToNewMetadataRepository(RepositoryTestHelper.GetSourcePathForOracleTest(), MockRepository.GenerateMock <IConfigurationValues>()); Assert.That(oldToNewMetadataRepository, Is.Not.Null); }
public void TestThatDataRepositoryGetsDataFromOracle() { var containerMock = MockRepository.GenerateMock <IContainer>(); var informationLoggerMock = MockRepository.GenerateMock <IInformationLogger>(); informationLoggerMock.Expect(m => m.LogInformation(Arg <string> .Is.NotNull)) .WhenCalled(e => Debug.WriteLine(e.Arguments[0])) .Repeat.Any(); var metadataRepository = new OldToNewMetadataRepository(RepositoryTestHelper.GetSourcePathForOracleTest(), new ConfigurationValues()); Assert.That(metadataRepository, Is.Not.Null); ICollection <IDataManipulator> dataMainpulatorCollection; using (var windsorContainer = new WindsorContainer()) { windsorContainer.Register(Component.For <IContainer>().Instance(containerMock).LifeStyle.Transient); windsorContainer.Register(Component.For <IInformationLogger>().Instance(informationLoggerMock).LifeStyle.Transient); windsorContainer.Register(Component.For <IMetadataRepository>().Instance(metadataRepository).LifeStyle.Transient); var dataManipulatorsConfigurationProvider = new DataManipulatorsConfigurationProvider(); dataManipulatorsConfigurationProvider.AddConfiguration(windsorContainer); dataMainpulatorCollection = windsorContainer.ResolveAll <IDataManipulator>(); windsorContainer.Dispose(); } containerMock.Expect(m => m.ResolveAll <IDataManipulator>()) .Return(dataMainpulatorCollection.ToArray()) .Repeat.Any(); var oracleClientFactory = new OracleClientFactory(); Assert.That(oracleClientFactory, Is.Not.Null); var dataManipulators = new DataManipulators(containerMock); Assert.That(dataManipulators, Is.Not.Null); Assert.That(dataManipulators, Is.Not.Empty); var dataRepository = new OracleDataRepository(oracleClientFactory, dataManipulators); Assert.That(dataRepository, Is.Not.Null); containerMock.Expect(m => m.Resolve <IDataRepository>()) .Return(dataRepository) .Repeat.Any(); var startTime = DateTime.MinValue; var numberOfRecords = 0; dataRepository.OnHandleData += (s, e) => { Assert.That(s, Is.Not.Null); Assert.That(e, Is.Not.Null); Assert.That(e.Table, Is.Not.Null); Assert.That(e.Data, Is.Not.Null); numberOfRecords += e.Data.Count(); if (e.EndOfData) { // ReSharper disable AccessToModifiedClosure Debug.WriteLine("{0} has been selected for the table named {1} in {2}", numberOfRecords, e.Table.NameTarget, new TimeSpan(DateTime.Now.Ticks - startTime.Ticks)); // ReSharper restore AccessToModifiedClosure numberOfRecords = 0; } }; var dataSource = metadataRepository.DataSourceGet(); Assert.That(dataSource, Is.Not.Null); Assert.That(dataSource.Tables, Is.Not.Null); Assert.That(dataSource.Tables, Is.Not.Empty); foreach (var table in dataSource.Tables) { startTime = DateTime.Now; dataRepository.DataGetFromTable(table); } }