Пример #1
0
 public void TearDown()
 {
     _config.DeleteInDatabase();
     _extractionInformation.DeleteInDatabase();
     _table.DeleteInDatabase();
     _cata.DeleteInDatabase();
 }
Пример #2
0
        public void test_creating_ExtractionInformation()
        {
            ExtractionInformation extractInfo = null;

            try
            {
                //define extraction information
                //change some values and then save it
                extractInfo = new ExtractionInformation(CatalogueRepository, cataItem, columnInfo, "dave")
                {
                    Order = 123,
                    ExtractionCategory = ExtractionCategory.Supplemental
                };
                extractInfo.SaveToDatabase();

                //confirm the insert worked
                Assert.AreEqual(extractInfo.SelectSQL, "dave");

                //fetch the extraction information via the linked CatalogueItem - ColumnInfo pair (i.e. we are testing the alternate route to fetch ExtractionInformation - by ID or by colum/item pair)
                ExtractionInformation extractInfo2_CameFromLinker = cataItem.ExtractionInformation;
                Assert.AreEqual(extractInfo.ID, extractInfo2_CameFromLinker.ID);
                Assert.AreEqual(extractInfo.SelectSQL, extractInfo2_CameFromLinker.SelectSQL);

                //make sure it saves properly
                Assert.AreEqual(extractInfo2_CameFromLinker.Order, 123);
                Assert.AreEqual(extractInfo2_CameFromLinker.ExtractionCategory, ExtractionCategory.Supplemental);
            }
            finally
            {
                if (extractInfo != null)
                {
                    extractInfo.DeleteInDatabase();
                }
            }
        }
Пример #3
0
        public void test_creating_ExtractionFilter()
        {
            ExtractionInformation     extractInfo      = null;
            ExtractionFilter          filterFastThings = null;
            ExtractionFilterParameter parameter        = null;

            try
            {
                //define extraction information
                extractInfo = new ExtractionInformation(CatalogueRepository, cataItem, columnInfo, "ROUND(VelocityOfMatter,2) VelocityOfMatterRounded");

                //define filter and parameter
                filterFastThings = new ExtractionFilter(CatalogueRepository, "FastThings", extractInfo)
                {
                    WhereSQL    = "VelocityOfMatter > @X",
                    Description = "Query to identify things that travel faster than X miles per hour!"
                };
                filterFastThings.SaveToDatabase();
                Assert.AreEqual(filterFastThings.Name, "FastThings");

                parameter = new ExtractionFilterParameter(CatalogueRepository, "DECLARE @X INT", filterFastThings);

                Assert.IsNotNull(parameter);
                Assert.AreEqual(parameter.ParameterName, "@X");

                parameter.Value = "500";
                parameter.SaveToDatabase();

                ExtractionFilterParameter afterSave = CatalogueRepository.GetObjectByID <ExtractionFilterParameter>(parameter.ID);
                Assert.AreEqual(afterSave.Value, "500");


                ExtractionFilter filterFastThings_NewCopyFromDB = CatalogueRepository.GetObjectByID <ExtractionFilter>(filterFastThings.ID);

                Assert.AreEqual(filterFastThings.ID, filterFastThings_NewCopyFromDB.ID);
                Assert.AreEqual(filterFastThings.Description, filterFastThings_NewCopyFromDB.Description);
                Assert.AreEqual(filterFastThings.Name, filterFastThings_NewCopyFromDB.Name);
                Assert.AreEqual(filterFastThings.WhereSQL, filterFastThings_NewCopyFromDB.WhereSQL);
            }
            finally
            {
                if (parameter != null)
                {
                    parameter.DeleteInDatabase();
                }

                //filters are children of extraction info with CASCADE DELETE so have to delete this one first if we want to test it programatically (although we could just skip deleting it since SQL will handle it anyway)
                if (filterFastThings != null)
                {
                    filterFastThings.DeleteInDatabase();
                }

                if (extractInfo != null)
                {
                    extractInfo.DeleteInDatabase();
                }
            }
        }
Пример #4
0
        public void ExtractableColumnTest()
        {
            ExtractableDataSet      dataSet       = null;
            ExtractionConfiguration configuration = null;
            Project project = null;

            Catalogue     cata     = null;
            CatalogueItem cataItem = null;
            ColumnInfo    column   = null;
            TableInfo     table    = null;

            ExtractionInformation extractionInformation = null;
            ExtractableColumn     extractableColumn     = null;

            try
            {
                //setup catalogue side of things
                cata     = new Catalogue(CatalogueRepository, "unit_test_ExtractableColumnTest_Cata");
                cataItem = new CatalogueItem(CatalogueRepository, cata, "unit_test_ExtractableColumnTest_CataItem");
                table    = new TableInfo(CatalogueRepository, "DaveTable");
                column   = new ColumnInfo(CatalogueRepository, "Name", "string", table);
                cataItem.SetColumnInfo(column);

                extractionInformation = new ExtractionInformation(CatalogueRepository, cataItem, column, "Hashme(Name)");

                //setup extractor side of things
                dataSet = new ExtractableDataSet(DataExportRepository, cata);
                project = new Project(DataExportRepository, "unit_test_ExtractableColumnTest_Proj");

                configuration = new ExtractionConfiguration(DataExportRepository, project);

                extractableColumn = new ExtractableColumn(DataExportRepository, dataSet, configuration, extractionInformation, 0, "Hashme2(Name)");
                Assert.AreEqual(configuration.GetAllExtractableColumnsFor(dataSet).Length, 1);
            }
            finally
            {
                if (extractionInformation != null)
                {
                    extractionInformation.DeleteInDatabase();
                }

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

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

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

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

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

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

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