예제 #1
0
        public void RelatedCatalogueTest_OneCatalogue(bool createExtractionInformation)
        {
            TableInfo  t = new TableInfo(Repository, "MyTable");
            ColumnInfo c = new ColumnInfo(Repository, "MyCol", "varchar(10)", t);

            Catalogue     cata = new Catalogue(Repository, "MyCata");
            CatalogueItem ci   = new CatalogueItem(Repository, cata, "MyCataItem");

            try
            {
                if (createExtractionInformation)
                {
                    new ExtractionInformation(Repository, ci, c, "dbo.SomeFunc('Bob') as MySelectLine");
                }
                else
                {
                    ci.SetColumnInfo(c);
                }

                var catas = t.GetAllRelatedCatalogues();
                Assert.AreEqual(1, catas.Length);
                Assert.AreEqual(cata, catas[0]);
            }
            finally
            {
                ci.DeleteInDatabase();
                cata.DeleteInDatabase();
                t.DeleteInDatabase();
            }
        }
        public void PreventDeletingCatalogueBecauseOfLinkedDatasetTest()
        {
            var obscura = new BetweenCatalogueAndDataExportObscureDependencyFinder(RepositoryLocator);
            var cata = new Catalogue(CatalogueRepository, "MyCata");

            //catalogue exists in isolation so is deletable
            Assert.DoesNotThrow(()=>obscura.ThrowIfDeleteDisallowed(cata));

            //there is a new dataset which is linked to Catalogue
            var dataset = new ExtractableDataSet(DataExportRepository,cata);
            
            //and suddenly we cannot delete the catalogue
            var ex = Assert.Throws<Exception>(() => obscura.ThrowIfDeleteDisallowed(cata));
            Assert.IsTrue(ex.Message.Contains("Cannot delete Catalogue MyCata because there are ExtractableDataSets which depend on them "));

            //also if we try to force through a delete it should behave in identical manner
            var ex2 = Assert.Throws<Exception>(cata.DeleteInDatabase);
            Assert.IsTrue(ex2.Message.Contains("Cannot delete Catalogue MyCata because there are ExtractableDataSets which depend on them "));

            //now we delete the linked dataset
            dataset.DeleteInDatabase();

            //and because there is now no longer a dataset dependency on the catalogue we can delete it
            Assert.DoesNotThrow(() => obscura.ThrowIfDeleteDisallowed(cata));
            
            //and the delete works too
            cata.DeleteInDatabase();

            //both objects still exist in memory of course but we should be able to see they have disapeared 
            Assert.IsTrue(dataset.HasLocalChanges().Evaluation == ChangeDescription.DatabaseCopyWasDeleted);
            Assert.IsTrue(cata.HasLocalChanges().Evaluation == ChangeDescription.DatabaseCopyWasDeleted);
        }
예제 #3
0
        public void update_changeAllPropertiesOfCatalogueItem_passes()
        {
            Catalogue     parent = new Catalogue(CatalogueRepository, "KONGOR");
            CatalogueItem child  = new CatalogueItem(CatalogueRepository, parent, "KONGOR_SUPERKING")
            {
                Agg_method  = "Adding SetUp",
                Comments    = "do not change amagad super secret!",
                Limitations = "Extreme limitaitons",
                Description =
                    "Exciting things are going down in the streets of new your this time of year it would be a great idea if you were to go there",
                Name               = "KONGOR_MINIMAN",
                Periodicity        = Catalogue.CataloguePeriodicity.Monthly,
                Research_relevance = "Highly relevant to all fields of subatomic particle study",
                Statistical_cons   = "Dangerous cons frequent the areas that this stats is happening, be afraid",
                Topic              = "nothing much, lots of stuff"
            };

            child.SaveToDatabase();

            CatalogueItem childAfter = CatalogueRepository.GetObjectByID <CatalogueItem>(child.ID);

            Assert.IsTrue(child.Name == childAfter.Name);
            Assert.IsTrue(child.Agg_method == childAfter.Agg_method);
            Assert.IsTrue(child.Comments == childAfter.Comments);
            Assert.IsTrue(child.Limitations == childAfter.Limitations);
            Assert.IsTrue(child.Description == childAfter.Description);
            Assert.IsTrue(child.Periodicity == childAfter.Periodicity);
            Assert.IsTrue(child.Research_relevance == childAfter.Research_relevance);
            Assert.IsTrue(child.Statistical_cons == childAfter.Statistical_cons);
            Assert.IsTrue(child.Topic == childAfter.Topic);

            child.DeleteInDatabase();
            parent.DeleteInDatabase();
        }
