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