Index: Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SegmentPointReader.cs =================================================================== diff -u -r9d56d6d370c1a05eebb62ca4cc58aa9036c27bf1 -r28064349855037e892288c81383f1413f4e84f4c --- Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SegmentPointReader.cs (.../SegmentPointReader.cs) (revision 9d56d6d370c1a05eebb62ca4cc58aa9036c27bf1) +++ Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SegmentPointReader.cs (.../SegmentPointReader.cs) (revision 28064349855037e892288c81383f1413f4e84f4c) @@ -34,7 +34,7 @@ namespace Ringtoets.Common.IO.SoilProfile { /// - /// This class reads a DSoil database file and reads segment points from this database. + /// This class reads a D-Soil Model file and reads segment points from this database. /// public class SegmentPointReader : SqLiteDatabaseReaderBase { Index: Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilDatabaseConstraintsReader.cs =================================================================== diff -u -r9d56d6d370c1a05eebb62ca4cc58aa9036c27bf1 -r28064349855037e892288c81383f1413f4e84f4c --- Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilDatabaseConstraintsReader.cs (.../SoilDatabaseConstraintsReader.cs) (revision 9d56d6d370c1a05eebb62ca4cc58aa9036c27bf1) +++ Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilDatabaseConstraintsReader.cs (.../SoilDatabaseConstraintsReader.cs) (revision 28064349855037e892288c81383f1413f4e84f4c) @@ -31,7 +31,7 @@ namespace Ringtoets.Common.IO.SoilProfile { /// - /// This class reads a DSoil database file and validates whether it meets required constraints. + /// This class reads a D-Soil Model file and validates whether it meets required constraints. /// public class SoilDatabaseConstraintsReader : SqLiteDatabaseReaderBase { Index: Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilProfile1DReader.cs =================================================================== diff -u -r71a7388a942d2f74d88f8df4d1bd76eb1ed49d28 -r28064349855037e892288c81383f1413f4e84f4c --- Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilProfile1DReader.cs (.../SoilProfile1DReader.cs) (revision 71a7388a942d2f74d88f8df4d1bd76eb1ed49d28) +++ Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilProfile1DReader.cs (.../SoilProfile1DReader.cs) (revision 28064349855037e892288c81383f1413f4e84f4c) @@ -33,7 +33,7 @@ namespace Ringtoets.Common.IO.SoilProfile { /// - /// This class reads a DSoil database file and reads 1d profiles from this database. + /// This class reads a D-Soil Model file and reads 1d profiles from this database. /// public class SoilProfile1DReader : SqLiteDatabaseReaderBase, IRowBasedDatabaseReader { @@ -124,20 +124,40 @@ } /// + /// Steps through the result rows until a row is read which' profile id differs from . + /// + /// The id of the profile to skip. + private void MoveToNextProfile(long soilProfileId) + { + while (HasNext && Read(SoilProfileTableDefinitions.SoilProfileId).Equals(soilProfileId)) + { + MoveNext(); + } + } + + /// /// Tries to read and create a . /// - /// + /// The read . /// Thrown when reading properties of the profile failed. private SoilProfile1D TryReadSoilProfile() { var properties = new RequiredProfileProperties(this); var soilLayers = new List(); - for (var i = 1; i <= properties.LayerCount; i++) + try { - soilLayers.Add(ReadSoilLayerFrom(this, properties.ProfileName)); - MoveNext(); + for (var i = 1; i <= properties.LayerCount; i++) + { + soilLayers.Add(ReadSoilLayerFrom(this, properties.ProfileName)); + MoveNext(); + } } + catch (SoilProfileReadException) + { + MoveToNextProfile(properties.ProfileId); + throw; + } try { Index: Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilProfile2DReader.cs =================================================================== diff -u -r71a7388a942d2f74d88f8df4d1bd76eb1ed49d28 -r28064349855037e892288c81383f1413f4e84f4c --- Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilProfile2DReader.cs (.../SoilProfile2DReader.cs) (revision 71a7388a942d2f74d88f8df4d1bd76eb1ed49d28) +++ Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilProfile2DReader.cs (.../SoilProfile2DReader.cs) (revision 28064349855037e892288c81383f1413f4e84f4c) @@ -33,7 +33,7 @@ namespace Ringtoets.Common.IO.SoilProfile { /// - /// This class reads a DSoil database file and reads 2d profiles from this database. + /// This class reads a D-Soil Model file and reads 2d profiles from this database. /// public class SoilProfile2DReader : SqLiteDatabaseReaderBase, IRowBasedDatabaseReader { @@ -122,6 +122,18 @@ base.Dispose(disposing); } + /// + /// Steps through the result rows until a row is read which' profile id differs from . + /// + /// The id of the profile to skip. + private void MoveToNextProfile(long soilProfileId) + { + while (HasNext && Read(SoilProfileTableDefinitions.SoilProfileId).Equals(soilProfileId)) + { + MoveNext(); + } + } + private void PrepareReader() { string soilProfile2DQuery = SoilDatabaseQueryBuilder.GetSoilProfile2DQuery(); @@ -137,29 +149,46 @@ } } + /// + /// Tries to read and create a . + /// + /// The read . + /// Thrown when reading properties of the profile failed. private SoilProfile2D TryReadSoilProfile() { var properties = new RequiredProfileProperties(this); var soilLayers = new List(); - - if (properties.LayerCount == 0) + try { - throw new SoilProfileReadException(Resources.SoilProfile_Cannot_construct_SoilProfile_without_layers, properties.ProfileName); + for (var i = 1; i <= properties.LayerCount; i++) + { + soilLayers.Add(ReadSoilLayerFrom(this, properties.ProfileName)); + MoveNext(); + } } - - for (var i = 1; i <= properties.LayerCount; i++) + catch (SoilProfileReadException) { - soilLayers.Add(ReadSoilLayerFrom(this, properties.ProfileName)); - MoveNext(); + MoveToNextProfile(properties.ProfileId); + throw; } - return new SoilProfile2D(properties.ProfileId, - properties.ProfileName, - soilLayers) + try { - IntersectionX = properties.IntersectionX - }; + return new SoilProfile2D(properties.ProfileId, + properties.ProfileName, + soilLayers) + { + IntersectionX = properties.IntersectionX + }; + } + catch (ArgumentException exception) + { + throw new SoilProfileReadException( + Resources.SoilProfile1DReader_ReadSoilProfile_Failed_to_construct_profile_from_read_data, + properties.ProfileName, + exception); + } } /// Index: Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/StochasticSoilModelReader.cs =================================================================== diff -u -r2dc7bb7aef782fd08d2474e14cc5486725896b38 -r28064349855037e892288c81383f1413f4e84f4c --- Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/StochasticSoilModelReader.cs (.../StochasticSoilModelReader.cs) (revision 2dc7bb7aef782fd08d2474e14cc5486725896b38) +++ Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/StochasticSoilModelReader.cs (.../StochasticSoilModelReader.cs) (revision 28064349855037e892288c81383f1413f4e84f4c) @@ -33,7 +33,7 @@ namespace Ringtoets.Common.IO.SoilProfile { /// - /// This class reads a DSoil database file and reads stochastic soil model from this database. + /// This class reads a D-Soil Model file and reads stochastic soil model from this database. /// public class StochasticSoilModelReader : SqLiteDatabaseReaderBase { @@ -43,13 +43,13 @@ private SegmentPointReader segmentPointReader; /// - /// Creates a new instance of , + /// Creates a new instance of /// which will use the as its source. /// /// The path of the database file to open. /// Thrown when: /// - /// The contains invalid characters. + /// The contains invalid characters; /// No file could be found at . /// /// @@ -96,8 +96,8 @@ /// values for required properties. /// Thrown when: /// - /// no stochastic soil profiles could be read; - /// the read failure mechanism type is not supported. + /// No stochastic soil profiles could be read; + /// The read failure mechanism type is not supported. /// /// public StochasticSoilModel ReadStochasticSoilModel() @@ -194,9 +194,9 @@ /// if no more soil models can be read. /// Thrown when: /// - /// no stochastic soil profiles could be read; - /// the geometry could not be read; - /// the read failure mechanism type is not supported. + /// No stochastic soil profiles could be read; + /// The geometry could not be read; + /// The read failure mechanism type is not supported. /// /// private StochasticSoilModel TryReadStochasticSoilModel() @@ -242,8 +242,8 @@ /// The read stochastic soil profiles. /// Thrown when: /// - /// no stochastic soil profiles could be read; - /// the read failure mechanism type is not supported. + /// No stochastic soil profiles could be read; + /// The read failure mechanism type is not supported. /// /// private IEnumerable ReadStochasticSoilProfiles(long stochasticSoilModelId) Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilProfile1DReaderTest.cs =================================================================== diff -u -ra331d81d2e74e59fc82643c0313105c61afcd654 -r28064349855037e892288c81383f1413f4e84f4c --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilProfile1DReaderTest.cs (.../SoilProfile1DReaderTest.cs) (revision a331d81d2e74e59fc82643c0313105c61afcd654) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilProfile1DReaderTest.cs (.../SoilProfile1DReaderTest.cs) (revision 28064349855037e892288c81383f1413f4e84f4c) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.Collections.Generic; using System.Collections.ObjectModel; using System.Drawing; using System.IO; @@ -110,6 +111,40 @@ } [Test] + public void GivenReadSoilProfileThrowsException_WhenReadingNextProfile_ReturnsNextProfile() + { + // Given + string dbFile = Path.Combine(testDataPath, "1dprofileWithInvalidLayerProperty.soil"); + + SoilProfileReadException exception = null; + var readSoilProfiles = new List(); + using (var reader = new SoilProfile1DReader(dbFile)) + { + reader.Initialize(); + + // When + try + { + reader.ReadSoilProfile(); + } + catch (SoilProfileReadException e) + { + exception = e; + } + + // Then + readSoilProfiles.Add(reader.ReadSoilProfile()); + } + + Assert.IsInstanceOf(exception); + Assert.AreEqual("Profile", exception.ProfileName); + Assert.AreEqual(1, readSoilProfiles.Count); + Assert.AreEqual("Profile2", readSoilProfiles[0].Name); + + Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile)); + } + + [Test] public void ReadSoilProfile_DatabaseWith1DAnd1DSoilProfileWithoutSoilLayers_ReturnOneProfile() { // Setup Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilProfile2DReaderTest.cs =================================================================== diff -u -r4d2b702d8a5e4570ee53fa499f8f5fa196acdb98 -r28064349855037e892288c81383f1413f4e84f4c --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilProfile2DReaderTest.cs (.../SoilProfile2DReaderTest.cs) (revision 4d2b702d8a5e4570ee53fa499f8f5fa196acdb98) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilProfile2DReaderTest.cs (.../SoilProfile2DReaderTest.cs) (revision 28064349855037e892288c81383f1413f4e84f4c) @@ -20,6 +20,7 @@ // All rights reserved. using System; +using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; using System.Linq; @@ -162,6 +163,40 @@ } [Test] + public void GivenReadSoilProfileThrowsException_WhenReadingNextProfile_ReturnsNextProfile() + { + // Given + string dbFile = Path.Combine(testDataPath, "2dprofileWithInvalidLayerProperty.soil"); + + SoilProfileReadException exception = null; + var readSoilProfiles = new List(); + using (var reader = new SoilProfile2DReader(dbFile)) + { + reader.Initialize(); + + // When + try + { + reader.ReadSoilProfile(); + } + catch (SoilProfileReadException e) + { + exception = e; + } + + // Then + readSoilProfiles.Add(reader.ReadSoilProfile()); + } + + Assert.IsInstanceOf(exception); + Assert.AreEqual("Profile", exception.ProfileName); + Assert.AreEqual(1, readSoilProfiles.Count); + Assert.AreEqual("Profile2", readSoilProfiles[0].Name); + + Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile)); + } + + [Test] public void ReadSoilProfile_IntersectionXFor2DSoilProfileNull_ReturnOneProfile() { // Setup Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/SoilProfile1DReader/1dprofileWithInvalidLayerProperty.soil =================================================================== diff -u Binary files differ Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/SoilProfile2DReader/2dprofileWithInvalidLayerProperty.soil =================================================================== diff -u Binary files differ Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfile/StochasticSoilModelReader.cs =================================================================== diff -u -r78382ec129ddc7537096860680cef36f3796700d -r28064349855037e892288c81383f1413f4e84f4c --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfile/StochasticSoilModelReader.cs (.../StochasticSoilModelReader.cs) (revision 78382ec129ddc7537096860680cef36f3796700d) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfile/StochasticSoilModelReader.cs (.../StochasticSoilModelReader.cs) (revision 28064349855037e892288c81383f1413f4e84f4c) @@ -35,7 +35,7 @@ namespace Ringtoets.MacroStabilityInwards.IO.SoilProfile { /// - /// This class reads a DSoil database file and reads from this database. + /// This class reads a D-Soil Model file and reads from this database. /// public class StochasticSoilModelReader : SqLiteDatabaseReaderBase { Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfile/StochasticSoilProfileReader.cs =================================================================== diff -u -r78382ec129ddc7537096860680cef36f3796700d -r28064349855037e892288c81383f1413f4e84f4c --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfile/StochasticSoilProfileReader.cs (.../StochasticSoilProfileReader.cs) (revision 78382ec129ddc7537096860680cef36f3796700d) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfile/StochasticSoilProfileReader.cs (.../StochasticSoilProfileReader.cs) (revision 28064349855037e892288c81383f1413f4e84f4c) @@ -35,7 +35,7 @@ namespace Ringtoets.MacroStabilityInwards.IO.SoilProfile { /// - /// This class reads a DSoil database file and reads + /// This class reads a D-Soil Model file and reads /// from this database. /// public class StochasticSoilProfileReader : SqLiteDatabaseReaderBase