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(); }
public void ExtractionFilterParameterSet_Deleting() { var cata = new Catalogue(CatalogueRepository, "myCata"); var cataItem = new CatalogueItem(CatalogueRepository, cata, "MyCol"); var table = new TableInfo(CatalogueRepository, "myTbl"); var col = new ColumnInfo(CatalogueRepository, "myCol", "varchar(10)", table); var ei = new ExtractionInformation(CatalogueRepository, cataItem, col, "[myTbl].[mycol]"); var filter = new ExtractionFilter(CatalogueRepository, "Age", ei); filter.WhereSQL = "Age >= @age"; new ExtractionFilterParameter(CatalogueRepository, "DECLARE @age int", filter); var paramSet = new ExtractionFilterParameterSet(CatalogueRepository, filter, "Old"); var vals = paramSet.CreateNewValueEntries(); Assert.AreEqual(1, vals.Length); Assert.IsTrue(vals[0].Exists()); paramSet.DeleteInDatabase(); Assert.IsFalse(paramSet.Exists()); Assert.IsFalse(vals[0].Exists()); }