public void Test_NoDatasetToken(string badString) { var dest = new ExecuteDatasetExtractionFlatFileDestination(); dest.ExtractionSubdirectoryPattern = badString; var ex = Assert.Throws <Exception>(() => dest.Check(new ThrowImmediatelyCheckNotifier())); StringAssert.Contains("ExtractionSubdirectoryPattern must contain a Dataset element", ex.Message); }
public void Test_NoRelativePaths() { var dest = new ExecuteDatasetExtractionFlatFileDestination(); dest.ExtractionSubdirectoryPattern = "../../troll"; var ex = Assert.Throws <Exception>(() => dest.Check(new ThrowImmediatelyCheckNotifier())); StringAssert.Contains("ExtractionSubdirectoryPattern cannot contain dots", ex.Message); }
public void ExtractionDestination_FloatRounding(bool lotsOfDecimalPlaces) { var dest = new ExecuteDatasetExtractionFlatFileDestination(); var dt = new DataTable(); dt.Columns.Add("Floats", typeof(decimal)); dt.Rows.Add(Math.PI); var lm = new LogManager(new DiscoveredServer(UnitTestLoggingConnectionString)); lm.CreateNewLoggingTaskIfNotExists("ExtractionDestination_FloatRounding"); var dli = lm.CreateDataLoadInfo("ExtractionDestination_FloatRounding", nameof(ExecuteDatasetExtractionFlatFileDestinationTests), "test", "", true); if (_request.QueryBuilder == null) { _request.GenerateQueryBuilder(); } dest.RoundFloatsTo = lotsOfDecimalPlaces ? 10 : 2; dest.PreInitialize(_request, new ThrowImmediatelyDataLoadEventListener()); dest.PreInitialize(_project, new ThrowImmediatelyDataLoadEventListener()); dest.PreInitialize((DataLoadInfo)dli, new ThrowImmediatelyDataLoadEventListener()); dest.ProcessPipelineData(dt, new ThrowImmediatelyDataLoadEventListener(), new GracefulCancellationToken()); dest.Dispose(new ThrowImmediatelyDataLoadEventListener(), null); Assert.IsNotNull(dest.OutputFile); FileAssert.Exists(dest.OutputFile); if (lotsOfDecimalPlaces) { Assert.AreEqual($"Floats{Environment.NewLine}3.1415926536{Environment.NewLine}", File.ReadAllText(dest.OutputFile)); } else { Assert.AreEqual($"Floats{Environment.NewLine}3.14{Environment.NewLine}", File.ReadAllText(dest.OutputFile)); } dt.Dispose(); }
public void Test_ValidPaths(string goodString, string pattern) { var sds = WhenIHaveA <SelectedDataSets>(); sds.ExtractionConfiguration.Project.ExtractionDirectory = TestContext.CurrentContext.WorkDirectory; sds.ExtractionConfiguration.Name = "AAA"; sds.ExtractableDataSet.Catalogue.Name = "BBB"; sds.ExtractableDataSet.Catalogue.Acronym = "C"; var cmd = new ExtractDatasetCommand(sds.ExtractionConfiguration, new ExtractableDatasetBundle(sds.ExtractableDataSet)); var dest = new ExecuteDatasetExtractionFlatFileDestination(); dest.ExtractionSubdirectoryPattern = goodString; Assert.DoesNotThrow(() => dest.Check(new ThrowImmediatelyCheckNotifier())); var answer = dest.GetDirectoryFor(cmd); StringAssert.IsMatch(pattern, answer.FullName.Replace('\\', '/')); }