예제 #4
0
        public void AddSameLinkTwice()
        {
            Catalogue     predator        = null;
            CatalogueItem lazor           = null;
            TableInfo     highEnergyTable = null;
            ColumnInfo    velocityColumn  = null;

            try
            {
                ///////////////Create the things that we are going to create relationships between /////////////////
                predator        = new Catalogue(CatalogueRepository, "Predator");
                lazor           = new CatalogueItem(CatalogueRepository, predator, "QuadlzorVelocity");
                highEnergyTable = new TableInfo(CatalogueRepository, "HighEnergyShizzle");
                velocityColumn  = new ColumnInfo(CatalogueRepository, "Velocity Of Matter", "int", highEnergyTable);

                //now you can add as many links as you want, it just skips them
                lazor.SetColumnInfo(velocityColumn);
                Assert.AreEqual(lazor.ColumnInfo, velocityColumn);
            }
            finally
            {
                lazor.DeleteInDatabase();           //delete child
                predator.DeleteInDatabase();        //delete parent

                velocityColumn.DeleteInDatabase();  //delete child
                highEnergyTable.DeleteInDatabase(); //delete parent
            }
        }
예제 #5
0
        public void AddLinkBetween_createNewLink_pass()
        {
            ///////////////Create the things that we are going to create relationships between /////////////////
            var predator        = new Catalogue(CatalogueRepository, "Predator");
            var lazor           = new CatalogueItem(CatalogueRepository, predator, "QuadlzorVelocity");
            var highEnergyTable = new TableInfo(CatalogueRepository, "HighEnergyShizzle");
            var velocityColumn  = new ColumnInfo(CatalogueRepository, "Velocity Of Matter", "int", highEnergyTable);

            ////////////Check the creation worked ok
            Assert.IsNotNull(predator); //catalogue
            Assert.IsNotNull(lazor);

            Assert.IsNotNull(highEnergyTable); //underlying table stuff
            Assert.IsNotNull(velocityColumn);

            ////////////// Create links between stuff and check they were created successfully //////////////

            //create a link between catalogue item lazor and velocity column
            lazor.SetColumnInfo(velocityColumn);
            Assert.IsTrue(lazor.ColumnInfo.ID == velocityColumn.ID);

            ////////////////cleanup ---- Delete everything that we created -------- //////////////
            velocityColumn.DeleteInDatabase(); //delete causes CASCADE: CatalogueItem no longer associated with ColumnInfo because ColumnInfo died

            lazor.RevertToDatabaseState();

            Assert.IsNull(lazor.ColumnInfo);//involves a database query so won't actually invalidate the below

            predator.DeleteInDatabase();

            highEnergyTable.DeleteInDatabase();
        }
예제 #6
0
        public void GovernsCatalogue(bool memoryRepository)
        {
            ICatalogueRepository repo = memoryRepository ? (ICatalogueRepository) new MemoryCatalogueRepository() : CatalogueRepository;

            var       gov = GetGov(repo);
            Catalogue c   = new Catalogue(repo, "GovernedCatalogue");

            try
            {
                Assert.AreEqual(gov.GovernedCatalogues.Count(), 0);

                //should be no governanced catalogues for this governancer yet
                gov.CreateGovernanceRelationshipTo(c);

                var allCatalogues     = gov.GovernedCatalogues.ToArray();
                var governedCatalogue = allCatalogues[0];
                Assert.AreEqual(governedCatalogue, c); //we now govern C
            }
            finally
            {
                gov.DeleteGovernanceRelationshipTo(c);
                Assert.AreEqual(gov.GovernedCatalogues.Count(), 0); //we govern c nevermore!

                c.DeleteInDatabase();
            }
        }
