public void TestEncryptedPasswordHostArgumentType() { LoadMetadata lmd = null; ProcessTaskArgument pta = null; try { pta = CreateNewProcessTaskArgumentInDatabase(out lmd); pta.SetType(typeof(EncryptedString)); pta.SetValue(new EncryptedString(CatalogueRepository) { Value = "test123" }); pta.SaveToDatabase(); var loadedPta = CatalogueRepository.GetObjectByID <ProcessTaskArgument>(pta.ID); var value = loadedPta.GetValueAsSystemType() as EncryptedString; Assert.NotNull(value); Assert.AreEqual("test123", value.GetDecryptedValue()); } finally { if (pta != null) { var processTask = CatalogueRepository.GetObjectByID <ProcessTask>(pta.ProcessTask_ID); processTask.DeleteInDatabase(); } if (lmd != null) { lmd.DeleteInDatabase(); } } }
public void TypeOfPreLoadDiscardedColumn() { string methodName = new StackTrace().GetFrame(0).GetMethod().Name; string tableInfoName = "TableInfoFor_" + methodName; string preLoadDiscardedColumnName = "PreLoadDiscardedColumnFor_" + methodName; TableInfo toCleanup = CatalogueRepository.GetAllObjects <TableInfo>().SingleOrDefault(t => t.Name.Equals(tableInfoName)); PreLoadDiscardedColumn toCleanupCol = CatalogueRepository.GetAllObjects <PreLoadDiscardedColumn>() .SingleOrDefault(c => c.RuntimeColumnName.Equals(preLoadDiscardedColumnName)); //must delete pre load discarded first if (toCleanupCol != null) { toCleanupCol.DeleteInDatabase(); } 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); pta.SetType(typeof(PreLoadDiscardedColumn)); var tableInfo = new TableInfo(CatalogueRepository, tableInfoName); PreLoadDiscardedColumn preloadDiscardedColumn = new PreLoadDiscardedColumn(CatalogueRepository, tableInfo, preLoadDiscardedColumnName); try { pta.SetValue(preloadDiscardedColumn); pta.SaveToDatabase(); var newInstanceOfPTA = CatalogueRepository.GetObjectByID <ProcessTaskArgument>(pta.ID); Assert.AreEqual(newInstanceOfPTA.Value, pta.Value); PreLoadDiscardedColumn p1 = (PreLoadDiscardedColumn)pta.GetValueAsSystemType(); PreLoadDiscardedColumn p2 = (PreLoadDiscardedColumn)newInstanceOfPTA.GetValueAsSystemType(); Assert.AreEqual(p1.ID, p2.ID); } finally { preloadDiscardedColumn.DeleteInDatabase(); tableInfo.DeleteInDatabase(); } } finally { lmd.DeleteInDatabase(); } }
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 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(); } }
public void LieToProcessTaskArgumentAboutWhatTypeIs_Throws() { 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); var tableInfo = new TableInfo(CatalogueRepository, tableInfoName); try { //tell it that we are going to give it a PreLoadDiscardedColumn pta.SetType(typeof(PreLoadDiscardedColumn)); //then surprise! heres a TableInfo! var ex = Assert.Throws <Exception>(() => pta.SetValue(tableInfo)); StringAssert.Contains("has an incompatible Type specified (Rdmp.Core.Curation.Data.DataLoad.PreLoadDiscardedColumn)", ex.Message); } finally { tableInfo.DeleteInDatabase(); } } finally { lmd.DeleteInDatabase(); } }
public void CloneProcessTask_ToNewLoadMetadataWithArguments() { //setup parents LoadMetadata parent1 = new LoadMetadata(CatalogueRepository); LoadMetadata parent2 = new LoadMetadata(CatalogueRepository); //make sure we didn't magically create the same ID somehow Assert.AreNotEqual(parent1.ID, parent2.ID); //setup things to clone in parent1 ProcessTask processTask1 = new ProcessTask(CatalogueRepository, parent1, LoadStage.AdjustRaw); ProcessTaskArgument arg = new ProcessTaskArgument(CatalogueRepository, processTask1); arg.Name = "TestArg"; arg.SetType(typeof(System.String)); arg.SetValue("TestValue"); arg.SaveToDatabase(); processTask1.Name = "Franky"; processTask1.Order = 999; processTask1.SaveToDatabase(); try { //clone to parent 2 var clone = processTask1.CloneToNewLoadMetadataStage(parent2, LoadStage.GetFiles); Assert.AreNotSame(clone.ID, processTask1.ID); Assert.IsFalse(clone.ID == processTask1.ID); //////////////////////////////////////////////////////////////////CHECK CLONAGE OF PROCESS TASK //////////////////////////////////////////////////////////// //get fresh copy out of database to ensure it is still there ProcessTask orig = CatalogueRepository.GetObjectByID <ProcessTask>(processTask1.ID); clone = CatalogueRepository.GetObjectByID <ProcessTask>(clone.ID); //ids must have changed Assert.IsFalse(orig.ID == clone.ID); //load stages must be correct per what we requested Assert.AreEqual(LoadStage.AdjustRaw, orig.LoadStage); Assert.AreEqual(LoadStage.GetFiles, clone.LoadStage); //all regular values must have been cloned successfully Assert.AreEqual(orig.Order, clone.Order); Assert.AreEqual(orig.Path, clone.Path); Assert.AreEqual(orig.ProcessTaskType, clone.ProcessTaskType); Assert.AreEqual(parent1.ID, orig.LoadMetadata_ID); Assert.AreEqual(parent2.ID, clone.LoadMetadata_ID); /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////CHECK CLONAGE OF ARGUMENTS //////////////////////////////////////////////////////////// ProcessTaskArgument clonearg = clone.ProcessTaskArguments.SingleOrDefault(); Assert.NotNull(clonearg); Assert.AreNotEqual(clonearg.ID, arg.ID); Assert.AreEqual(clonearg.GetType(), arg.GetType()); Assert.AreEqual(clonearg.Name, arg.Name); Assert.AreEqual(clonearg.Value, arg.Value); /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// clone.DeleteInDatabase(); } finally { processTask1.DeleteInDatabase(); parent1.DeleteInDatabase(); parent2.DeleteInDatabase(); } }