示例#1
0
        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();
        }
示例#2
0
        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();
            }
        }