예제 #7
0
        public void ExtractionInformationTriangle()
        {
            var t   = new TableInfo(CatalogueRepository, "t");
            var col = new ColumnInfo(CatalogueRepository, "mycol", "varchar(10)", t);

            var cat = new Catalogue(CatalogueRepository, "MyCat");
            var ci  = new CatalogueItem(CatalogueRepository, cat, "myci");


            try
            {
                //col depends on tr
                Assert.Contains(t, col.GetObjectsThisDependsOn());
                Assert.Contains(col, t.GetObjectsDependingOnThis());

                //catalogue depends on catalogue items existing (slightly counter intuitive but think of it as data flow out of technical low level data through transforms into datasets - and then into researchers and research projects)
                Assert.Contains(cat, ci.GetObjectsDependingOnThis());
                Assert.Contains(ci, cat.GetObjectsThisDependsOn());

                //catalogue item should not be relying on anything currently (no link to underlying technical data)
                Assert.IsNull(ci.GetObjectsThisDependsOn());

                //now they are associated so the ci should be dependent on the col
                ci.SetColumnInfo(col);
                Assert.Contains(col, ci.GetObjectsDependingOnThis());
            }
            finally
            {
                t.DeleteInDatabase();
                cat.DeleteInDatabase();
            }
        }
예제 #8
0
파일: BulkTestsData.cs 프로젝트: rkm/RDMP
        /// <summary>
        /// Deletes the rdmp metadata objects (but not the actual <see cref="BulkDataTable"/>)
        /// </summary>
        public void DeleteCatalogue()
        {
            var creds = (DataAccessCredentials)tableInfo.GetCredentialsIfExists(DataAccessContext.InternalDataProcessing);

            if (tableInfo.Exists())
            {
                tableInfo.DeleteInDatabase();
            }

            if (creds != null)
            {
                try
                {
                    creds.DeleteInDatabase();
                }
                catch (CredentialsInUseException e)
                {
                    Console.WriteLine("Ignored Potential Exception:" + e);
                }
            }

            if (catalogue.Exists())
            {
                catalogue.DeleteInDatabase();
            }
        }
예제 #9
0
        private void CleanCatalogueDatabase()
        {
            if (_catalogue != null)
            {
                _catalogue.DeleteInDatabase();
            }

            // ensure the database is cleared of test remnants
            foreach (var ji in CatalogueRepository.GetAllObjects <JoinInfo>())
            {
                ji.DeleteInDatabase();
            }

            // column infos don't appear to delete
            foreach (var ci in CatalogueRepository.GetAllObjects <ColumnInfo>())
            {
                ci.DeleteInDatabase();
            }

            foreach (var ti in CatalogueRepository.GetAllObjects <TableInfo>())
            {
                ti.DeleteInDatabase();
            }

            foreach (var credentials in CatalogueRepository.GetAllObjects <DataAccessCredentials>())
            {
                credentials.DeleteInDatabase();
            }
        }
예제 #10
0
 public void TearDown()
 {
     _config.DeleteInDatabase();
     _extractionInformation.DeleteInDatabase();
     _table.DeleteInDatabase();
     _cata.DeleteInDatabase();
 }
