public void CSVParseTestSuccess() { var dataSource = new WindowsFileSystem(_csvDataFilePath); var dataFromFileSystem = dataSource.FetchData(); var dataToImport = new CSVDataToImport(dataFromFileSystem); var dataSourceLocation = new CSVDataSourceLocation(6, 3); var dataDateTimeSourceLocation = new CSVDataSourceLocation(6, 0); var parser = new CellParser(new DefaultParserFactory()); var parseDoubleResult = parser.Parse(dataToImport, dataSourceLocation, typeof(double)); Assert.NotNull(parseDoubleResult); Assert.AreEqual(parseDoubleResult.Level, ResultLevel.INFO); Assert.AreEqual(parseDoubleResult.Message, "Parsing value successfully"); Assert.AreEqual(0.3, ((IParsingResult)parseDoubleResult).Value); var parseDateTimeResult = parser.Parse(dataToImport, dataDateTimeSourceLocation, typeof(DateTime)); Assert.NotNull(parseDateTimeResult); Assert.AreEqual(parseDateTimeResult.Level, ResultLevel.INFO); Assert.AreEqual(parseDateTimeResult.Message, "Parsing value successfully"); Assert.AreEqual(new DateTime(2013, 12, 12, 14, 0, 0), ((IParsingResult)parseDateTimeResult).Value); }
public void CSVDataToImportReadCSVFileTest() { var dataSource = new WindowsFileSystem(_csvDataFilePath); var dataFromFileSystem = dataSource.FetchData(); var dataToImport = new CSVDataToImport(dataFromFileSystem); AssertData(Path.GetFileName(_csvDataFilePath), dataToImport); }
private CSVDataToImport CreateCSVDataToImport(string filePath) { var dataSource = new WindowsFileSystem(filePath); var dataFromFileSystem = dataSource.FetchData(); var dataToImport = new CSVDataToImport(dataFromFileSystem); return(dataToImport); }
public static XMLDataToImport CreateXMLDatoToImport(string filePath) { var dataSource = new WindowsFileSystem(filePath); var dataFromFileSystem = dataSource.FetchData(); var dataToImport = new XMLDataToImport(dataFromFileSystem); return(dataToImport); }
public void XMLDataToImportReadXMLFileTest() { var dataSource = new WindowsFileSystem(_xmlDataFilePath); var dataFromFileSystem = dataSource.FetchData(); var dataToImport = new XMLDataToImport(dataFromFileSystem); AssertData(Path.GetFileName(_xmlDataFilePath), dataToImport); }
private IDataToImport GetDataToImport(string fileName) { var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DataFiles", fileName); var dataSource = new WindowsFileSystem(path); var dataFromFileSystem = dataSource.FetchData(); var dataToImport = new XMLDataToImport(dataFromFileSystem); return dataToImport; }
private IDataToImport GetDataToImport(string fileName) { var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DataFiles", fileName); var dataSource = new WindowsFileSystem(path); var dataFromFileSystem = dataSource.FetchData(); var dataToImport = new CSVDataToImport(dataFromFileSystem); return(dataToImport); }
private IExtractConfiguration CreateSampleFileDataExtractConfiguration() { var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DataFiles", "SampleFileExample.csv"); var dataSource = new WindowsFileSystem(path); var dataFromFileSystem = dataSource.FetchData(); var dataToImport = new CSVDataToImport(dataFromFileSystem); var simpleValueAssginer = new SimpleValueAssigner(); var sampleDataImporter = ESDATTestHelper.BuildSampleDataFileImporter(); var childObjectExtractConfiguration = new SampleFileChildObjectExtractConfiguration(sampleDataImporter, "SampleFileData", simpleValueAssginer); return(childObjectExtractConfiguration); }
public void ExtractDataTest() { var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DataFiles", "XMLSample.xml"); var dataSource = new WindowsFileSystem(path); var dataFromFileSystem = dataSource.FetchData(); var dataToImport = new XMLDataToImport(dataFromFileSystem); var dataImporter = new TestXMLImporterBuilder().Build(); var extractedDataSet = dataImporter.Extract <ESDATModel>(dataToImport); Assert.NotNull(extractedDataSet); Assert.AreEqual(true, extractedDataSet.IsExtractedSuccess); Assert.AreEqual(1, extractedDataSet.ExtractedEntities.Count()); }
public void ExtractDataTest() { var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DataFiles", "XMLSample.xml"); var dataSource = new WindowsFileSystem(path); var dataFromFileSystem = dataSource.FetchData(); var dataToImport = new XMLDataToImport(dataFromFileSystem); var dataImporter = new TestXMLImporterBuilder().Build(); var extractedDataSet = dataImporter.Extract<ESDATModel>(dataToImport); Assert.NotNull(extractedDataSet); Assert.AreEqual(true, extractedDataSet.IsExtractedSuccess); Assert.AreEqual(1, extractedDataSet.ExtractedEntities.Count()); }
public void ParsingSuccessTest() { var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DataFiles", "XMLSample.xml"); var dataSource = new WindowsFileSystem(path); var dataFromFileSystem = dataSource.FetchData(); var dataToImport = new XMLDataToImport(dataFromFileSystem); var dataSourceLocation = new XMLDataSourceLocation("LabReport", "Lab_Report_Number"); var parserFactory = new DefaultParserFactory(); var testCellParser = new ElementParser(parserFactory); var testParsingResult = testCellParser.Parse(dataToImport, dataSourceLocation, typeof(string)) as ParsingResult; Assert.NotNull(testParsingResult); Assert.AreEqual(ResultLevel.INFO, testParsingResult.Level); Assert.AreEqual("Parsing value successfully", testParsingResult.Message); Assert.AreEqual("LR04927",testParsingResult.Value); }
public void ParsingSuccessTest() { var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DataFiles", "XMLSample.xml"); var dataSource = new WindowsFileSystem(path); var dataFromFileSystem = dataSource.FetchData(); var dataToImport = new XMLDataToImport(dataFromFileSystem); var dataSourceLocation = new XMLDataSourceLocation("LabReport", "Lab_Report_Number"); var parserFactory = new DefaultParserFactory(); var testCellParser = new ElementParser(parserFactory); var testParsingResult = testCellParser.Parse(dataToImport, dataSourceLocation, typeof(string)) as ParsingResult; Assert.NotNull(testParsingResult); Assert.AreEqual(ResultLevel.INFO, testParsingResult.Level); Assert.AreEqual("Parsing value successfully", testParsingResult.Message); Assert.AreEqual("LR04927", testParsingResult.Value); }
public void ExtractChemistryFileDataTest() { var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DataFiles", "ChemistryFileExample.csv"); var dataSource = new WindowsFileSystem(path); var dataFromFileSystem = dataSource.FetchData(); var dataToImport = new CSVDataToImport(dataFromFileSystem); var chemistryFileImporter = BuildChemistryFileImporter(); var extractResult = chemistryFileImporter.Extract<ChemistryFileData>(dataToImport); var allFailResults = extractResult.AllParsingResults.Where(x => x.Level == ResultLevel.ERROR).ToList(); Assert.NotNull(extractResult); Assert.AreEqual(ResultLevel.ERROR, extractResult.ThresholdLevel); Assert.False(allFailResults.Any()); Assert.AreEqual(true, extractResult.IsExtractedSuccess); Assert.AreEqual(9, extractResult.ExtractedEntities.Count()); var firstEntity = extractResult.ExtractedEntities.FirstOrDefault(); Assert.NotNull(firstEntity); Assert.AreEqual("5828314", firstEntity.SampleCode); Assert.AreEqual("100-41-4", firstEntity.ChemCode); Assert.AreEqual("Ethylbenzene", firstEntity.OriginalChemName); Assert.AreEqual("<", firstEntity.Prefix); Assert.AreEqual(0.0005, firstEntity.Result); Assert.AreEqual("mg/L", firstEntity.ResultUnit); Assert.AreEqual("T", firstEntity.TotalOrFiltered); Assert.AreEqual("REG", firstEntity.ResultType); Assert.AreEqual("Inorganic", firstEntity.MethodType); Assert.AreEqual("TO 0332", firstEntity.MethodName); Assert.AreEqual(new DateTime(2014, 9, 23), firstEntity.ExtractionDate); Assert.AreEqual(new DateTime(2014, 9, 24), firstEntity.AnalysedDate); Assert.AreEqual(0.0005, firstEntity.EQL); Assert.AreEqual("mg/L", firstEntity.EQLUnits); Assert.AreEqual(string.Empty, firstEntity.Comments); Assert.AreEqual(50.0d, firstEntity.UCL); Assert.AreEqual(null, firstEntity.LCL); }
public void ExtractChemistryFileDataTest() { var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DataFiles", "ChemistryFileExample.csv"); var dataSource = new WindowsFileSystem(path); var dataFromFileSystem = dataSource.FetchData(); var dataToImport = new CSVDataToImport(dataFromFileSystem); var chemistryFileImporter = BuildChemistryFileImporter(); var extractResult = chemistryFileImporter.Extract <ChemistryFileData>(dataToImport); var allFailResults = extractResult.AllParsingResults.Where(x => x.Level == ResultLevel.ERROR).ToList(); Assert.NotNull(extractResult); Assert.AreEqual(ResultLevel.ERROR, extractResult.ThresholdLevel); Assert.False(allFailResults.Any()); Assert.AreEqual(true, extractResult.IsExtractedSuccess); Assert.AreEqual(9, extractResult.ExtractedEntities.Count()); var firstEntity = extractResult.ExtractedEntities.FirstOrDefault(); Assert.NotNull(firstEntity); Assert.AreEqual("5828314", firstEntity.SampleCode); Assert.AreEqual("100-41-4", firstEntity.ChemCode); Assert.AreEqual("Ethylbenzene", firstEntity.OriginalChemName); Assert.AreEqual("<", firstEntity.Prefix); Assert.AreEqual(0.0005, firstEntity.Result); Assert.AreEqual("mg/L", firstEntity.ResultUnit); Assert.AreEqual("T", firstEntity.TotalOrFiltered); Assert.AreEqual("REG", firstEntity.ResultType); Assert.AreEqual("Inorganic", firstEntity.MethodType); Assert.AreEqual("TO 0332", firstEntity.MethodName); Assert.AreEqual(new DateTime(2014, 9, 23), firstEntity.ExtractionDate); Assert.AreEqual(new DateTime(2014, 9, 24), firstEntity.AnalysedDate); Assert.AreEqual(0.0005, firstEntity.EQL); Assert.AreEqual("mg/L", firstEntity.EQLUnits); Assert.AreEqual(string.Empty, firstEntity.Comments); Assert.AreEqual(50.0d, firstEntity.UCL); Assert.AreEqual(null, firstEntity.LCL); }
public void OutOfRangeTest() { var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DataFiles", "XMLSample.xml"); var dataSource = new WindowsFileSystem(path); var dataFromFileSystem = dataSource.FetchData(); var dataSourceLocation = new XMLDataSourceLocation("here","there"); var dataToImport = new XMLDataToImport(dataFromFileSystem); var parserFactory = new DefaultParserFactory(); var testElementParser = new ElementParser(parserFactory); var testParsingResult = testElementParser.Parse(dataToImport, dataSourceLocation, typeof(int)) as ParsingResult; Assert.NotNull(testParsingResult); Assert.AreEqual(ResultLevel.FATAL, testParsingResult.Level); //Assert.AreEqual("Argument is out of range", testParsingResult.Message); Assert.Null(testParsingResult.Value); }
public void OutOfRangeTest() { var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DataFiles", "XMLSample.xml"); var dataSource = new WindowsFileSystem(path); var dataFromFileSystem = dataSource.FetchData(); var dataSourceLocation = new XMLDataSourceLocation("here", "there"); var dataToImport = new XMLDataToImport(dataFromFileSystem); var parserFactory = new DefaultParserFactory(); var testElementParser = new ElementParser(parserFactory); var testParsingResult = testElementParser.Parse(dataToImport, dataSourceLocation, typeof(int)) as ParsingResult; Assert.NotNull(testParsingResult); Assert.AreEqual(ResultLevel.FATAL, testParsingResult.Level); //Assert.AreEqual("Argument is out of range", testParsingResult.Message); Assert.Null(testParsingResult.Value); }
public void ParseTest() { var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DataFiles", "TestJSONFile.json"); var dataSource = new WindowsFileSystem(path); var dataFromFileSystem = dataSource.FetchData(); var dataSourceLocation = new JSONDataSourceLocation("objects[*].name", true); var dataToImport = new JSONDataToImport(dataFromFileSystem); var parserFactory = new DefaultParserFactory(); var testParser = new SimpleJSONObjectParser(parserFactory); var parseResults = testParser.Parse(dataToImport, dataSourceLocation, typeof(string)) as ParsingResult; dynamic result = parseResults.Value; Assert.NotNull(parseResults); Assert.AreEqual("Cruise", result[0]); Assert.AreEqual("Data retrieval", result[1]); Assert.AreEqual("Derivation", result[2]); }
public void ChemistryFilePropertyTest() { var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DataFiles", "ChemistryFileExample.csv"); var dataSource = new WindowsFileSystem(path); var dataFromFileSystem = dataSource.FetchData(); var dataToImport = new CSVDataToImport(dataFromFileSystem); var simpleValueAssginer = new SimpleValueAssigner(); var chemistryImporter = ESDATTestHelper.BuildChemistryFileImporter(); var childObjectExtractConfiguration = new ChemistryFileChildObjectExtractConfiguration(chemistryImporter, "ChemistryData", simpleValueAssginer); Assert.AreEqual(typeof(ChemistryFileData), childObjectExtractConfiguration.ChildObjectType); var testESDATModel = new ESDATModel(); var extractResult = childObjectExtractConfiguration.ExtractData(testESDATModel, dataToImport); Assert.NotNull(extractResult); Assert.AreEqual(9, testESDATModel.ChemistryData.Count()); }
public void ChemistryFilePropertyTest() { var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DataFiles", "SampleFileExample.csv"); var dataSource = new WindowsFileSystem(path); var dataFromFileSystem = dataSource.FetchData(); var dataToImport = new CSVDataToImport(dataFromFileSystem); var simpleValueAssginer = new SimpleValueAssigner(); var sampleDataImporter = ESDATTestHelper.BuildSampleDataFileImporter(); var childObjectExtractConfiguration = new SampleFileChildObjectExtractConfiguration(sampleDataImporter, "SampleFileData", simpleValueAssginer); Assert.AreEqual(typeof(SampleFileData), childObjectExtractConfiguration.ChildObjectType); var testESDATModel = new ESDATModel(); var extractResult = childObjectExtractConfiguration.ExtractData(testESDATModel, dataToImport); Assert.NotNull(extractResult); Assert.AreEqual(3, testESDATModel.SampleFileData.Count()); var firstSampleData = testESDATModel.SampleFileData.FirstOrDefault(); Assert.NotNull(firstSampleData); Assert.AreEqual("5828314", firstSampleData.SampleCode); Assert.AreEqual(new DateTime(2014, 9, 16), firstSampleData.SampledDateTime); Assert.AreEqual("FRL-1 @ 16:00", firstSampleData.FieldID); Assert.Null(firstSampleData.SampleDepth); Assert.AreEqual("Water", firstSampleData.MatrixType); Assert.AreEqual("Normal", firstSampleData.SampleType); Assert.AreEqual(string.Empty, firstSampleData.ParentSample); Assert.AreEqual("14J891101", firstSampleData.SDG); Assert.AreEqual("AGAT", firstSampleData.LabName); Assert.AreEqual("5828314", firstSampleData.LabSampleID); Assert.AreEqual(string.Empty, firstSampleData.Comments); Assert.AreEqual("14J891101", firstSampleData.LabReportNumber); }
public void ExtractSampleDataFileTest() { var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DataFiles", "SampleFileExample.csv"); var dataSource = new WindowsFileSystem(path); var dataFromFileSystem = dataSource.FetchData(); var dataToImport = new CSVDataToImport(dataFromFileSystem); var sampleDataFileImporter = ESDATTestHelper.BuildSampleDataFileImporter(); var extractResult = sampleDataFileImporter.Extract<SampleFileData>(dataToImport); var allFailResults = extractResult.AllParsingResults.Where(x => x.Level == ResultLevel.ERROR).ToList(); Assert.NotNull(extractResult); Assert.AreEqual(ResultLevel.ERROR, extractResult.ThresholdLevel); Assert.False(allFailResults.Any()); Assert.AreEqual(true, extractResult.IsExtractedSuccess); Assert.AreEqual(3, extractResult.ExtractedEntities.Count()); var firstEntity = extractResult.ExtractedEntities.FirstOrDefault(); Assert.NotNull(firstEntity); Assert.AreEqual("5828314", firstEntity.SampleCode); Assert.AreEqual(new DateTime(2014, 9, 16), firstEntity.SampledDateTime); Assert.AreEqual("FRL-1 @ 16:00", firstEntity.FieldID); Assert.Null(firstEntity.SampleDepth); Assert.AreEqual("Water", firstEntity.MatrixType); Assert.AreEqual("Normal", firstEntity.SampleType); Assert.AreEqual(string.Empty, firstEntity.ParentSample); Assert.AreEqual("14J891101", firstEntity.SDG); Assert.AreEqual("AGAT", firstEntity.LabName); Assert.AreEqual("5828314", firstEntity.LabSampleID); Assert.AreEqual(string.Empty, firstEntity.Comments); Assert.AreEqual("14J891101", firstEntity.LabReportNumber); }
public void ExtractSampleDataFileTest() { var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DataFiles", "SampleFileExample.csv"); var dataSource = new WindowsFileSystem(path); var dataFromFileSystem = dataSource.FetchData(); var dataToImport = new CSVDataToImport(dataFromFileSystem); var sampleDataFileImporter = ESDATTestHelper.BuildSampleDataFileImporter(); var extractResult = sampleDataFileImporter.Extract <SampleFileData>(dataToImport); var allFailResults = extractResult.AllParsingResults.Where(x => x.Level == ResultLevel.ERROR).ToList(); Assert.NotNull(extractResult); Assert.AreEqual(ResultLevel.ERROR, extractResult.ThresholdLevel); Assert.False(allFailResults.Any()); Assert.AreEqual(true, extractResult.IsExtractedSuccess); Assert.AreEqual(3, extractResult.ExtractedEntities.Count()); var firstEntity = extractResult.ExtractedEntities.FirstOrDefault(); Assert.NotNull(firstEntity); Assert.AreEqual("5828314", firstEntity.SampleCode); Assert.AreEqual(new DateTime(2014, 9, 16), firstEntity.SampledDateTime); Assert.AreEqual("FRL-1 @ 16:00", firstEntity.FieldID); Assert.Null(firstEntity.SampleDepth); Assert.AreEqual("Water", firstEntity.MatrixType); Assert.AreEqual("Normal", firstEntity.SampleType); Assert.AreEqual(string.Empty, firstEntity.ParentSample); Assert.AreEqual("14J891101", firstEntity.SDG); Assert.AreEqual("AGAT", firstEntity.LabName); Assert.AreEqual("5828314", firstEntity.LabSampleID); Assert.AreEqual(string.Empty, firstEntity.Comments); Assert.AreEqual("14J891101", firstEntity.LabReportNumber); }
public static IExtractConfiguration CreateSampleFileDataExtractConfiguration() { var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DataFiles", "SampleFileExample.csv"); var dataSource = new WindowsFileSystem(path); var dataFromFileSystem = dataSource.FetchData(); var dataToImport = new CSVDataToImport(dataFromFileSystem); var simpleValueAssginer = new SimpleValueAssigner(); var sampleDataImporter = ESDATTestHelper.BuildSampleDataFileImporter(); var childObjectExtractConfiguration = new SampleFileChildObjectExtractConfiguration(sampleDataImporter, "SampleFileData", simpleValueAssginer); return childObjectExtractConfiguration; }
public static CSVDataToImport CreateCSVDataToImport(string filePath) { var dataSource = new WindowsFileSystem(filePath); var dataFromFileSystem = dataSource.FetchData(); var dataToImport = new CSVDataToImport(dataFromFileSystem); return dataToImport; }
private XMLDataToImport CreateXMLDatoToImport(string filePath) { var dataSource = new WindowsFileSystem(filePath); var dataFromFileSystem = dataSource.FetchData(); var dataToImport = new XMLDataToImport(dataFromFileSystem); return dataToImport; }