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);
        }
コード例 #2
0
        private void TestDataExportOfTvf()
        {
            var config = new ExtractionConfiguration(DataExportRepository, _project);

            config.Cohort_ID = DataExportRepository.GetAllObjects <ExtractableCohort>().Single().ID;
            config.SaveToDatabase();

            var tvfExtractable = new ExtractableDataSet(DataExportRepository, _tvfCatalogue);

            var selected = new SelectedDataSets(DataExportRepository, config, tvfExtractable, null);

            //make all columns part of the extraction
            foreach (ExtractionInformation e in _tvfCatalogue.GetAllExtractionInformation(ExtractionCategory.Any))
            {
                config.AddColumnToExtraction(tvfExtractable, e);
            }

            //the default value should be 10
            Assert.AreEqual("10", _tvfTableInfo.GetAllParameters().Single().Value);

            //configure an extraction specific global of 1 so that only 1 chi number is fetched (which will be in the cohort)
            var globalP = new GlobalExtractionFilterParameter(DataExportRepository, config, "DECLARE @numberOfRecords AS int;");

            globalP.Value = "1";
            globalP.SaveToDatabase();

            var extractionCommand = new ExtractDatasetCommand(config, new ExtractableDatasetBundle(tvfExtractable));

            var source = new ExecuteDatasetExtractionSource();

            source.PreInitialize(extractionCommand, new ThrowImmediatelyDataLoadEventListener());

            var dt = source.GetChunk(new ThrowImmediatelyDataLoadEventListener(), new GracefulCancellationToken());

            Assert.AreEqual(1, dt.Rows.Count);

            Assert.AreEqual("ReleaseId", dt.Columns[0].ColumnName);

            //should be a guid
            Assert.IsTrue(dt.Rows[0][0].ToString().Length > 10);
            Assert.IsTrue(dt.Rows[0][0].ToString().Contains("-"));

            selected.DeleteInDatabase();
            globalP.DeleteInDatabase();
            config.DeleteInDatabase();

            tvfExtractable.DeleteInDatabase();
        }
コード例 #3
0
ファイル: SelectedColumnsTests.cs プロジェクト: 24418863/rdm
        public void CreateAndAssociateColumns()
        {
            var cata           = new Catalogue(CatalogueRepository, "MyCat");
            var cataItem       = new CatalogueItem(CatalogueRepository, cata, "MyCataItem");
            var TableInfo      = new TableInfo(CatalogueRepository, "Cata");
            var ColumnInfo     = new ColumnInfo(CatalogueRepository, "Col", "varchar(10)", TableInfo);
            var ExtractionInfo = new ExtractionInformation(CatalogueRepository, cataItem, ColumnInfo, "fish");

            var ds = new ExtractableDataSet(DataExportRepository, cata);

            var proj   = new Project(DataExportRepository, "MyProj");
            var config = new ExtractionConfiguration(DataExportRepository, proj);

            SelectedDataSets selectedDataSets;

            var extractableColumn = new ExtractableColumn(DataExportRepository, ds, config, ExtractionInfo, 1, "fish");

            try
            {
                selectedDataSets = new SelectedDataSets(DataExportRepository, config, ds, null);

                var cols = config.GetAllExtractableColumnsFor(ds);

                Assert.AreEqual(1, cols.Count());
                Assert.AreEqual(extractableColumn, cols.Single());

                cols = config.GetAllExtractableColumnsFor(ds);

                Assert.AreEqual(1, cols.Count());
                Assert.AreEqual(extractableColumn, cols.Single());
            }
            finally
            {
                extractableColumn.DeleteInDatabase();
                config.DeleteInDatabase();
                proj.DeleteInDatabase();

                ds.DeleteInDatabase();

                TableInfo.DeleteInDatabase();
                cata.DeleteInDatabase();
            }
        }
コード例 #4
0
        public void CreateExtractableDataSet()
        {
            ExtractableDataSet eds = null;
            var cata = new Catalogue(CatalogueRepository, "TestExtractableTables Cata");

            try
            {
                //creates with a Null Catalogue until it is associated with a catalogue and saved
                eds = new ExtractableDataSet(DataExportRepository, cata);
                Assert.AreEqual(cata.ID, eds.Catalogue_ID);
            }
            finally
            {
                if (eds != null)
                {
                    eds.DeleteInDatabase();
                }

                cata.DeleteInDatabase();
            }
        }
        public void AllowDeletingWhenDataExportManagerIsNotSet()
        {
            var noDataExportManagerExists = new LinkedRepositoryProvider(CatalogueRepository.ConnectionString,null);

            var obscura1 = new BetweenCatalogueAndDataExportObscureDependencyFinder(RepositoryLocator);
            var obscura2 = new BetweenCatalogueAndDataExportObscureDependencyFinder(noDataExportManagerExists);

            var cata = new Catalogue(CatalogueRepository, "MyCata");
            var dataset = new ExtractableDataSet(DataExportRepository,cata);

            //we cannot delete it because there is a dependency
            var ex = Assert.Throws<Exception>(() => obscura1.ThrowIfDeleteDisallowed(cata));
            Assert.IsTrue(ex.Message.Contains("Cannot delete Catalogue MyCata because there are ExtractableDataSets which depend on them "));

            //the second finder simulates when the repository locator doesn't have a record of the data export repository so it is unable to check it so it will let you delete it just fine
            Assert.DoesNotThrow(() => obscura2.ThrowIfDeleteDisallowed(cata));

            //now delete them in the correct order
            dataset.DeleteInDatabase();
            cata.DeleteInDatabase();

        }
コード例 #6
0
ファイル: PackageContentsTests.cs プロジェクト: 24418863/rdm
        public void AddAndRemove()
        {
            var cata = new Catalogue(CatalogueRepository, "PackageContentsTests");

            var ds = new ExtractableDataSet(DataExportRepository, cata);

            var package = new ExtractableDataSetPackage(DataExportRepository, "My Cool Package");

            try
            {
                Assert.AreEqual("My Cool Package", package.Name);
                package.Name = "FishPackage";
                package.SaveToDatabase();


                var packageContents = new ExtractableDataSetPackageManager(DataExportRepository);

                var results = packageContents.GetAllDataSets(package, null);
                Assert.AreEqual(0, results.Length);

                packageContents.AddDataSetToPackage(package, ds);

                results = packageContents.GetAllDataSets(package, DataExportRepository.GetAllObjects <ExtractableDataSet>());
                Assert.AreEqual(1, results.Length);
                Assert.AreEqual(ds, results[0]);

                packageContents.RemoveDataSetFromPackage(package, ds);

                //cannot delete the relationship twice
                Assert.Throws <ArgumentException>(() => packageContents.RemoveDataSetFromPackage(package, ds));
            }
            finally
            {
                ds.DeleteInDatabase();
                package.DeleteInDatabase();
                cata.DeleteInDatabase();
            }
        }
コード例 #7
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();
                }
            }
        }