예제 #11
0
        public void CreateNewExternalServerAndConfigureItAsDefault()
        {
            ServerDefaults defaults = new ServerDefaults(CatalogueRepository);

            var databaseServer = new ExternalDatabaseServer(CatalogueRepository, "Deleteme", null);

            try
            {
                Assert.AreEqual("Deleteme", databaseServer.Name);
                databaseServer.Password = "******";                               //automatically encrypts password

                Assert.AreNotEqual("nothing", databaseServer.Password);            //should not match what we just set it to
                Assert.AreEqual("nothing", databaseServer.GetDecryptedPassword()); //should match what we set it to because of explicit call to decrypt

                databaseServer.Server   = "Bob";
                databaseServer.Database = "TEST";
                databaseServer.SaveToDatabase();

                Catalogue cata = new Catalogue(CatalogueRepository, "TestCatalogueFor_CreateNewExternalServerAndConfigureItAsDefault");
                cata.DeleteInDatabase();
            }
            finally
            {
                databaseServer.DeleteInDatabase();
            }
        }
예제 #12
0
        public void CreateCatalogueWithNoAcronym_CrashesDITAExtractor()
        {
            var testDir = _directoryHelper.Directory;

            try
            {
                //create a new Catalogue in the test datbaase that doesnt have a acronym (should crash Dita Extractor)
                Catalogue myNewCatalogue = new Catalogue(CatalogueRepository, "UnitTestCatalogue");
                myNewCatalogue.Acronym = "";
                myNewCatalogue.SaveToDatabase();

                try
                {
                    DitaCatalogueExtractor extractor = new DitaCatalogueExtractor(CatalogueRepository, testDir);
                    var ex = Assert.Throws <Exception>(() => extractor.Extract(new ThrowImmediatelyDataLoadEventListener()));
                    Assert.AreEqual("Dita Extraction requires that each catalogue have a unique Acronym, the catalogue UnitTestCatalogue is missing an Acronym", ex.Message);
                }
                finally
                {
                    myNewCatalogue.DeleteInDatabase();
                }
            }
            finally
            {
                foreach (var file in testDir.GetFiles())
                {
                    file.Delete();
                }
            }
        }
예제 #13
0
        public void CatalogueFolder_SubfolderingDuplicateNames()
        {
            var c1 = new Catalogue(Repository, "C1");
            var c2 = new Catalogue(Repository, "C2");
            var c3 = new Catalogue(Repository, "C3");

            try
            {
                c1.Folder.Path = @"\A\B\C\";
                c1.SaveToDatabase();

                c2.Folder.Path = @"\B\C\";
                c2.SaveToDatabase();

                c3.Folder.Path = @"\A\B\";
                c3.SaveToDatabase();

                //c1 is a subfolder of c3
                Assert.IsFalse(c1.Folder.IsSubFolderOf(c2.Folder));
                Assert.IsTrue(c1.Folder.IsSubFolderOf(c3.Folder));

                //c2 is nobodies subfolder
                Assert.IsFalse(c2.Folder.IsSubFolderOf(c1.Folder));
                Assert.IsFalse(c2.Folder.IsSubFolderOf(c3.Folder));

                //c2 is nobodies subfolder
                Assert.IsFalse(c3.Folder.IsSubFolderOf(c1.Folder));
                Assert.IsFalse(c3.Folder.IsSubFolderOf(c2.Folder));
            }
            finally
            {
                c1.DeleteInDatabase();
                c2.DeleteInDatabase();
            }
        }
예제 #14
0
            public void Dispose()
            {
                if (Catalogue != null)
                {
                    Catalogue.DeleteInDatabase();
                }

                if (LoadMetadata != null)
                {
                    LoadMetadata.DeleteInDatabase();
                }

                if (ColumnInfo != null)
                {
                    ColumnInfo.DeleteInDatabase();
                }

                if (TableInfo != null)
                {
                    TableInfo.DeleteInDatabase();
                }

                if (Credentials != null)
                {
                    Credentials.DeleteInDatabase();
                }
            }
예제 #15
0
        public void GetCatalogueWithID_validID_pass()
        {
            Catalogue c = new Catalogue(Repository, "TEST");

            Assert.NotNull(c);
            Assert.True(c.Name == "TEST");

            c.DeleteInDatabase();
        }
