Index: src/Deltares.Geotechnics.IO.Tests/SoilProfilesImporterTest.cs =================================================================== diff -u -r14 -r50 --- src/Deltares.Geotechnics.IO.Tests/SoilProfilesImporterTest.cs (.../SoilProfilesImporterTest.cs) (revision 14) +++ src/Deltares.Geotechnics.IO.Tests/SoilProfilesImporterTest.cs (.../SoilProfilesImporterTest.cs) (revision 50) @@ -1,12 +1,9 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Runtime.InteropServices; using System.Text; -using Deltares.DeltaModel; using Deltares.Geotechnics.IO.Importers; using Deltares.Standard.Language; -using Deltares.Standard.TestUtils; using NUnit.Framework; namespace Deltares.Geotechnics.IO.Tests @@ -37,66 +34,24 @@ File.Delete(testFile); } + /// - /// Test the Ringtoets/Proeftoets example data for DijkRing 36 (records NOT sorted by profile_id!) - /// - [Test] - public void ImportProeftoetsD36UnsortedRecords() - { - var deltaModel = new DeltaModel.DeltaModel(); - var deltaModelFactory = new DeltaModelFactory(deltaModel); - - // ringtoets style import using deltamodel factory - var fileName = Path.Combine(@"..\..\..\data", @"RingToets//Proeftoets1//Ringtoets invoer DR36", "soilprofiles_DR36.csv"); - var soilProfilesImporter = new SoilProfilesImporter - { - FileName = fileName, Factory = deltaModelFactory - }; - soilProfilesImporter.Import(); - - soilProfilesImporter.Registration.PopulateRegisteredItems(); - Assert.AreEqual(1100, deltaModel.SoilProfiles1D.Count, "Read incorrect number of soil profiles"); - - SoilProfile1D soilProfile = deltaModel.SoilProfiles1D.FirstOrDefault(x => x.Name.Equals("36001004_PIP1")); - Assert.IsNotNull(soilProfile); - Assert.AreEqual(3, soilProfile.Layers.Count); - //Assert.IsNotNull(soilProfile.Layers[0].Soil); - //Assert.AreEqual(soilProfile.Layers[0].Soil.Name, "36001004_PIP1_D_0"); - - // same without using the factory (as in D-SoilModel) - soilProfilesImporter = new SoilProfilesImporter(); - var soils = new SoilList(); - var soilProfiles = soilProfilesImporter.ReadSoilProfiles(fileName, soils); - soilProfile = soilProfiles.FirstOrDefault(x => x.Name.Equals("36001004_PIP1")); - Assert.IsNotNull(soilProfile); - Assert.AreEqual(3, soilProfile.Layers.Count); - // TODO: user should get warning about missing soils via LogManager ? - Assert.IsNotNull(soilProfile.Layers[0].Soil); - Assert.AreEqual(soilProfile.Layers[0].Soil.Name, "36001004_PIP1_D_0"); - } - - /// /// Check of Import() returns correct soil profiles. /// The values that are checked in this test were looked up in the testfile "soilprofiles.csv" /// [Test] public void ImportReturnsCorrectSoilProfiles() { - var deltaModel = new DeltaModel.DeltaModel(); - var testDeltaModelFactory = new TestDeltaModelFactory(deltaModel); + var soils = new SoilList(); + var importer = new SoilProfilesImporter(); + var soilProfiles = importer.ReadSoilProfiles(Path.Combine(mapTestData, soilProfilesFilename), soils); + Assert.AreEqual(32, soilProfiles.Count, "Read incorrect number of soil profiles"); - var soilProfilesImporter = new SoilProfilesImporter - { - FileName = Path.Combine(mapTestData, soilProfilesFilename), Factory = testDeltaModelFactory - }; - soilProfilesImporter.Import(); - Assert.AreEqual(32, deltaModel.SoilProfiles1D.Count, "Read incorrect number of soil profiles"); - - SoilProfile1D soilProfile = deltaModel.SoilProfiles1D.FirstOrDefault(x => x.Name.Equals("10Z_400_STBI")); + SoilProfile1D soilProfile = soilProfiles.FirstOrDefault(x => x.Name.Equals("10Z_400_STBI")); Assert.IsNotNull(soilProfile); Assert.AreEqual(3, soilProfile.Layers.Count); - soilProfilesImporter.Registration.PopulateRegisteredItems(); + importer.Registration.PopulateRegisteredItems(); Assert.AreEqual("Zand Pleistoceen", soilProfile.Layers[2].Soil.Name); } @@ -118,51 +73,8 @@ Assert.AreEqual(3, soilProfile.Layers.Count); Assert.AreEqual("Zand Pleistoceen", soilProfile.Layers[2].Soil.Name); } - + /// - /// Check whether importing the same file for the second time result in overwriting existing soilProfiles in DeltaModel - /// - [Test] - public void RepeatedImportOverwritesExistingSoilProfiles() - { - var deltaModel = new DeltaModel.DeltaModel(); - var deltaModelFactory = new DeltaModelFactory(deltaModel); - - var soilProfilesImporter = new SoilProfilesImporter - { - FileName = Path.Combine(mapTestData, soilProfilesFilename), Factory = deltaModelFactory - }; - soilProfilesImporter.Import(); - Assert.AreEqual(32, deltaModel.SoilProfiles1D.Count, "Read incorrect number of soil profiles"); - - var sample1 = deltaModel.SoilProfiles1D.FirstOrDefault(x => x.Name.Equals("10Z_400_STBI")); - Assert.IsTrue(sample1 != null); - var count1 = sample1.LayerCount; - - var sample2 = deltaModel.SoilProfiles1D.FirstOrDefault(x => x.Name.Equals("10Z_327_STBI")); - Assert.IsTrue(sample2 != null); - var count2 = sample2.LayerCount; - sample2.Layers.Clear(); - - soilProfilesImporter = new SoilProfilesImporter - { - FileName = Path.Combine(mapTestData, soilProfilesFilename), Factory = deltaModelFactory - }; - soilProfilesImporter.Import(); - Assert.AreEqual(32, deltaModel.SoilProfiles1D.Count, "Read incorrect number of soil profiles"); - - var resample1 = deltaModel.SoilProfiles1D.FirstOrDefault(x => x.Name.Equals("10Z_400_STBI")); - Assert.IsTrue(resample1 != null); - Assert.AreEqual(count1, resample1.LayerCount); - Assert.AreSame(sample1, resample1); - - var resample2 = deltaModel.SoilProfiles1D.FirstOrDefault(x => x.Name.Equals("10Z_327_STBI")); - Assert.IsTrue(resample2 != null); - Assert.AreEqual(count2, resample2.LayerCount); - Assert.AreSame(sample2, resample2); - } - - /// /// Check whether matching Soils via the classic (not using factory) method is not case sensitive /// [Test]