public void CloneAPipeline_BrokenPipes() { Pipeline p = new Pipeline(CatalogueRepository); //Setup a pipeline with a source component type that doesn't exist var source = new PipelineComponent(CatalogueRepository, p, typeof(DelimitedFlatFileAttacher), 0); source.Class = "Trollololol"; var arg = source.CreateNewArgument(); //Also give the source component a non existent argument arg.GetType().GetProperty("Type").SetValue(arg, "fffffzololz"); arg.SaveToDatabase(); p.SourcePipelineComponent_ID = source.ID; p.SaveToDatabase(); Assert.AreEqual("fffffzololz", p.Source.GetAllArguments().Single().Type); var clone = p.Clone(); Assert.AreEqual(clone.Source.Class, p.Source.Class); Assert.AreEqual("fffffzololz", clone.Source.GetAllArguments().Single().Type); p.DeleteInDatabase(); clone.DeleteInDatabase(); }
public void TestArgumentWithTypeThatIsInterface(bool useInterfaceDeclaration) { var pipe = new Pipeline(CatalogueRepository, "p"); var pc = new PipelineComponent(CatalogueRepository, pipe, typeof(BasicDataReleaseDestination), -1, "c"); var arg = new PipelineComponentArgument(CatalogueRepository, pc); var server = new ExternalDatabaseServer(CatalogueRepository, "fish", null); try { arg.SetType(useInterfaceDeclaration ? typeof(IExternalDatabaseServer) : typeof(ExternalDatabaseServer)); arg.SetValue(server); //should have set Value string to the ID of the object Assert.AreEqual(arg.Value, server.ID.ToString()); arg.SaveToDatabase(); //but as system Type should return the server Assert.AreEqual(arg.GetValueAsSystemType(), server); } finally { pipe.DeleteInDatabase(); server.DeleteInDatabase(); } }
public void TestArgumentWithTypeThatIsEnum() { var pipe = new Pipeline(CatalogueRepository, "p"); var pc = new PipelineComponent(CatalogueRepository, pipe, typeof(BasicDataReleaseDestination), -1, "c"); var arg = new PipelineComponentArgument(CatalogueRepository, pc); try { arg.SetType(typeof(ExitCodeType)); arg.SetValue(ExitCodeType.OperationNotRequired); //should have set Value string to the ID of the object Assert.AreEqual(arg.Value, ExitCodeType.OperationNotRequired.ToString()); arg.SaveToDatabase(); //but as system Type should return the server Assert.AreEqual(arg.GetValueAsSystemType(), ExitCodeType.OperationNotRequired); } finally { pipe.DeleteInDatabase(); } }
[TestCase(typeof(DateTime?), "now")] //sadly can't pass DateTime.Now public void TestIArgumentsForNullableTypes(Type nullableType, object value) { if (String.Equals(value as String, "now")) //sadly can't pass DateTime.Now { value = new DateTime(2001, 01, 01, 3, 20, 11); //hey btw when you put in milliseconds into DateTime IArgument it drops them... due to DateTime.Parse? or DateTime.ToString()? } var p = new Pipeline(CatalogueRepository); var pc = new PipelineComponent(CatalogueRepository, p, GetType() //Normally this would be the PipelineComponent hosted class which would be a proper class declared as a MEF export with DemandsInitialization etc but we don't need all that , 0 , "My imaginary Pipe Component"); var arg = new PipelineComponentArgument(CatalogueRepository, pc); try { arg.SetType(nullableType); arg.SetValue(value); Assert.AreEqual(nullableType, arg.GetSystemType()); Assert.AreEqual(value, arg.GetValueAsSystemType()); } finally { p.DeleteInDatabase(); } }
protected virtual Pipeline SetupPipeline() { var repository = RepositoryLocator.CatalogueRepository; var pipeline = new Pipeline(repository, "Empty extraction pipeline"); var component = new PipelineComponent(repository, pipeline, typeof(ExecuteDatasetExtractionFlatFileDestination), 0, "Destination"); var arguments = component.CreateArgumentsForClassIfNotExists <ExecuteDatasetExtractionFlatFileDestination>().ToArray(); if (arguments.Length < 3) { throw new Exception("Expected only 2 arguments for type ExecuteDatasetExtractionFlatFileDestination, did somebody add another [DemandsInitialization]? if so handle it below"); } arguments.Single(a => a.Name.Equals("DateFormat")).SetValue("yyyy-MM-dd"); arguments.Single(a => a.Name.Equals("DateFormat")).SaveToDatabase(); arguments.Single(a => a.Name.Equals("FlatFileType")).SetValue(ExecuteExtractionToFlatFileType.CSV); arguments.Single(a => a.Name.Equals("FlatFileType")).SaveToDatabase(); var component2 = new PipelineComponent(repository, pipeline, typeof(ExecuteDatasetExtractionSource), -1, "Source"); var arguments2 = component2.CreateArgumentsForClassIfNotExists <ExecuteDatasetExtractionSource>().ToArray(); arguments2.Single(a => a.Name.Equals("AllowEmptyExtractions")).SetValue(AllowEmptyExtractions); arguments2.Single(a => a.Name.Equals("AllowEmptyExtractions")).SaveToDatabase(); //configure the component as the destination pipeline.DestinationPipelineComponent_ID = component.ID; pipeline.SourcePipelineComponent_ID = component2.ID; pipeline.SaveToDatabase(); return(pipeline); }
/// <summary> /// Sets metadata version to assemblies current version /// </summary> /// <param name="component">pipeline component</param> /// <param name="componentMetaData">components metdadata</param> public static void UpdateVersion(PipelineComponent component, IDTSComponentMetaData100 componentMetaData) { DtsPipelineComponentAttribute componentAttr = (DtsPipelineComponentAttribute)Attribute.GetCustomAttribute(component.GetType(), typeof(DtsPipelineComponentAttribute), false); int binaryVersion = componentAttr.CurrentVersion; componentMetaData.Version = binaryVersion; }
static InspectionWorker() { // Since we're using Reflection-only LoadFrom, we must pre-load // dependent assemblies, such as System.AddIn.dll (this assembly). SystemAddInInReflectionOnlyContext = Assembly.ReflectionOnlyLoad(typeof(AddInStore).Assembly.FullName); SystemAddInContractsInReflectionOnlyContext = Assembly.ReflectionOnlyLoad(typeof(System.AddIn.Contract.IContract).Assembly.FullName); PipelineComponent.SetTypesFromReflectionLoaderContext(SystemAddInInReflectionOnlyContext, SystemAddInContractsInReflectionOnlyContext); }
private void AddAdvertisedComponent(DragEventArgs e, DividerLineControl divider) { var advert = GetAdvertisedObjectFromDragOperation(e); if ( //if user is trying to add a source advert.GetRole() == DataFlowComponentVisualisation.Role.Source //and there is already an explicit source or a configured one && (_useCase.ExplicitSource != null || _pipeline.SourcePipelineComponent_ID != null)) { MessageBox.Show("There is already a source in this pipeline"); return; } if ( //if user is trying to add a destination advert.GetRole() == DataFlowComponentVisualisation.Role.Destination //and there is already an explicit destination or a configured one && (_useCase.ExplicitDestination != null || _pipeline.DestinationPipelineComponent_ID != null)) { MessageBox.Show("There is already a destination in this pipeline"); return; } Type underlyingComponentType = advert.GetComponentType(); //add the component to the pipeline var repository = (ICatalogueRepository)_pipeline.Repository; var newcomp = new PipelineComponent(repository, _pipeline, underlyingComponentType, -999, advert.ToString()) { Order = GetOrderMakingSpaceIfNessesary(null, divider) }; newcomp.CreateArgumentsForClassIfNotExists(underlyingComponentType); newcomp.SaveToDatabase(); if (advert.GetRole() == DataFlowComponentVisualisation.Role.Source) { _pipeline.SourcePipelineComponent_ID = newcomp.ID; _pipeline.SaveToDatabase(); } if (advert.GetRole() == DataFlowComponentVisualisation.Role.Destination) { _pipeline.DestinationPipelineComponent_ID = newcomp.ID; _pipeline.SaveToDatabase(); } RefreshUIFromDatabase(); var viz = flpPipelineDiagram.Controls.OfType <PipelineComponentVisualisation>().Single(v => Equals(v.PipelineComponent, newcomp)); component_Selected(viz, newcomp); }
public void Execute_FullPipeline_ExecutesToTheEnd() { var initialComponent = PipelineComponent.CreatePipeline <string, int>((x, c) => x.Length); IPipelineOutput <bool> pipelineOutput = initialComponent .AddStep((x, c) => x > 10); initialComponent.Execute("12345678901"); Assert.IsTrue(pipelineOutput.GetOutput()); }
public async Task ExecuteAsync_FullPipeline_ExecutesToTheEnd() { var initialComponent = PipelineComponent.CreateAsyncPipeline <string, int>((x, c) => Task.FromResult(x.Length)); IPipelineOutput <bool> pipelineOutput = initialComponent .AddStep((x, c) => Task.FromResult(x > 10)); await initialComponent.ExecuteAsync("dit is een test string"); Assert.IsTrue(pipelineOutput.GetOutput()); }
public void TestPipelineContextIsAllowable() { var contextFactory = new DataFlowPipelineContextFactory <DataTable>(); var context = contextFactory.Create(PipelineUsage.FixedSource | PipelineUsage.FixedDestination | PipelineUsage.LoadsSingleTableInfo); var pipeline = new Pipeline(CatalogueRepository, "DeleteMePipeline"); var component = new PipelineComponent(CatalogueRepository, pipeline, typeof(TestObject_RequiresTableInfo), 0); Assert.IsTrue(context.IsAllowable(pipeline)); pipeline.DeleteInDatabase(); }
public static string Get(this IDTSCustomPropertyCollection100 collection, PipelineComponent component, string name) { string value = collection[name].Value.ToString(); if (value.StartsWith("@")) { var variableName = value.StartsWith("@[") ? value.Substring(2, value.Length - 3) : value.Substring(1); IDTSVariables100 variables; component.VariableDispenser.LockForRead(variableName); component.VariableDispenser.GetVariables(out variables); value = variables[variableName].Value.ToString(); } return(value); }
public void SetupAndSaveAPipeline() { Pipeline pipeline = new Pipeline(CatalogueRepository, "Bob"); try { Assert.AreEqual(pipeline.Name, "Bob"); PipelineComponent pipelineComponent = new PipelineComponent(CatalogueRepository, pipeline, typeof(BasicAnonymisationEngine), 0); try { Assert.AreEqual(pipelineComponent.Class, typeof(BasicAnonymisationEngine).FullName); PipelineComponentArgument argument1 = (PipelineComponentArgument)pipelineComponent.CreateNewArgument(); PipelineComponentArgument argument2 = new PipelineComponentArgument(CatalogueRepository, pipelineComponent); try { argument1.SetType(typeof(string)); argument1.SetValue("bob"); argument1.SaveToDatabase(); var dt = DateTime.Now; dt = new DateTime(dt.Ticks - (dt.Ticks % TimeSpan.TicksPerSecond), dt.Kind);//get rid of the milliseconds argument2.SetType(typeof(DateTime)); argument2.SetValue(dt); argument2.SaveToDatabase(); PipelineComponentArgument argument2Copy = CatalogueRepository.GetObjectByID <PipelineComponentArgument>(argument2.ID); Assert.AreEqual(dt, argument2Copy.GetValueAsSystemType()); } finally { argument1.DeleteInDatabase(); argument2.DeleteInDatabase(); } } finally { pipelineComponent.DeleteInDatabase(); } } finally { pipeline.DeleteInDatabase(); } }
/// <summary> /// Gets the Version of the Pipeline Component based ont he DTSPipelineComponentAttribute /// </summary> /// <param name="comp">Pipeline component to return the version</param> /// <returns>Version of the provided pipeline component</returns> public static int GetPipelineComponentVersion(PipelineComponent comp) { int version = 0; if (comp != null) { var attribs = TypeDescriptor.GetAttributes(comp.GetType()); DtsPipelineComponentAttribute pc = (DtsPipelineComponentAttribute)attribs[typeof(DtsPipelineComponentAttribute)]; System.Reflection.PropertyInfo pi = pc.GetType().GetProperty("CurrentVersion"); if (pi != null) { version = (int)pi.GetValue(pc, null); } } return(version); }
private bool ComponentInWrongLocation(PipelineComponent component, PipelineComponent dependentComponent, String rootDir, Collection <String> warnings) { System.Diagnostics.Contracts.Contract.Requires(rootDir != null || PipelineRootDirectory != null); string dependentPath = rootDir == null ? dependentComponent.Location : Path.Combine(rootDir, dependentComponent.Location); String fileName = Path.GetFileName(component.Location); String location = Path.GetDirectoryName(dependentPath); if (File.Exists(Path.Combine(location, fileName))) { warnings.Add(String.Format(CultureInfo.CurrentCulture, Res.ComponentInWrongLocation, fileName, location)); return(true); } return(false); }
public static ContainerBuilder AddLogging(this ContainerBuilder builder, Action <IPipelineComponent <Log, Log>, IComponentContext> configure) { builder.Register(context => { IPipelineComponent <Log, Log> pipeline = PipelineComponent.CreateIdentity <Log>(); configure?.Invoke(pipeline, context); return(new Logger(pipeline)); }).As <ILogger>().SingleInstance(); builder.RegisterGeneric(typeof(Logger <>)) .As(typeof(ILogger <>)) .InstancePerDependency(); return(builder); }
public TestDataPipelineAssembler(string pipeName, CatalogueRepository catalogueRepository) { Pipeline = new Pipeline(catalogueRepository, pipeName); Source = new PipelineComponent(catalogueRepository, Pipeline, typeof(TestDataInventor), 1, "DataInventorSource"); Destination = new PipelineComponent(catalogueRepository, Pipeline, typeof(TestDataWriter), 2, "DataInventorDestination"); Destination.CreateArgumentsForClassIfNotExists <TestDataWriter>(); Pipeline.SourcePipelineComponent_ID = Source.ID; Pipeline.DestinationPipelineComponent_ID = Destination.ID; Pipeline.SaveToDatabase(); var args = Source.CreateArgumentsForClassIfNotExists <TestDataInventor>(); args[0].SetValue(TestContext.CurrentContext.TestDirectory); args[0].SaveToDatabase(); }
public void DeletePipelineDestination_ClearsReference() { Pipeline p = new Pipeline(CatalogueRepository); //Setup a pipeline with a source component var dest = new PipelineComponent(CatalogueRepository, p, typeof(DelimitedFlatFileAttacher), 0); dest.Class = "Trollololol"; p.DestinationPipelineComponent_ID = dest.ID; p.SaveToDatabase(); // delete the dest dest.DeleteInDatabase(); p.RevertToDatabaseState(); // should also clear the reference Assert.IsNull(p.DestinationPipelineComponent_ID); }
protected override Pipeline SetupPipeline() { //create a target server pointer _extractionServer = new ExternalDatabaseServer(CatalogueRepository, "myserver", null); _extractionServer.Server = DiscoveredServerICanCreateRandomDatabasesAndTablesOn.Name; _extractionServer.Username = DiscoveredServerICanCreateRandomDatabasesAndTablesOn.ExplicitUsernameIfAny; _extractionServer.Password = DiscoveredServerICanCreateRandomDatabasesAndTablesOn.ExplicitPasswordIfAny; _extractionServer.SaveToDatabase(); //create a pipeline _pipeline = new Pipeline(CatalogueRepository, "Empty extraction pipeline"); //set the destination pipeline var component = new PipelineComponent(CatalogueRepository, _pipeline, typeof(ExecuteFullExtractionToDatabaseMSSql), 0, "MS SQL Destination"); var destinationArguments = component.CreateArgumentsForClassIfNotExists <ExecuteFullExtractionToDatabaseMSSql>().ToList(); IArgument argumentServer = destinationArguments.Single(a => a.Name == "TargetDatabaseServer"); IArgument argumentDbNamePattern = destinationArguments.Single(a => a.Name == "DatabaseNamingPattern"); IArgument argumentTblNamePattern = destinationArguments.Single(a => a.Name == "TableNamingPattern"); Assert.AreEqual("TargetDatabaseServer", argumentServer.Name); argumentServer.SetValue(_extractionServer); argumentServer.SaveToDatabase(); argumentDbNamePattern.SetValue(TestDatabaseNames.Prefix + "$p_$n"); argumentDbNamePattern.SaveToDatabase(); argumentTblNamePattern.SetValue("$c_$d"); argumentTblNamePattern.SaveToDatabase(); AdjustPipelineComponentDelegate?.Invoke(component); var component2 = new PipelineComponent(CatalogueRepository, _pipeline, typeof(ExecuteCrossServerDatasetExtractionSource), -1, "Source"); var arguments2 = component2.CreateArgumentsForClassIfNotExists <ExecuteCrossServerDatasetExtractionSource>().ToArray(); arguments2.Single(a => a.Name.Equals("AllowEmptyExtractions")).SetValue(false); arguments2.Single(a => a.Name.Equals("AllowEmptyExtractions")).SaveToDatabase(); AdjustPipelineComponentDelegate?.Invoke(component2); //configure the component as the destination _pipeline.DestinationPipelineComponent_ID = component.ID; _pipeline.SourcePipelineComponent_ID = component2.ID; _pipeline.SaveToDatabase(); return(_pipeline); }
private Pipeline CreatePipeline(string nameOfPipe, Type sourceType, Type destinationTypeIfAny, params Type[] componentTypes) { if (componentTypes == null || componentTypes.Length == 0) { return(CreatePipeline(nameOfPipe, sourceType, destinationTypeIfAny)); } var pipeline = CreatePipeline(nameOfPipe, sourceType, destinationTypeIfAny); int i = 1; foreach (var componentType in componentTypes) { var component = new PipelineComponent(_repositoryLocator.CatalogueRepository, pipeline, componentType, i++); component.CreateArgumentsForClassIfNotExists(componentType); component.Pipeline_ID = pipeline.ID; } return(pipeline); }
private void AddExplicit(object value) { var role = PipelineComponent.GetRoleFor(value.GetType()); var component = new DataFlowComponentVisualisation(role, value, null); flpPipelineDiagram.Controls.Add(component);//add the explicit component component.IsLocked = true; try { if (!_useCase.IsDesignTime) { _useCase.GetContext().PreInitializeGeneric(new ThrowImmediatelyDataLoadEventListener(), component.Value, _useCase.GetInitializationObjects().ToArray()); } } catch (Exception e) { ExceptionViewer.Show("PreInitialize failed on Explicit (locked component) " + component.Value.GetType().Name, e); } }
// The loader may load assemblies from the wrong place in certain cases. // We need to warn people. // 1. Contracts is not in AddInAdapter directory // 2. AddInView is not in AddInAdapter directory // 3. AddInView is not in AddIn directory // 4. Contracts is not in HostSideAdapter directory // // At discovery time, rootDir is passed in. // At activation time, it is not needed. internal bool HasDuplicatedAssemblies(String rootDir, Collection <String> warnings) { PipelineComponent[] componentsAndDependents = new PipelineComponent[] { _contract, _addinAdapter, _addinBase, _addinAdapter, _addinBase, _addin, _contract, _hostAdapter }; bool duplicates = false; for (int i = 0; i < componentsAndDependents.Length; i += 2) { if (ComponentInWrongLocation(componentsAndDependents[i], componentsAndDependents[i + 1], rootDir, warnings)) { duplicates = true; } } return(duplicates); }
private void PopulateCohortDatabaseWithRecordsFromNonTvfCatalogue() { //create a cohort identification configuration (identifies people from datasets using set operations - see CohortManager) _cic = new CohortIdentificationConfiguration(CatalogueRepository, "TbvfCIC"); _cic.CreateRootContainerIfNotExists(); //turn the catalogue _nonTvfCatalogue into a cohort set and add it to the root container var newAggregate = _cic.CreateNewEmptyConfigurationForCatalogue(_nonTvfCatalogue, (s, e) => { throw new Exception("Did not expect there to be more than 1!"); }); var root = _cic.RootCohortAggregateContainer; root.AddChild(newAggregate, 0); //create a pipeline for executing this CIC and turning it into a cohort _pipe = new Pipeline(CatalogueRepository, "CREATE COHORT:By Executing CIC"); var source = new PipelineComponent(CatalogueRepository, _pipe, typeof(CohortIdentificationConfigurationSource), 0, "CIC Source"); _project = new Project(DataExportRepository, "TvfProject"); _project.ProjectNumber = 12; _project.ExtractionDirectory = TestContext.CurrentContext.TestDirectory; _project.SaveToDatabase(); var destination = new PipelineComponent(CatalogueRepository, _pipe, typeof(BasicCohortDestination), 1, "Destination"); _pipe.SourcePipelineComponent_ID = source.ID; _pipe.DestinationPipelineComponent_ID = destination.ID; _pipe.SaveToDatabase(); //create pipeline arguments source.CreateArgumentsForClassIfNotExists <CohortIdentificationConfigurationSource>(); destination.CreateArgumentsForClassIfNotExists <BasicCohortDestination>(); //create pipeline initialization objects var request = new CohortCreationRequest(_project, new CohortDefinition(null, "MyFirstCohortForTvfTest", 1, 12, _externalCohortTable), (DataExportRepository)DataExportRepository, "Here goes nothing"); request.CohortIdentificationConfiguration = _cic; var engine = request.GetEngine(_pipe, new ThrowImmediatelyDataLoadEventListener()); engine.ExecutePipeline(new GracefulCancellationToken()); }
/// <summary> /// Adds the given <paramref name="component"/> to the IL emission pipeline. /// </summary> /// <param name="editor"></param> /// <param name="component"></param> public static void EditIL(this CompilationEditor editor, PipelineComponent <EmitDelegate> component) { Pipeline <EmitDelegate> GetDefaultValue() { EmitDelegate Emit(EmitDelegate next) { var pipeline = editor.Storage.Get <Pipeline <EmitDelegate> >(Key); var del = pipeline.MakeDelegate(next); return(del); } CodeGeneratorContext.EmitPipeline += Emit; //editor.EmissionStart += ce => CodeGeneratorContext.EmitPipeline += Emit; //editor.EmissionEnd += ce => CodeGeneratorContext.EmitPipeline -= Emit; return(new Pipeline <EmitDelegate>()); } editor.Storage.GetOrAdd(Key, GetDefaultValue).Add(component); }
public async Task ExecuteAsync_BrokenPipeline_DoesNotFinish() { bool triggered = false; var initialComponent = PipelineComponent.CreateAsyncPipeline <int, bool>((x, c) => { c.Break(); return(Task.FromResult(true)); }); IPipelineOutput <bool> pipelineOutput = initialComponent.AddStep((x, c) => { triggered = true; return(Task.FromResult(x)); }); var context = new PipelineContext(); await initialComponent.ExecuteAsync(10, context); Assert.IsTrue(context.IsBroken); Assert.IsFalse(triggered); }
private Pipeline CreatePipeline(string nameOfPipe, Type sourceType, Type destinationTypeIfAny) { var pipe = new Pipeline(_repositoryLocator.CatalogueRepository, nameOfPipe); if (sourceType != null) { var source = new PipelineComponent(_repositoryLocator.CatalogueRepository, pipe, sourceType, 0); source.CreateArgumentsForClassIfNotExists(sourceType); pipe.SourcePipelineComponent_ID = source.ID; } if (destinationTypeIfAny != null) { var destination = new PipelineComponent(_repositoryLocator.CatalogueRepository, pipe, destinationTypeIfAny, 100); destination.CreateArgumentsForClassIfNotExists(destinationTypeIfAny); pipe.DestinationPipelineComponent_ID = destination.ID; } pipe.SaveToDatabase(); return(pipe); }
public void TestPipelineContextIsNOTAllowable() { var contextFactory = new DataFlowPipelineContextFactory <DataTable>(); var context = contextFactory.Create(PipelineUsage.FixedDestination); var pipeline = new Pipeline(CatalogueRepository, "DeleteMePipeline"); var component = new PipelineComponent(CatalogueRepository, pipeline, typeof(TestObject_RequiresTableInfo), 0); component.Name = "TestPipeComponent"; component.SaveToDatabase(); string reason; bool rejection = context.IsAllowable(pipeline, out reason); Console.WriteLine(reason); Assert.IsFalse(rejection, reason); Assert.AreEqual("Component TestPipeComponent implements a forbidden type (IPipelineRequirement<TableInfo>) under the pipeline usage context", reason); pipeline.DeleteInDatabase(); }
public void Execute_BrokenPipeline_DoesNotFinish() { bool triggered = false; var initialComponent = PipelineComponent.CreatePipeline <int, bool>((x, c) => { c.Break(); return(true); }); IPipelineOutput <bool> pipelineOutput = initialComponent.AddStep((x, c) => { triggered = true; return(x); }); var context = new PipelineContext(); initialComponent.Execute(10, context); Assert.IsTrue(context.IsBroken); Assert.IsFalse(triggered); }
public void TestArgumentThatIsDictionary() { var pipe = new Pipeline(CatalogueRepository, "p"); var pc = new PipelineComponent(CatalogueRepository, pipe, typeof(BasicDataReleaseDestination), -1, "c"); try { var arg = new PipelineComponentArgument(CatalogueRepository, pc); arg.Name = "MyNames"; arg.SetType(typeof(Dictionary <TableInfo, string>)); arg.SaveToDatabase(); Assert.AreEqual(typeof(Dictionary <TableInfo, string>), arg.GetConcreteSystemType()); var ti1 = new TableInfo(CatalogueRepository, "test1"); var ti2 = new TableInfo(CatalogueRepository, "test2"); var val = new Dictionary <TableInfo, string>(); val.Add(ti1, "Fish"); val.Add(ti2, "Fish"); arg.SetValue(val); arg.SaveToDatabase(); var val2 = (Dictionary <TableInfo, string>)arg.GetValueAsSystemType(); Assert.AreEqual(2, val2.Count); Assert.AreEqual("Fish", val2[ti1]); Assert.AreEqual("Fish", val2[ti2]); } finally { pipe.DeleteInDatabase(); } }
public void TestNestedDemandsGetPutIntoDatabaseAndCanBeBroughtBack() { var pipe = new Pipeline(CatalogueRepository, "NestedPipe"); var pc = new PipelineComponent(CatalogueRepository, pipe, typeof(BasicDataReleaseDestination), -1, "Coconuts"); pipe.DestinationPipelineComponent_ID = pc.ID; pipe.SaveToDatabase(); //some of the DemandsInitialization on BasicDataReleaseDestination should be nested var f = new ArgumentFactory(); Assert.True( f.GetRequiredProperties(typeof(BasicDataReleaseDestination)).Any(r => r.ParentPropertyInfo != null)); //new pc should have no arguments Assert.That(pc.GetAllArguments(), Is.Empty); //we create them (the root and nested ones!) var args = pc.CreateArgumentsForClassIfNotExists <BasicDataReleaseDestination>(); //and get all arguments / create arguments for class should have handled that Assert.That(pc.GetAllArguments().Any()); var match = args.Single(a => a.Name == "ReleaseSettings.DeleteFilesOnSuccess"); match.SetValue(true); match.SaveToDatabase(); var useCase = ReleaseUseCase.DesignTime(); var factory = new DataFlowPipelineEngineFactory(useCase, RepositoryLocator.CatalogueRepository.MEF); var destInstance = factory.CreateDestinationIfExists(pipe); Assert.AreEqual(true, ((BasicDataReleaseDestination)destInstance).ReleaseSettings.DeleteFilesOnSuccess); }