예제 #16
0
        private void AddToExistingCatalogue(Catalogue addToInstead, ExtractionInformation[] eis)
        {
            //move all the CatalogueItems to the other Catalogue instead
            foreach (ExtractionInformation ei in eis)
            {
                var ci = ei.CatalogueItem;
                ci.Catalogue_ID = addToInstead.ID;
                ci.SaveToDatabase();
            }

            _choicesFinalised = true;
            _catalogue.DeleteInDatabase();
            _catalogue = null;

            Activator.RefreshBus.Publish(this, new RefreshObjectEventArgs(addToInstead));

            Close();
        }
예제 #17
0
        public void Test_GetObjects_Catalogue()
        {
            Catalogue catalogueWithId = new Catalogue(Repository, "bob");

            Catalogue[] catas = Repository.GetAllObjects <Catalogue>();

            Assert.IsTrue(catas.Length > 0);

            catalogueWithId.DeleteInDatabase();
        }
예제 #18
0
        public void test_SupportingDocument_CreateAndDestroy()
        {
            Catalogue          cata = new Catalogue(CatalogueRepository, "deleteme");
            SupportingDocument doc  = new SupportingDocument(CatalogueRepository, cata, "davesFile");

            Assert.AreEqual(doc.Name, "davesFile");

            doc.DeleteInDatabase();
            cata.DeleteInDatabase();
        }
예제 #19
0
        public void TearDown()
        {
            cic.DeleteInDatabase();

            acCohort.DeleteInDatabase();
            acDataset.DeleteInDatabase();

            t.DeleteInDatabase();
            c.DeleteInDatabase();
        }
예제 #20
0
        public void Test_RowVer()
        {
            var cata = new Catalogue(CatalogueRepository, "FFFF");

            //When we get all the Catalogues we should include cata
            Assert.Contains(cata, CatalogueRepository.GetAllObjects <Catalogue>());
            Assert.AreEqual(cata, CatalogueRepository.GetAllObjects <Catalogue>()[0]);
            Assert.AreNotSame(cata, CatalogueRepository.GetAllObjects <Catalogue>()[0]);

            //create a cache
            var rowVerCache = new RowVerCache <Catalogue>(CatalogueRepository);

            //should fill the cache
            cata = rowVerCache.GetAllObjects()[0];

            //should return the same instance
            Assert.AreSame(cata, rowVerCache.GetAllObjects()[0]);

            cata.DeleteInDatabase();
            Assert.IsEmpty(rowVerCache.GetAllObjects());

            //create some catalogues
            new Catalogue(CatalogueRepository, "1");
            new Catalogue(CatalogueRepository, "2");
            new Catalogue(CatalogueRepository, "3");

            //fill up the cache
            rowVerCache.GetAllObjects();

            //give it a fresh object
            var cata2 = new Catalogue(CatalogueRepository, "dddd");

            //fresh fetch for this
            Assert.Contains(cata2, rowVerCache.GetAllObjects());
            Assert.IsFalse(rowVerCache.GetAllObjects().Contains(cata));

            //change a value in the background but first make sure that what the cache has is a Equal but not reference to cata2
            Assert.IsFalse(rowVerCache.GetAllObjects().Any(o => ReferenceEquals(o, cata2)));
            Assert.IsTrue(rowVerCache.GetAllObjects().Any(o => Equals(o, cata2)));

            cata2.Name = "boom";
            cata2.SaveToDatabase();

            Assert.AreEqual(1, rowVerCache.GetAllObjects().Count(c => c.Name.Equals("boom")));

            cata2.Name = "vroom";
            cata2.SaveToDatabase();

            Assert.AreEqual(1, rowVerCache.GetAllObjects().Count(c => c.Name.Equals("vroom")));

            Assert.AreEqual(1, rowVerCache.GetAllObjects().Count(c => c.Name.Equals("vroom")));

            Assert.IsFalse(rowVerCache.Broken);
        }
