Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/PipingSoilProfileReader.cs
===================================================================
diff -u -rc1e31ab57c197658d1c75750feef8856df7e9f6b -r2da851fd63f93a1e0684874c0011b69c97506472
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/PipingSoilProfileReader.cs (.../PipingSoilProfileReader.cs) (revision c1e31ab57c197658d1c75750feef8856df7e9f6b)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/PipingSoilProfileReader.cs (.../PipingSoilProfileReader.cs) (revision 2da851fd63f93a1e0684874c0011b69c97506472)
@@ -164,7 +164,7 @@
/// The name of the profile to skip.
private void MoveToNextProfile(string profileName)
{
- while (Read(SoilProfileDatabaseColumns.ProfileName).Equals(profileName))
+ while (HasNext && Read(SoilProfileDatabaseColumns.ProfileName).Equals(profileName))
{
MoveNext();
}
@@ -226,9 +226,9 @@
string.Join(" ",
"(SELECT",
"m.MA_ID,",
- "sum(case when pn.PN_Name = 'AbovePhreaticLevel' then pv.PV_Value end) {0},",
- "sum(case when pn.PN_Name = 'BelowPhreaticLevel' then pv.PV_Value end) {1},",
- "sum(case when pn.PN_Name = 'DryUnitWeight' then pv.PV_Value end) {2}",
+ "max(case when pn.PN_Name = 'AbovePhreaticLevel' then pv.PV_Value end) {0},",
+ "max(case when pn.PN_Name = 'BelowPhreaticLevel' then pv.PV_Value end) {1},",
+ "max(case when pn.PN_Name = 'DryUnitWeight' then pv.PV_Value end) {2}",
"FROM ParameterNames as pn",
"JOIN ParameterValues as pv ON pn.PN_ID = pv.PN_ID",
"JOIN Materials as m ON m.MA_ID = pv.MA_ID",
@@ -253,7 +253,7 @@
string.Join(" ",
"(SELECT",
"pv.SL1D_ID,",
- "sum(case when pn.PN_Name = 'IsAquifer' then pv.PV_Value end) {0}",
+ "max(case when pn.PN_Name = 'IsAquifer' then pv.PV_Value end) {0}",
"FROM ParameterNames as pn",
"JOIN LayerParameterValues as pv ON pn.PN_ID = pv.PN_ID",
"GROUP BY pv.SL1D_ID) as lpv ON lpv.SL1D_ID = l.SL1D_ID"
@@ -263,7 +263,7 @@
string.Join(" ",
"(SELECT",
"pv.SL2D_ID,",
- "sum(case when pn.PN_Name = 'IsAquifer' then pv.PV_Value end) {0}",
+ "max(case when pn.PN_Name = 'IsAquifer' then pv.PV_Value end) {0}",
"FROM ParameterNames as pn",
"JOIN LayerParameterValues as pv ON pn.PN_ID = pv.PN_ID",
"GROUP BY pv.SL2D_ID) as lpv ON lpv.SL2D_ID = l.SL2D_ID"
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/PipingSoilProfileReaderTest.cs
===================================================================
diff -u -rc1e31ab57c197658d1c75750feef8856df7e9f6b -r2da851fd63f93a1e0684874c0011b69c97506472
--- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/PipingSoilProfileReaderTest.cs (.../PipingSoilProfileReaderTest.cs) (revision c1e31ab57c197658d1c75750feef8856df7e9f6b)
+++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/PipingSoilProfileReaderTest.cs (.../PipingSoilProfileReaderTest.cs) (revision 2da851fd63f93a1e0684874c0011b69c97506472)
@@ -65,6 +65,22 @@
}
[Test]
+ public void Constructor_EmptyDatabase_HasNextFalse()
+ {
+ // Setup
+ var dbName = "emptyschema.soil";
+ var dbFile = Path.Combine(testDataPath, dbName);
+
+
+ // Call
+ using (var pipingSoilProfileReader = new PipingSoilProfileReader(dbFile))
+ {
+ // Assert
+ Assert.IsFalse(pipingSoilProfileReader.HasNext);
+ }
+ }
+
+ [Test]
public void Constructor_IncorrectVersion_ThrowsCriticalFileReadException()
{
// Setup
@@ -198,6 +214,57 @@
}
[Test]
+ public void ReadProfile_DatabaseProfileWithInvalidBottom_ReturnsNoProfile()
+ {
+ // Setup
+ var testFile = "invalidBottom1dProfile.soil";
+ using (var pipingSoilProfilesReader = new PipingSoilProfileReader(Path.Combine(testDataPath, testFile)))
+ {
+ // Call
+ TestDelegate profile = () => pipingSoilProfilesReader.ReadProfile();
+
+ // Assert
+ var exceptionMessage = Assert.Throws(profile).Message;
+ var message = string.Format(Resources.PipingSoilProfileReader_Profile_0_has_invalid_value_on_Column_1_, "Profile", "Bottom");
+ Assert.AreEqual(message, exceptionMessage);
+ }
+ }
+
+ [Test]
+ public void ReadProfile_DatabaseProfileWithLayerWithInvalidTop_ReturnsNoProfile()
+ {
+ // Setup
+ var testFile = "invalidTop1dProfile.soil";
+ using (var pipingSoilProfilesReader = new PipingSoilProfileReader(Path.Combine(testDataPath, testFile)))
+ {
+ // Call
+ TestDelegate profile = () => pipingSoilProfilesReader.ReadProfile();
+
+ // Assert
+ var exceptionMessage = Assert.Throws(profile).Message;
+ var message = string.Format(Resources.PipingSoilProfileReader_Profile_0_has_invalid_value_on_Column_1_, "Profile", "Top");
+ Assert.AreEqual(message, exceptionMessage);
+ }
+ }
+
+ [Test]
+ public void ReadProfile_DatabaseProfileWithLayerWithInvalidLayerProperty_ReturnsNoProfile()
+ {
+ // Setup
+ var testFile = "incorrectValue2dProperty.soil";
+ using (var pipingSoilProfilesReader = new PipingSoilProfileReader(Path.Combine(testDataPath, testFile)))
+ {
+ // Call
+ TestDelegate profile = () => pipingSoilProfilesReader.ReadProfile();
+
+ // Assert
+ var exceptionMessage = Assert.Throws(profile).Message;
+ var message = string.Format(Resources.PipingSoilProfileReader_Profile_0_has_invalid_value_on_Column_1_, "Profile", "DryUnitWeight");
+ Assert.AreEqual(message, exceptionMessage);
+ }
+ }
+
+ [Test]
public void ReadProfile_DatabaseWith1DProfile3Layers_ReturnsProfile()
{
// Setup
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingSoilProfilesReader/invalidBottom1dProfile.soil
===================================================================
diff -u -r41d06d91a2ef710ad07b3f474f190400751e09b8 -r2da851fd63f93a1e0684874c0011b69c97506472
Binary files differ
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingSoilProfilesReader/invalidTop1dProfile.soil
===================================================================
diff -u -r41d06d91a2ef710ad07b3f474f190400751e09b8 -r2da851fd63f93a1e0684874c0011b69c97506472
Binary files differ
Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSoilProfilesImporterTest.cs
===================================================================
diff -u -rc1e31ab57c197658d1c75750feef8856df7e9f6b -r2da851fd63f93a1e0684874c0011b69c97506472
--- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSoilProfilesImporterTest.cs (.../PipingSoilProfilesImporterTest.cs) (revision c1e31ab57c197658d1c75750feef8856df7e9f6b)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSoilProfilesImporterTest.cs (.../PipingSoilProfilesImporterTest.cs) (revision 2da851fd63f93a1e0684874c0011b69c97506472)
@@ -337,10 +337,7 @@
var importedItem = importer.ImportItem(corruptPath, observableSoilProfileList);
Assert.AreSame(observableSoilProfileList, importedItem);
- Assert.AreEqual(0.0, observableSoilProfileList[0].Layers.ElementAt(0).DryUnitWeight);
- Assert.AreEqual(0.0, observableSoilProfileList[1].Layers.ElementAt(1).DryUnitWeight);
- Assert.AreEqual(2, observableSoilProfileList.Count);
- Assert.AreEqual(4, progress);
+ Assert.AreEqual(0, observableSoilProfileList.Count);
mocks.VerifyAll();
}
Index: doc/dsoilmodel/queries/All1dProfilesAndLayersAndLayerPropertiesAndMaterialProperties.sql
===================================================================
diff -u -r6692dc3480971fe1c017aef633382c40eb37056f -r2da851fd63f93a1e0684874c0011b69c97506472
--- doc/dsoilmodel/queries/All1dProfilesAndLayersAndLayerPropertiesAndMaterialProperties.sql (.../All1dProfilesAndLayersAndLayerPropertiesAndMaterialProperties.sql) (revision 6692dc3480971fe1c017aef633382c40eb37056f)
+++ doc/dsoilmodel/queries/All1dProfilesAndLayersAndLayerPropertiesAndMaterialProperties.sql (.../All1dProfilesAndLayersAndLayerPropertiesAndMaterialProperties.sql) (revision 2da851fd63f93a1e0684874c0011b69c97506472)
@@ -17,17 +17,17 @@
LEFT JOIN (
SELECT
m.MA_ID,
- sum(case when pn.PN_Name = 'AbovePhreaticLevel' then pv.PV_Value end) AbovePhreaticLevel,
- sum(case when pn.PN_Name = 'BelowPhreaticLevel' then pv.PV_Value end) BelowPhreaticLevel,
- sum(case when pn.PN_Name = 'DryUnitWeight' then pv.PV_Value end) DryUnitWeight
+ max(case when pn.PN_Name = 'AbovePhreaticLevel' then pv.PV_Value end) AbovePhreaticLevel,
+ max(case when pn.PN_Name = 'BelowPhreaticLevel' then pv.PV_Value end) BelowPhreaticLevel,
+ max(case when pn.PN_Name = 'DryUnitWeight' then pv.PV_Value end) DryUnitWeight
FROM ParameterNames as pn
JOIN ParameterValues as pv ON pn.PN_ID = pv.PN_ID
JOIN Materials as m ON m.MA_ID = pv.MA_ID
GROUP BY m.MA_ID) as mat ON l.MA_ID = mat.MA_ID
LEFT JOIN (
SELECT
pv.SL1D_ID,
- sum(case when pn.PN_Name = 'IsAquifer' then pv.PV_Value end) IsAquifer
+ max(case when pn.PN_Name = 'IsAquifer' then pv.PV_Value end) IsAquifer
FROM ParameterNames as pn
JOIN LayerParameterValues as pv ON pn.PN_ID = pv.PN_ID
GROUP BY pv.SL1D_ID) as lpv ON lpv.SL1D_ID = l.SL1D_ID
Index: doc/dsoilmodel/queries/All2dProfilesAndLayersAndLayerPropertiesAndMaterialProperties.sql
===================================================================
diff -u -r6692dc3480971fe1c017aef633382c40eb37056f -r2da851fd63f93a1e0684874c0011b69c97506472
--- doc/dsoilmodel/queries/All2dProfilesAndLayersAndLayerPropertiesAndMaterialProperties.sql (.../All2dProfilesAndLayersAndLayerPropertiesAndMaterialProperties.sql) (revision 6692dc3480971fe1c017aef633382c40eb37056f)
+++ doc/dsoilmodel/queries/All2dProfilesAndLayersAndLayerPropertiesAndMaterialProperties.sql (.../All2dProfilesAndLayersAndLayerPropertiesAndMaterialProperties.sql) (revision 2da851fd63f93a1e0684874c0011b69c97506472)
@@ -19,17 +19,17 @@
LEFT JOIN (
SELECT
m.MA_ID,
- sum(case when pn.PN_Name = 'AbovePhreaticLevel' then pv.PV_Value end) AbovePhreaticLevel,
- sum(case when pn.PN_Name = 'BelowPhreaticLevel' then pv.PV_Value end) BelowPhreaticLevel,
- sum(case when pn.PN_Name = 'DryUnitWeight' then pv.PV_Value end) DryUnitWeight
+ max(case when pn.PN_Name = 'AbovePhreaticLevel' then pv.PV_Value end) AbovePhreaticLevel,
+ max(case when pn.PN_Name = 'BelowPhreaticLevel' then pv.PV_Value end) BelowPhreaticLevel,
+ max(case when pn.PN_Name = 'DryUnitWeight' then pv.PV_Value end) DryUnitWeight
FROM ParameterNames as pn
JOIN ParameterValues as pv ON pn.PN_ID = pv.PN_ID
JOIN Materials as m ON m.MA_ID = pv.MA_ID
GROUP BY m.MA_ID) as mat ON l.MA_ID = mat.MA_ID
LEFT JOIN (
SELECT
pv.SL2D_ID,
- sum(case when pn.PN_Name = 'IsAquifer' then pv.PV_Value end) IsAquifer
+ max(case when pn.PN_Name = 'IsAquifer' then pv.PV_Value end) IsAquifer
FROM ParameterNames as pn
JOIN LayerParameterValues as pv ON pn.PN_ID = pv.PN_ID
GROUP BY pv.SL2D_ID) as lpv ON lpv.SL2D_ID = l.SL2D_ID