Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile2DReaderTest.cs =================================================================== diff -u -r223528aec31c0f78f0f8ff67991e43f781075931 -r6e00eba7f45883916d98df04a84f6d0dca2f61fc --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile2DReaderTest.cs (.../SoilProfile2DReaderTest.cs) (revision 223528aec31c0f78f0f8ff67991e43f781075931) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile2DReaderTest.cs (.../SoilProfile2DReaderTest.cs) (revision 6e00eba7f45883916d98df04a84f6d0dca2f61fc) @@ -27,6 +27,7 @@ using Core.Common.Utils.Builders; using NUnit.Framework; using Rhino.Mocks; +using Ringtoets.Piping.IO.Builders; using Ringtoets.Piping.IO.Exceptions; using Ringtoets.Piping.IO.SoilProfile; using Ringtoets.Piping.IO.Test.TestHelpers; @@ -138,7 +139,7 @@ const string path = "A"; reader.Expect(r => r.Path).Return(path); - SetExpectations(0, name, 0.0, 1.0, string.Empty, 0, new byte[0], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); + SetExpectations(0, name, 0.0, 1.0, string.Empty, 0, new byte[0], null, null, null, null, null, null); mocks.ReplayAll(); @@ -161,7 +162,7 @@ const string path = "A"; reader.Expect(r => r.Path).Return(path); - SetExpectations(1, name, 0.0, 1.0, string.Empty, 0, null, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); + SetExpectations(1, name, 0.0, 1.0, string.Empty, 0, null, null, null, null, null, null, null); mocks.ReplayAll(); @@ -183,7 +184,7 @@ const string name = "cool name"; const string path = "A"; - SetExpectations(1, name, 0.0, 1.0, string.Empty, 0, new byte[0], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); + SetExpectations(1, name, 0.0, 1.0, string.Empty, 0, new byte[0], null, null, null, null, null, null); reader.Expect(r => r.Path).Return(path); mocks.ReplayAll(); @@ -227,7 +228,7 @@ public void ReadFrom_NullValuesForLayer_ReturnsProfileWithNullValuesAndDefaultsOnLayer() { // Setup - SetExpectations(1, "", 0.0, null, null, null, someGeometry,0.0,0.0,0.0,0.0,0.0,0.0); + SetExpectations(1, "", 0.0, null, null, null, someGeometry, null, null, null, null, null, null); mocks.ReplayAll(); @@ -245,6 +246,13 @@ Assert.IsEmpty(pipingSoilLayer.MaterialName); Assert.AreEqual(Color.Empty, pipingSoilLayer.Color); + Assert.IsNaN(pipingSoilLayer.BelowPhreaticLevelMean); + Assert.IsNaN(pipingSoilLayer.BelowPhreaticLevelDeviation); + Assert.IsNaN(pipingSoilLayer.DiameterD70Mean); + Assert.IsNaN(pipingSoilLayer.DiameterD70Deviation); + Assert.IsNaN(pipingSoilLayer.PermeabilityMean); + Assert.IsNaN(pipingSoilLayer.PermeabilityDeviation); + mocks.VerifyAll(); } @@ -307,7 +315,105 @@ mocks.VerifyAll(); } + [Test] + public void ReadFrom_InvalidBelowPhreaticLevelDistributionValue_ThrowsPipingSoilProfileReadException() + { + // Setup + reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1); + reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.BelowPhreaticLevelDistribution)).Return(1); + mocks.ReplayAll(); + // Call + TestDelegate test = () => SoilProfile2DReader.ReadFrom(reader); + + // Assert + Assert.Throws(test); + mocks.VerifyAll(); + } + + [Test] + public void ReadFrom_InvalidBelowPhreaticLevelShiftValue_ThrowsPipingSoilProfileReadException() + { + // Setup + reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1); + reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.BelowPhreaticLevelDistribution)).Return(SoilLayerConstants.LogNormalDistributionValue); + reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.BelowPhreaticLevelShift)).Return(1); + mocks.ReplayAll(); + + // Call + TestDelegate test = () => SoilProfile2DReader.ReadFrom(reader); + + // Assert + Assert.Throws(test); + mocks.VerifyAll(); + } + + [Test] + public void ReadFrom_InvalidDiameterD70DistributionValue_ThrowsPipingSoilProfileReadException() + { + // Setup + reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1); + reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.DiameterD70Distribution)).Return(1); + mocks.ReplayAll(); + + // Call + TestDelegate test = () => SoilProfile2DReader.ReadFrom(reader); + + // Assert + Assert.Throws(test); + mocks.VerifyAll(); + } + + [Test] + public void ReadFrom_InvalidDiameterD70ShiftValue_ThrowsPipingSoilProfileReadException() + { + // Setup + reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1); + reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.DiameterD70Distribution)).Return(SoilLayerConstants.LogNormalDistributionValue); + reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.DiameterD70Shift)).Return(1); + mocks.ReplayAll(); + + // Call + TestDelegate test = () => SoilProfile2DReader.ReadFrom(reader); + + // Assert + Assert.Throws(test); + mocks.VerifyAll(); + } + + [Test] + public void ReadFrom_InvalidPermeabilityDistributionValue_ThrowsPipingSoilProfileReadException() + { + // Setup + reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1); + reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.PermeabilityDistribution)).Return(1); + mocks.ReplayAll(); + + // Call + TestDelegate test = () => SoilProfile2DReader.ReadFrom(reader); + + // Assert + Assert.Throws(test); + mocks.VerifyAll(); + } + + [Test] + public void ReadFrom_InvalidPermeabilityShiftValue_ThrowsPipingSoilProfileReadException() + { + // Setup + reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1); + reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.PermeabilityDistribution)).Return(SoilLayerConstants.LogNormalDistributionValue); + reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.PermeabilityShift)).Return(1); + mocks.ReplayAll(); + + // Call + TestDelegate test = () => SoilProfile2DReader.ReadFrom(reader); + + // Assert + Assert.Throws(test); + mocks.VerifyAll(); + } + private void SetExpectations(int layerCount, string profileName, double intersectionX, double? isAquifer, string materialName, double? color, byte[] geometry, double? belowPhreaticLevelMean, double? belowPhreaticLevelDeviation, double? diameterD70Mean, double? diameterD70Deviation, double? permeabilityMean, double? permeabilityDeviation) { reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(layerCount).Repeat.Any();