예제 #21
0
        public void CatalogueCheck_DodgyName()
        {
            var cata = new Catalogue(CatalogueRepository, "fish");

            //name broken
            cata.Name = @"c:\bob.txt#";
            var ex = Assert.Throws <Exception>(() => cata.Check(new ThrowImmediatelyCheckNotifier()));

            Assert.IsTrue(ex.Message.Contains("The following invalid characters were found:'\\','.','#'"));

            cata.DeleteInDatabase();
        }
예제 #22
0
        public void TestSettingColumnInfoToNull()
        {
            var parent = new Catalogue(CatalogueRepository, "GROG");

            CatalogueItem child1 = new CatalogueItem(CatalogueRepository, parent, "GROG_ITEM1");

            child1.SetColumnInfo(null);

            Assert.IsNull(child1.ColumnInfo_ID);
            child1.DeleteInDatabase();
            parent.DeleteInDatabase();
        }
예제 #23
0
        public void Destroy()
        {
            var credentials = (DataAccessCredentials)TableInfoCreated.GetCredentialsIfExists(DataAccessContext.InternalDataProcessing);

            TableInfoCreated.DeleteInDatabase();

            if (credentials != null)
            {
                credentials.DeleteInDatabase();
            }

            Cata.DeleteInDatabase();
        }
예제 #24
0
        public void FindSameName_MixedCaps()
        {
            var cata1 = new Catalogue(Repository, "Bob");
            var cata2 = new Catalogue(Repository, "bob");

            var activator = new ThrowImmediatelyActivator(RepositoryLocator);
            var cmd       = new ExecuteCommandSimilar(activator, cata1, false);

            Assert.AreEqual(cata2, cmd.Matched.Single());

            cata1.DeleteInDatabase();
            cata2.DeleteInDatabase();
        }
예제 #25
0
        public void CatalogueFolder_DefaultIsRoot()
        {
            var c = new Catalogue(Repository, "bob");

            try
            {
                Assert.AreEqual("\\", c.Folder.Path);
            }
            finally
            {
                c.DeleteInDatabase();
            }
        }
예제 #26
0
        public void clone_CloneCatalogueItemWithIDIntoCatalogue_passes()
        {
            Catalogue parent  = new Catalogue(CatalogueRepository, "KONGOR");
            Catalogue parent2 = new Catalogue(CatalogueRepository, "KONGOR2");

            CatalogueItem child = new CatalogueItem(CatalogueRepository, parent, "KONGOR_SUPERKING")
            {
                Agg_method  = "Adding SetUp",
                Comments    = "do not change amagad super secret!",
                Limitations = "Extreme limitaitons",
                Description =
                    "Exciting things are going down in the streets of new your this time of year it would be a great idea if you were to go there",
                Name               = "KONGOR_MINIMAN",
                Periodicity        = Catalogue.CataloguePeriodicity.Monthly,
                Research_relevance = "Highly relevant to all fields of subatomic particle study",
                Statistical_cons   = "Dangerous cons frequent the areas that this stats is happening, be afraid",
                Topic              = "nothing much, lots of stuff"
            };

            CatalogueItem cloneChild = null;

            try
            {
                child.SaveToDatabase();
                cloneChild = child.CloneCatalogueItemWithIDIntoCatalogue(parent2);

                //get the clone that was returned
                Assert.AreEqual(cloneChild.Catalogue_ID, parent2.ID);   //it is in the second one
                Assert.AreNotEqual(cloneChild.Catalogue_ID, parent.ID); //it is not in the first one
                Assert.AreNotEqual(cloneChild.ID, child.ID);            //it has a new ID

                Assert.AreEqual(cloneChild.Limitations, child.Limitations);
                Assert.AreEqual(cloneChild.Description, child.Description);
                Assert.AreEqual(cloneChild.Name, child.Name);
                Assert.AreEqual(cloneChild.Periodicity, child.Periodicity);
                Assert.AreEqual(cloneChild.Research_relevance, child.Research_relevance);
                Assert.AreEqual(cloneChild.Statistical_cons, child.Statistical_cons);
                Assert.AreEqual(cloneChild.Topic, child.Topic);
            }
            finally
            {
                if (cloneChild != null)
                {
                    cloneChild.DeleteInDatabase();
                }

                child.DeleteInDatabase();
                parent.DeleteInDatabase();
                parent2.DeleteInDatabase();
            }
        }
