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 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);
        }
コード例 #3
0
        public void ExtractESDATDataTest()
        {
            var mockDefaultValueProvider = new Mock <IWQDefaultValueProvider>();

            var headerFileToImport    = CreateXMLDatoToImport(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DataFiles", "XMLSample.xml"));
            var chemistryFileToImport = CreateCSVDataToImport(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DataFiles", "ChemistryFileExample.csv"));
            var sampleFileToImport    = CreateCSVDataToImport(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DataFiles", "SampleFileExample.csv"));

            var testESDATDataToImport = new ESDATDataToImport(headerFileToImport, sampleFileToImport, chemistryFileToImport);


            var simpleValueAssginer = new SimpleValueAssigner();

            var sampleDataImporter = ESDATTestHelper.BuildSampleDataFileImporter();
            var sampleFileChildObjectExtractConfiguration = new SampleFileChildObjectExtractConfiguration(sampleDataImporter, "SampleFileData", simpleValueAssginer);

            var chemistryDataImporter = ESDATTestHelper.BuildChemistryFileImporter();
            var chemistryFileChildObjectExtractConfiguration = new ChemistryFileChildObjectExtractConfiguration(chemistryDataImporter, "ChemistryData", simpleValueAssginer);

            var testESDATDataImporter = new ESDATDataImporter(ResultLevel.ERROR, mockDefaultValueProvider.Object);

            AddXMLExtractConfigurationsToImporter(testESDATDataImporter);
            testESDATDataImporter.AddExtractConfiguration(sampleFileChildObjectExtractConfiguration);
            testESDATDataImporter.AddExtractConfiguration(chemistryFileChildObjectExtractConfiguration);

            var extractResult = testESDATDataImporter.Extract <ESDATModel>(testESDATDataToImport);

            Assert.NotNull(extractResult);

            var entity = extractResult.ExtractedEntities.Cast <ESDATModel>().SingleOrDefault();

            Assert.NotNull(entity);
            Assert.AreEqual("Lab1", entity.LabName);
            Assert.AreEqual(3, entity.SampleFileData.Count());
            Assert.AreEqual(9, entity.ChemistryData.Count());
        }
        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);
        }