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(); }
public void DatasetIsDisabled() { _extractableDataSet.DisableExtraction = true; _extractableDataSet.SaveToDatabase(); //checking should fail var exception = Assert.Throws <Exception>(() => new ProjectChecker(new ThrowImmediatelyActivator(RepositoryLocator), _project).Check(new ThrowImmediatelyCheckNotifier { ThrowOnWarning = true })); Assert.AreEqual("Dataset TestTable is set to DisableExtraction=true, probably someone doesn't want you extracting this dataset at the moment", exception.Message); //but if the user goes ahead and executes the extraction that should fail too var source = new ExecuteDatasetExtractionSource(); source.PreInitialize(_request, new ThrowImmediatelyDataLoadEventListener()); var exception2 = Assert.Throws <Exception>(() => source.GetChunk(new ThrowImmediatelyDataLoadEventListener(), new GracefulCancellationToken())); Assert.AreEqual("Cannot extract TestTable because DisableExtraction is set to true", exception2.Message); }