예제 #27
0
        public void CatalogueFolder_CannotSetToNull()
        {
            var c = new Catalogue(Repository, "bob");

            try
            {
                var ex = Assert.Throws <NotSupportedException>(() => c.Folder.Path = null);
                Assert.AreEqual(@"An attempt was made to set Catalogue bob Folder to null, every Catalogue must have a folder, set it to \ if you want the root", ex.Message);
            }
            finally
            {
                c.DeleteInDatabase();
            }
        }
예제 #28
0
        public void CatalogueFolder_CannotSetToNonRoot()
        {
            var c = new Catalogue(Repository, "bob");

            try
            {
                var ex = Assert.Throws <NotSupportedException>(() => c.Folder.Path = "fish");
                Assert.AreEqual(@"All catalogue paths must start with \ but Catalogue bob had an attempt to set it's folder to :fish", ex.Message);
            }
            finally
            {
                c.DeleteInDatabase();
            }
        }
예제 #29
0
        public void GatherAndShare_ExtractionFilter_Test()
        {
            //Setup some objects under Catalogue
            var cata = new Catalogue(CatalogueRepository, "Cata");

            cata.Periodicity = Catalogue.CataloguePeriodicity.BiMonthly;
            cata.SaveToDatabase();

            var catalogueItem1 = new CatalogueItem(CatalogueRepository, cata, "Ci1");

            var tableInfo = new TableInfo(CatalogueRepository, "Myt");
            var colInfo   = new ColumnInfo(CatalogueRepository, "[Mt].[C1]", "varchar(10)", tableInfo);

            catalogueItem1.ColumnInfo_ID = colInfo.ID;
            catalogueItem1.SaveToDatabase();

            //Setup a Filter under this extractable column (the filter is what we will share)
            var ei = new ExtractionInformation(CatalogueRepository, catalogueItem1, colInfo, "UPPER(C1) as Fish");

            var filter = new ExtractionFilter(CatalogueRepository, "My Filter", ei);

            filter.Description = "amagad";
            filter.WhereSQL    = "UPPER(C1) = @a";

            //Give the filter a parameter @a just to make things interesting
            var declaration = filter.GetQuerySyntaxHelper().GetParameterDeclaration("@a", new DatabaseTypeRequest(typeof(string), 1));
            var param       = filter.GetFilterFactory().CreateNewParameter(filter, declaration);

            //Also create a 'known good value' set i.e. recommended value for the parameter to achive some goal (you can have multiple of these - this will not be shared)
            var set = new ExtractionFilterParameterSet(CatalogueRepository, filter, "Fife");
            var val = new ExtractionFilterParameterSetValue(CatalogueRepository, set, (ExtractionFilterParameter)param);

            val.Value = "'FISH'";

            //Gather the dependencies (this is what we are testing)
            var gatherer = new Gatherer(RepositoryLocator);

            Assert.IsTrue(gatherer.CanGatherDependencies(filter));
            var gathered = gatherer.GatherDependencies(filter);

            //gatherer should have gathered the filter and the parameter (but not the ExtractionFilterParameterSet sets)
            Assert.AreEqual(1, gathered.Children.Count);
            Assert.AreEqual(param, gathered.Children[0].Object);

            //Cleanup
            val.DeleteInDatabase();
            set.DeleteInDatabase();
            cata.DeleteInDatabase();
        }
예제 #30
0
 private void MessWithCatalogue()
 {
     try
     {
         var repository = new CatalogueRepository(CatalogueRepository.ConnectionStringBuilder);
         var cata       = new Catalogue(repository, "bob");
         cata.Name = "Fuss";
         cata.SaveToDatabase();
         cata.DeleteInDatabase();
     }
     catch (Exception ex)
     {
         asyncExceptions.Add(ex);
     }
 }