public void GatherAndShare_LoadMetadata_EmptyLoadMetadata() { //create an object LoadMetadata lmd = new LoadMetadata(Repository, "MyLmd"); var lmd2 = ShareToNewRepository(lmd); //different repos so not identical Assert.IsFalse(ReferenceEquals(lmd, lmd2)); Assert.AreEqual(lmd.Name, lmd2.Name); }
public ExecuteCommandOverrideRawServer(IActivateItems activator, LoadMetadata loadMetadata) : base(activator) { _loadMetadata = loadMetadata; _available = activator.CoreChildProvider.AllExternalServers.Where(s => string.IsNullOrWhiteSpace(s.CreatedByAssembly)).ToArray(); if (!_available.Any()) { SetImpossible("There are no compatible servers"); } }
public ExecuteCommandCreateNewClassBasedProcessTask(IBasicActivateItems activator, LoadMetadata loadMetadata, LoadStage loadStage, [DemandsInitialization("Class to execute, must be an attacher, mutilater etc", TypeOf = typeof(IDisposeAfterDataLoad))] Type type) : base(activator) { _loadMetadata = loadMetadata; _loadStage = loadStage; if (type != null) { SetType(type); } }
public void TypeOfTableInfo(bool declareAsInterface) { string tableInfoName = "TableInfoFor_" + new StackTrace().GetFrame(0).GetMethod().Name; TableInfo toCleanup = CatalogueRepository.GetAllObjects <TableInfo>().SingleOrDefault(t => t.Name.Equals(tableInfoName)); if (toCleanup != null) { toCleanup.DeleteInDatabase(); } var loadMetadata = new LoadMetadata(CatalogueRepository); try { var pt = new ProcessTask(CatalogueRepository, loadMetadata, LoadStage.AdjustStaging); var pta = new ProcessTaskArgument(CatalogueRepository, pt); if (declareAsInterface) { pta.SetType(typeof(ITableInfo)); } else { pta.SetType(typeof(TableInfo)); } var tableInfo = new TableInfo(CatalogueRepository, tableInfoName); try { pta.SetValue(tableInfo); pta.SaveToDatabase(); var newInstanceOfPTA = CatalogueRepository.GetObjectByID <ProcessTaskArgument>(pta.ID); Assert.AreEqual(newInstanceOfPTA.Value, pta.Value); TableInfo t1 = (TableInfo)pta.GetValueAsSystemType(); TableInfo t2 = (TableInfo)newInstanceOfPTA.GetValueAsSystemType(); Assert.AreEqual(t1.ID, t2.ID); } finally { tableInfo.DeleteInDatabase(); } } finally { loadMetadata.DeleteInDatabase(); } }
public ExecuteCommandAssociateCatalogueWithLoadMetadata(IActivateItems activator, LoadMetadata loadMetadata) : base(activator) { _loadMetadata = loadMetadata; _availableCatalogues = Activator.CoreChildProvider.AllCatalogues.Where(c => c.LoadMetadata_ID == null).ToArray(); //Ensure logging task is correct _otherCatalogues = _loadMetadata.GetAllCatalogues().ToArray(); if (!_availableCatalogues.Any()) { SetImpossible("There are no Catalogues that are not associated with another Load already"); } }
private void btnCreate_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(_catalogue.LoggingDataTask)) { MessageBox.Show("You must configure a logging task first"); return; } LoadMetadataCreatedIfAny = new LoadMetadata(Activator.RepositoryLocator.CatalogueRepository, tbLoadMetadataNameToCreate.Text); this.DialogResult = DialogResult.OK; this.Close(); }
public void SetupEditLoadMetadata(object sender, LoadMetadata loadMetadata) { if (!_windowManager.IsVisible(RDMPCollection.DataLoad)) { _windowManager.Create(RDMPCollection.DataLoad, DockState.DockLeft); } var diagram = (Control)_activator.Activate <LoadDiagramUI, LoadMetadata>(loadMetadata); ((DockContent)diagram.Parent).DockTo(_mainDockPanel, DockStyle.Right); _activator.Activate <ExecuteLoadMetadataUI, LoadMetadata>(loadMetadata); _activator.RequestItemEmphasis(this, new EmphasiseRequest(loadMetadata, int.MaxValue)); }
public DicomRelationalMapperQueueConsumer(IRDMPPlatformRepositoryServiceLocator repositoryLocator, LoadMetadata lmd, INameDatabasesAndTablesDuringLoads namer, DicomRelationalMapperOptions options) { _lmd = lmd; _repositoryLocator = repositoryLocator; DatabaseNamer = namer; _minimumBatchSize = options.MinimumBatchSize; _useInsertIntoForRawMigration = options.UseInsertIntoForRAWMigration; _retryOnFailureCount = options.RetryOnFailureCount; _retryDelayInSeconds = Math.Max(10, options.RetryDelayInSeconds); _maximumRunDelayInSeconds = new TimeSpan(0, 0, 0, options.MaximumRunDelayInSeconds <= 0 ? 15 : 0); StartDleRunnerTask(); }
private LoadMetadata ShareToNewRepository(LoadMetadata lmd) { var gatherer = new Gatherer(RepositoryLocator); Assert.IsTrue(gatherer.CanGatherDependencies(lmd)); var rootObj = gatherer.GatherDependencies(lmd); var sm = new ShareManager(RepositoryLocator, null); var shareDefinition = rootObj.ToShareDefinitionWithChildren(sm); var repo2 = new MemoryDataExportRepository(); var sm2 = new ShareManager(new RepositoryProvider(repo2)); return(sm2.ImportSharedObject(shareDefinition).OfType <LoadMetadata>().Single()); }
private void CreateCSVProcessTask(LoadMetadata lmd, TableInfo ti, string regex) { var pt = new ProcessTask(CatalogueRepository, lmd, LoadStage.Mounting); pt.Path = typeof(AnySeparatorFileAttacher).FullName; pt.ProcessTaskType = ProcessTaskType.Attacher; pt.Name = "Load " + ti.GetRuntimeName(); pt.SaveToDatabase(); pt.CreateArgumentsForClassIfNotExists <AnySeparatorFileAttacher>(); pt.SetArgumentValue("FilePattern", regex); pt.SetArgumentValue("Separator", ","); pt.SetArgumentValue("TableToLoad", ti); pt.Check(new ThrowImmediatelyCheckNotifier()); }
public override void SetDatabaseObject(IActivateItems activator, LoadMetadata databaseObject) { base.SetDatabaseObject(activator, databaseObject); ragSmiley1.Reset(); LoadMetadata = databaseObject; CommonFunctionality.Add(new ToolStripLabel("Filter:")); CommonFunctionality.Add(_tbFilterBox); CommonFunctionality.Add(_btnApplyFilter); CommonFunctionality.Add(new ToolStripSeparator()); CommonFunctionality.Add(new ToolStripLabel("Fetch:")); CommonFunctionality.Add(_tbToFetch); CommonFunctionality.Add(_btnFetch); }
public void up() { RepositoryLocator.CatalogueRepository.MEF.AddTypeToCatalogForTesting(typeof(TestDataWriter)); RepositoryLocator.CatalogueRepository.MEF.AddTypeToCatalogForTesting(typeof(TestDataInventor)); _lmd = new LoadMetadata(CatalogueRepository, "JobDateGenerationStrategyFactoryTestsIntegration"); _lp = new LoadProgress(CatalogueRepository, _lmd); _lp.DataLoadProgress = new DateTime(2001, 1, 1); _lp.SaveToDatabase(); _cp = new CacheProgress(CatalogueRepository, _lp); _server = new DiscoveredServer(new SqlConnectionStringBuilder("server=localhost;initial catalog=fish")); _factory = new JobDateGenerationStrategyFactory(new SingleLoadProgressSelectionStrategy(_lp)); }
public LoadMetadataMenu(RDMPContextMenuStripArgs args, LoadMetadata loadMetadata) : base(args, loadMetadata) { Add(new ExecuteCommandViewLoadMetadataLogs(_activator).SetTarget(loadMetadata)); Add(new ExecuteCommandViewLoadDiagram(_activator, loadMetadata)); Add(new ExecuteCommandEditLoadMetadataDescription(_activator, loadMetadata)); Add(new ExecuteCommandExportObjectsToFileUI(_activator, new IMapsDirectlyToDatabaseTable[] { loadMetadata })); Items.Add(new ToolStripSeparator()); Add(new ExecuteCommandOverrideRawServer(_activator, loadMetadata)); Add(new ExecuteCommandCreateNewLoadMetadata(_activator)); ReBrandActivateAs("Check and Execute", RDMPConcept.LoadMetadata, OverlayKind.Execute); }
public void CreateNewAndGetBackFromDatabase() { var loadMetadata = new LoadMetadata(CatalogueRepository); try { loadMetadata.LocationOfFlatFiles = "C:\\temp"; loadMetadata.SaveToDatabase(); var loadMetadataWithIdAfterwards = CatalogueRepository.GetObjectByID <LoadMetadata>(loadMetadata.ID); Assert.AreEqual(loadMetadataWithIdAfterwards.LocationOfFlatFiles, "C:\\temp"); } finally { loadMetadata.DeleteInDatabase(); } }
public void ConfirmLogs_With2CacheProgress_Throws() { var lmd1 = new LoadMetadata(CatalogueRepository, "MyLmd"); var cata = new Catalogue(CatalogueRepository, "myCata"); cata.LoadMetadata_ID = lmd1.ID; cata.LoggingDataTask = "B"; cata.SaveToDatabase(); var lmd2 = new LoadMetadata(CatalogueRepository, "MyLmd"); var cata2 = new Catalogue(CatalogueRepository, "myCata"); cata2.LoadMetadata_ID = lmd2.ID; cata2.LoggingDataTask = "A"; cata2.SaveToDatabase(); var lp1 = new LoadProgress(CatalogueRepository, lmd1); var lp2 = new LoadProgress(CatalogueRepository, lmd2); var cp1 = new CacheProgress(CatalogueRepository, lp1); var cp2 = new CacheProgress(CatalogueRepository, lp2); cp2.Name = "MyCoolCache"; cp2.SaveToDatabase(); var lm = new LogManager(cp1.GetDistinctLoggingDatabase()); lm.CreateNewLoggingTaskIfNotExists(cp1.GetDistinctLoggingTask()); // create a log entry for cp1 only var logEntry = lm.CreateDataLoadInfo(cp1.GetDistinctLoggingTask(), "pack o' cards", cp1.GetLoggingRunName(), null, true); // we mark it as completed successfully - this is a good, happy log entry logEntry.CloseAndMarkComplete(); // The first cache has logged success so should be happy var cmd1 = new ExecuteCommandConfirmLogs(new ThrowImmediatelyActivator(RepositoryLocator), cp1, null); Assert.DoesNotThrow(() => cmd1.Execute()); // The second cache has not logged any successes so should be unhappy var cmd2 = new ExecuteCommandConfirmLogs(new ThrowImmediatelyActivator(RepositoryLocator), cp2, null); var ex = Assert.Throws <LogsNotConfirmedException>(() => cmd2.Execute()); Assert.AreEqual("There are no log entries for MyCoolCache", ex.Message); }
public ExecuteCommandPacsFetch(IBasicActivateItems activator, string start, string end, string remoteAeUri, int remotePort, string remoteAeTitle, string localAeUri, int localPort, string localAeTitle, string outDir, int maxRetries) : base(activator) { var startDate = DateTime.Parse(start); var endDate = DateTime.Parse(end); // Make something that kinda looks like a valid DLE load var memory = new MemoryCatalogueRepository(); var lmd = new LoadMetadata(memory); var dir = Directory.CreateDirectory(outDir); var results = LoadDirectory.CreateDirectoryStructure(dir, "out", true); lmd.LocationOfFlatFiles = results.RootPath.FullName; lmd.SaveToDatabase(); var lp = new LoadProgress(memory, lmd); var cp = new CacheProgress(memory, lp); //Create the source component only and a valid request range to fetch _source = new PACSSource { RemoteAEUri = new Uri("http://" + remoteAeUri), RemoteAEPort = remotePort, RemoteAETitle = remoteAeTitle, LocalAEUri = new Uri("http://" + localAeUri), LocalAEPort = localPort, LocalAETitle = localAeTitle, TransferTimeOutInSeconds = 50000, Modality = "ALL", MaxRetries = maxRetries }; //<- rly? its not gonna pass without an http!? _request = new BackfillCacheFetchRequest(BasicActivator.RepositoryLocator.CatalogueRepository, startDate) { ChunkPeriod = endDate.Subtract(startDate), CacheProgress = cp }; //Initialize it _source.PreInitialize(BasicActivator.RepositoryLocator.CatalogueRepository, new ThrowImmediatelyDataLoadEventListener { WriteToConsole = true }); _source.PreInitialize(this, new ThrowImmediatelyDataLoadEventListener { WriteToConsole = true }); }
public void GatherAndShare_LoadMetadata_WithReferenceProcessTaskArgument() { //create an object LoadMetadata lmd1 = WhenIHaveA <LoadMetadata>(); //setup Reflection / MEF SetupMEF(); RuntimeTaskFactory f = new RuntimeTaskFactory(Repository); var stg = Mock.Of <IStageArgs>(x => x.LoadStage == LoadStage.Mounting && x.DbInfo == new DiscoveredServer(new SqlConnectionStringBuilder()).ExpectDatabase("d")); //create a single process task for the load var pt1 = new ProcessTask(Repository, lmd1, LoadStage.Mounting); pt1.ProcessTaskType = ProcessTaskType.MutilateDataTable; pt1.LoadStage = LoadStage.AdjustRaw; pt1.Path = typeof(SafePrimaryKeyCollisionResolverMutilation).FullName; pt1.SaveToDatabase(); //give it a reference to an (unshared) object (ColumnInfo) pt1.CreateArgumentsForClassIfNotExists(typeof(SafePrimaryKeyCollisionResolverMutilation)); var pta = pt1.ProcessTaskArguments.Single(pt => pt.Name == "ColumnToResolveOn"); pta.SetValue(WhenIHaveA <ColumnInfo>()); pta.SaveToDatabase(); //check that reflection can assemble the master ProcessTask MutilateDataTablesRuntimeTask t = (MutilateDataTablesRuntimeTask)f.Create(pt1, stg); Assert.IsNotNull(((SafePrimaryKeyCollisionResolverMutilation)t.MEFPluginClassInstance).ColumnToResolveOn); //share to the second repository (which won't have that ColumnInfo) var lmd2 = ShareToNewRepository(lmd1); //create a new reflection factory for the new repo RuntimeTaskFactory f2 = new RuntimeTaskFactory(lmd2.CatalogueRepository); lmd2.CatalogueRepository.MEF = MEF; //when we create the shared instance it should not have a valid value for ColumnInfo (since it wasn't - and shouldn't be shared) MutilateDataTablesRuntimeTask t2 = (MutilateDataTablesRuntimeTask)f2.Create(lmd2.ProcessTasks.Single(), stg); Assert.IsNull(((SafePrimaryKeyCollisionResolverMutilation)t2.MEFPluginClassInstance).ColumnToResolveOn); }
public void ConfirmLogs_NoEntries_Throws() { var lmd = new LoadMetadata(CatalogueRepository, "MyLmd"); var cata = new Catalogue(CatalogueRepository, "myCata"); cata.LoadMetadata_ID = lmd.ID; cata.LoggingDataTask = "GGG"; cata.SaveToDatabase(); var lm = new LogManager(lmd.GetDistinctLoggingDatabase()); lm.CreateNewLoggingTaskIfNotExists("GGG"); var cmd = new ExecuteCommandConfirmLogs(new ThrowImmediatelyActivator(RepositoryLocator), lmd); var ex = Assert.Throws <LogsNotConfirmedException>(() => cmd.Execute()); Assert.AreEqual("There are no log entries for MyLmd", ex.Message); }
public void Create(CatalogueRepository repository, DiscoveredDatabase database, ILoadDirectory directory) { TableInfo = new TableInfo(repository, "TestData") { Server = database.Server.Name, Database = database.GetRuntimeName() }; TableInfo.SaveToDatabase(); if (!string.IsNullOrWhiteSpace(database.Server.ExplicitUsernameIfAny)) { Credentials = new DataAccessCredentialsFactory(repository).Create(TableInfo, database.Server.ExplicitUsernameIfAny, database.Server.ExplicitPasswordIfAny, DataAccessContext.Any); } ColumnInfo = new ColumnInfo(repository, "Col1", "int", TableInfo) { IsPrimaryKey = true }; ColumnInfo.SaveToDatabase(); LoadMetadata = new LoadMetadata(repository, "HICLoadPipelineTests") { LocationOfFlatFiles = directory.RootPath.FullName }; LoadMetadata.SaveToDatabase(); Catalogue = new Catalogue(repository, "HICLoadPipelineTests") { LoggingDataTask = "Test", LoadMetadata_ID = LoadMetadata.ID }; Catalogue.SaveToDatabase(); var catalogueItem = new CatalogueItem(repository, Catalogue, "Test"); catalogueItem.SetColumnInfo(ColumnInfo); SetupLoadProcessTasks(repository); }
/// <summary> /// Runs the data load engine for the given <paramref name="lmd"/> /// </summary> /// <param name="lmd"></param> /// <param name="timeoutInMilliseconds"></param> /// <param name="checks">True to run the pre load checks with accept all proposed fixes</param> public void RunDLE(LoadMetadata lmd, int timeoutInMilliseconds, bool checks) { if (checks) { //Get DleRunner to run pre load checks (includes trigger creation etc) var checker = new DleRunner(new DleOptions() { LoadMetadata = lmd.ID, Command = CommandLineActivity.check }); checker.Run(RepositoryLocator, new ThrowImmediatelyDataLoadEventListener(), new AcceptAllCheckNotifier(), new GracefulCancellationToken()); } var runner = new DleRunner(new DleOptions() { LoadMetadata = lmd.ID, Command = CommandLineActivity.run }); runner.Run(RepositoryLocator, new ThrowImmediatelyDataLoadEventListener(), new ThrowImmediatelyCheckNotifier(), new GracefulCancellationToken()); }
public void TestExecuteCommandAssociateCatalogueWithLoadMetadata_Simple() { var cata1 = new Catalogue(RepositoryLocator.CatalogueRepository, "fff"); var cata2 = new Catalogue(RepositoryLocator.CatalogueRepository, "bbb"); Assert.IsNull(cata1.LoadMetadata); Assert.IsNull(cata2.LoadMetadata); var lmd = new LoadMetadata(RepositoryLocator.CatalogueRepository, "mylmd"); GetInvoker().ExecuteCommand(typeof(ExecuteCommandAssociateCatalogueWithLoadMetadata), new CommandLineObjectPicker(new[] { $"LoadMetadata:{lmd.ID}", "Catalogue:fff" }, GetActivator())); cata1.RevertToDatabaseState(); cata2.RevertToDatabaseState(); Assert.AreEqual(lmd.ID, cata1.LoadMetadata_ID); Assert.IsNull(cata2.LoadMetadata); }
public void TableInfoType_FetchAfterDelete_ReturnsNull() { string tableInfoName = "TableInfoFor_" + new StackTrace().GetFrame(0).GetMethod().Name; TableInfo toCleanup = CatalogueRepository.GetAllObjects <TableInfo>().SingleOrDefault(t => t.Name.Equals(tableInfoName)); if (toCleanup != null) { toCleanup.DeleteInDatabase(); } var lmd = new LoadMetadata(CatalogueRepository); try { var pt = new ProcessTask(CatalogueRepository, lmd, LoadStage.AdjustStaging); var pta = new ProcessTaskArgument(CatalogueRepository, pt); //Prepare to receive a TableInfo object pta.SetType(typeof(TableInfo)); var tableInfo = new TableInfo(CatalogueRepository, tableInfoName); //Heres the TableInfo object pta.SetValue(tableInfo); pta.SaveToDatabase(); //Lolz I just deleted it out of the database tableInfo.DeleteInDatabase(); //give the object back now please? - returns null because it's gone (new behaviour) Assert.IsNull(pta.GetValueAsSystemType()); //old behaviour /*var ex = Assert.Throws<KeyNotFoundException>(()=>pta.GetValueAsSystemType()); * StringAssert.Contains("Could not find TableInfo with ID",ex.Message);*/ } finally { lmd.DeleteInDatabase(); } }
protected override void SetUp() { base.SetUp(); Database = GetCleanedServer(FAnsi.DatabaseType.MicrosoftSQLServer); var rootFolder = new DirectoryInfo(TestContext.CurrentContext.TestDirectory); var subdir = rootFolder.CreateSubdirectory("TestsRequiringADle"); LoadDirectory = LoadDirectory.CreateDirectoryStructure(rootFolder, subdir.FullName, true); Clear(LoadDirectory); LiveTable = CreateDataset <Demography>(Database, 500, 5000, new Random(190)); LiveTable.CreatePrimaryKey(new DiscoveredColumn[] { LiveTable.DiscoverColumn("chi"), LiveTable.DiscoverColumn("dtCreated"), LiveTable.DiscoverColumn("hb_extract") }); TestCatalogue = Import(LiveTable); RowsBefore = 5000; TestLoadMetadata = new LoadMetadata(CatalogueRepository, "Loading Test Catalogue"); TestLoadMetadata.LocationOfFlatFiles = LoadDirectory.RootPath.FullName; TestLoadMetadata.SaveToDatabase(); //make the load load the table TestCatalogue.LoadMetadata_ID = TestLoadMetadata.ID; TestCatalogue.SaveToDatabase(); CreateFlatFileAttacher(TestLoadMetadata, "*.csv", TestCatalogue.GetTableInfoList(false).Single(), ","); //Get DleRunner to run pre load checks (includes trigger creation etc) var runner = new DleRunner(new DleOptions() { LoadMetadata = TestLoadMetadata.ID, Command = CommandLineActivity.check }); runner.Run(RepositoryLocator, new ThrowImmediatelyDataLoadEventListener(), new AcceptAllCheckNotifier(), new GracefulCancellationToken()); }
public override void SetDatabaseObject(IActivateItems activator, LoadMetadata databaseObject) { base.SetDatabaseObject(activator, databaseObject); _loadMetadata = databaseObject; checkAndExecuteUI1.SetItemActivator(activator); SetButtonStates(null, null); SetLoadProgressGroupBoxState(); CommonFunctionality.Add(new ExecuteCommandViewLoadDiagram(activator, _loadMetadata)); CommonFunctionality.AddToMenu(new ExecuteCommandEditLoadMetadataDescription(activator, _loadMetadata)); CommonFunctionality.Add(new ExecuteCommandViewLogs(activator, (LoadMetadata)databaseObject)); CommonFunctionality.Add(dd_DebugOptions); }
public void TestMemoryVsDatabaseRepository_ProcessTaskConstructor() { var memoryRepository = new MemoryCatalogueRepository(CatalogueRepository.GetServerDefaults()); var memLmd = new LoadMetadata(memoryRepository, "My New Load"); var dbLmd = new LoadMetadata(CatalogueRepository, "My New Load"); UnitTests.AssertAreEqual(memLmd, dbLmd); var memPt = new ProcessTask(memoryRepository, memLmd, LoadStage.AdjustRaw) { Name = "MyPt" }; var dbPt = new ProcessTask(CatalogueRepository, dbLmd, LoadStage.AdjustRaw) { Name = "MyPt" }; UnitTests.AssertAreEqual(memPt, dbPt); }
public void TestCreatingNamer_CorrectType(DatabaseType dbType, string typeName, Type expectedType) { var db = GetCleanedServer(dbType); var dt = new DataTable(); dt.Columns.Add("Hi"); dt.Rows.Add("There"); var tbl = db.CreateTable("DicomRelationalMapperHostTests", dt); var cata = Import(tbl); var globals = new GlobalOptionsFactory().Load(); var consumerOptions = globals.DicomRelationalMapperOptions; var lmd = new LoadMetadata(CatalogueRepository, "MyLoad"); cata.LoadMetadata_ID = lmd.ID; cata.SaveToDatabase(); consumerOptions.LoadMetadataId = lmd.ID; consumerOptions.DatabaseNamerType = typeName; consumerOptions.Guid = Guid.Empty; globals.RDMPOptions.CatalogueConnectionString = CatalogueRepository.DiscoveredServer.Builder.ConnectionString; globals.RDMPOptions.DataExportConnectionString = DataExportRepository.DiscoveredServer.Builder.ConnectionString; using (new MicroserviceTester(globals.RabbitOptions, globals.DicomRelationalMapperOptions)) { using (var host = new DicomRelationalMapperHost(globals)) { host.Start(); Assert.AreEqual(expectedType, host.Consumer.DatabaseNamer.GetType()); Assert.IsNotNull(host); host.Stop("Test finished"); } } }
public void ConfirmLogs_SadEntryWithEx_Throws() { var lmd = new LoadMetadata(CatalogueRepository, "MyLmd"); var cata = new Catalogue(CatalogueRepository, "myCata"); cata.LoadMetadata_ID = lmd.ID; cata.LoggingDataTask = "FFF"; cata.SaveToDatabase(); var lm = new LogManager(lmd.GetDistinctLoggingDatabase()); lm.CreateNewLoggingTaskIfNotExists("FFF"); var logEntry = lm.CreateDataLoadInfo("FFF", "pack o' cards", "going down gambling", null, true); logEntry.LogFatalError("vegas", "we lost it all on a pair of deuces"); var cmd = new ExecuteCommandConfirmLogs(new ThrowImmediatelyActivator(RepositoryLocator), lmd); var ex = Assert.Throws <LogsNotConfirmedException>(() => cmd.Execute()); StringAssert.IsMatch("Latest logs for MyLmd .* indicate that it failed", ex.Message); }
public void ConfirmLogs_SadEntry_BecauseNeverEnded_Throws() { var lmd = new LoadMetadata(CatalogueRepository, "MyLmd"); var cata = new Catalogue(CatalogueRepository, "myCata"); cata.LoadMetadata_ID = lmd.ID; cata.LoggingDataTask = "FFF"; cata.SaveToDatabase(); var lm = new LogManager(lmd.GetDistinctLoggingDatabase()); lm.CreateNewLoggingTaskIfNotExists("FFF"); // we have created log entry but it did not have an end time. This is a sad entry because it never completed lm.CreateDataLoadInfo("FFF", "pack o' cards", "going down gambling", null, true); var cmd = new ExecuteCommandConfirmLogs(new ThrowImmediatelyActivator(RepositoryLocator), lmd); var ex = Assert.Throws <LogsNotConfirmedException>(() => cmd.Execute()); StringAssert.IsMatch("Latest logs for MyLmd .* indicate that it did not complete", ex.Message); }
public void GatherAndShare_LoadMetadata_WithRealProcessTask() { //create an object LoadMetadata lmd1 = WhenIHaveA <LoadMetadata>(); SetupMEF(); var pt1 = new ProcessTask(Repository, lmd1, LoadStage.Mounting); pt1.ProcessTaskType = ProcessTaskType.Attacher; pt1.LoadStage = LoadStage.Mounting; pt1.Path = typeof(AnySeparatorFileAttacher).FullName; pt1.SaveToDatabase(); pt1.CreateArgumentsForClassIfNotExists(typeof(AnySeparatorFileAttacher)); var pta = pt1.ProcessTaskArguments.Single(pt => pt.Name == "Separator"); pta.SetValue(","); pta.SaveToDatabase(); var lmd2 = ShareToNewRepository(lmd1); //different repos so not identical Assert.IsFalse(ReferenceEquals(lmd1, lmd2)); AssertAreEqual(lmd1, lmd2); var pt2 = lmd2.ProcessTasks.Single(); Assert.IsFalse(ReferenceEquals(pt1, pt2)); AssertAreEqual(pt1, pt2); AssertAreEqual(pt1.GetAllArguments(), pt2.GetAllArguments()); RuntimeTaskFactory f = new RuntimeTaskFactory(Repository); var stg = Mock.Of <IStageArgs>(x => x.LoadStage == LoadStage.Mounting); f.Create(pt1, stg); }
public void TestConstructionFromProcessTaskUsingDatabase() { const string expectedPath = @"\\a\fake\path.exe"; var loadMetadata = new LoadMetadata(CatalogueRepository); var processTask = new ProcessTask(CatalogueRepository, loadMetadata, LoadStage.Mounting) { Name = "Test process task", Path = expectedPath }; processTask.SaveToDatabase(); var argument = new ProcessTaskArgument(CatalogueRepository, processTask) { Name = "DatabaseName", Value = @"Foo_STAGING" }; argument.SaveToDatabase(); try { var args = new RuntimeArgumentCollection(processTask.ProcessTaskArguments.Cast <IArgument>().ToArray(), null); var runtimeTask = new ExecutableRuntimeTask(processTask, args); Assert.AreEqual(expectedPath, runtimeTask.ExeFilepath); Assert.AreEqual(1, runtimeTask.RuntimeArguments.GetAllArgumentsOfType <string>().Count()); var dictionaryOfStringArguments = runtimeTask.RuntimeArguments.GetAllArgumentsOfType <string>().ToDictionary(kvp => kvp.Key, kvp => kvp.Value); Assert.IsNotNull(dictionaryOfStringArguments["DatabaseName"]); Assert.AreEqual("Foo_STAGING", dictionaryOfStringArguments["DatabaseName"]); } finally { loadMetadata.DeleteInDatabase(); } }