Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/AssessmentSectionEntityReadExtensionsTest.cs =================================================================== diff -u -r3014d0ced22c45300938639e7958ea0850485240 -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/AssessmentSectionEntityReadExtensionsTest.cs (.../AssessmentSectionEntityReadExtensionsTest.cs) (revision 3014d0ced22c45300938639e7958ea0850485240) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/AssessmentSectionEntityReadExtensionsTest.cs (.../AssessmentSectionEntityReadExtensionsTest.cs) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -281,10 +281,12 @@ { new StochasticSoilModelEntity { + Name = "modelA", StochasticSoilModelSegmentPointXml = emptySegmentPointsXml }, new StochasticSoilModelEntity { + Name = "modelB", StochasticSoilModelSegmentPointXml = emptySegmentPointsXml } }, Index: Core/Common/src/Core.Common.Base/ObservableCollectionWithSourcePath.cs =================================================================== diff -u -r5ad23eae9f87bb12cbf453126070e8967e32d7ad -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Core/Common/src/Core.Common.Base/ObservableCollectionWithSourcePath.cs (.../ObservableCollectionWithSourcePath.cs) (revision 5ad23eae9f87bb12cbf453126070e8967e32d7ad) +++ Core/Common/src/Core.Common.Base/ObservableCollectionWithSourcePath.cs (.../ObservableCollectionWithSourcePath.cs) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -125,11 +125,21 @@ { throw new ArgumentException($"'{filePath}' is not a valid filepath.", nameof(filePath)); } + ValidateItems(items); SourcePath = filePath; collection.AddRange(items); } + /// + /// Perform additional validations over . + /// + /// The items to validate. + /// Throw an exception when validation fails. + protected virtual void ValidateItems(IEnumerable items) + { + } + public IEnumerator GetEnumerator() { return collection.GetEnumerator(); Index: Core/Common/test/Core.Common.Gui.Test/DialogBasedInquiryHelperTest.cs =================================================================== diff -u -r45440093089496f59ed420e772136756c229e30b -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Core/Common/test/Core.Common.Gui.Test/DialogBasedInquiryHelperTest.cs (.../DialogBasedInquiryHelperTest.cs) (revision 45440093089496f59ed420e772136756c229e30b) +++ Core/Common/test/Core.Common.Gui.Test/DialogBasedInquiryHelperTest.cs (.../DialogBasedInquiryHelperTest.cs) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -211,8 +211,6 @@ public void InquireContinuation_OkOrCancelClicked_ReturnExpectedResult(bool confirm) { // Setup - mocks.ReplayAll(); - dialogParent.Expect(d => d.Handle).Repeat.AtLeastOnce().Return(default(IntPtr)); mocks.ReplayAll(); Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingFailureMechanism.cs =================================================================== diff -u -rd6d1b03ce8dc3c4e6bba565a85ea310f6196adea -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingFailureMechanism.cs (.../PipingFailureMechanism.cs) (revision d6d1b03ce8dc3c4e6bba565a85ea310f6196adea) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingFailureMechanism.cs (.../PipingFailureMechanism.cs) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -45,7 +45,7 @@ PipingProbabilityAssessmentInput = new PipingProbabilityAssessmentInput(); GeneralInput = new GeneralPipingInput(); SurfaceLines = new ObservableCollectionWithSourcePath(); - StochasticSoilModels = new ObservableCollectionWithSourcePath(); + StochasticSoilModels = new StochasticSoilModelCollection(); CalculationsGroup = new CalculationGroup(RingtoetsCommonDataResources.FailureMechanism_Calculations_DisplayName, false); sectionResults = new List(); @@ -67,7 +67,7 @@ /// /// Gets the available stochastic soil models within the scope of the piping failure mechanism. /// - public ObservableCollectionWithSourcePath StochasticSoilModels { get; } + public StochasticSoilModelCollection StochasticSoilModels { get; } /// /// Gets the general piping calculation input parameters that apply to each piping calculation. Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/Ringtoets.Piping.Data.csproj =================================================================== diff -u -r5ad23eae9f87bb12cbf453126070e8967e32d7ad -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Ringtoets/Piping/src/Ringtoets.Piping.Data/Ringtoets.Piping.Data.csproj (.../Ringtoets.Piping.Data.csproj) (revision 5ad23eae9f87bb12cbf453126070e8967e32d7ad) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/Ringtoets.Piping.Data.csproj (.../Ringtoets.Piping.Data.csproj) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -66,6 +66,7 @@ + Fisheye: Tag 5ad23eae9f87bb12cbf453126070e8967e32d7ad refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Data/StochasticSoilModelCollection.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/StochasticSoilModelCollectionContext.cs =================================================================== diff -u -r5ad23eae9f87bb12cbf453126070e8967e32d7ad -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/StochasticSoilModelCollectionContext.cs (.../StochasticSoilModelCollectionContext.cs) (revision 5ad23eae9f87bb12cbf453126070e8967e32d7ad) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/StochasticSoilModelCollectionContext.cs (.../StochasticSoilModelCollectionContext.cs) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -30,7 +30,7 @@ /// /// The presentation object for . /// - public class StochasticSoilModelCollectionContext : ObservableWrappedObjectContextBase> + public class StochasticSoilModelCollectionContext : ObservableWrappedObjectContextBase { /// /// Creates a new instance of . @@ -39,7 +39,7 @@ /// The failure mechanism. /// The assessment section. /// Thrown when any input argument is null. - public StochasticSoilModelCollectionContext(ObservableCollectionWithSourcePath wrappedStochasticSoilModels, + public StochasticSoilModelCollectionContext(StochasticSoilModelCollection wrappedStochasticSoilModels, PipingFailureMechanism failureMechanism, IAssessmentSection assessmentSection) : base(wrappedStochasticSoilModels) Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilDatabaseQueryBuilder.cs =================================================================== diff -u -re7e22e69b16b23c89c063f18444c82aa818dc176 -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilDatabaseQueryBuilder.cs (.../SoilDatabaseQueryBuilder.cs) (revision e7e22e69b16b23c89c063f18444c82aa818dc176) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilDatabaseQueryBuilder.cs (.../SoilDatabaseQueryBuilder.cs) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -20,6 +20,7 @@ // All rights reserved. using Ringtoets.Piping.IO.SoilProfile; +using Ringtoets.Piping.IO.SoilProfile.Schema; namespace Ringtoets.Piping.IO.Builders { @@ -34,7 +35,7 @@ /// /// The SQL query to execute. /// ME_Name needs to be - /// defined as . + /// defined as . public static string GetStochasticSoilModelOfMechanismQuery() { return string.Format(@"SELECT SP.{8}, SP.{9}, S.{10}, SSM.{11}, SSM.{12} " + @@ -43,19 +44,19 @@ "INNER JOIN {2} SSM USING({5}) " + "INNER JOIN {3} SP USING({6}) " + "WHERE M.{7} = @{7} ORDER BY SSM.{12};", - MechanismDatabaseColumns.TableName, - SegmentDatabaseColumns.TableName, - StochasticSoilModelDatabaseColumns.TableName, - SegmentPointsDatabaseColumns.TableName, - MechanismDatabaseColumns.MechanismId, - StochasticSoilModelDatabaseColumns.StochasticSoilModelId, - SegmentPointsDatabaseColumns.SegmentId, - MechanismDatabaseColumns.MechanismName, - SegmentPointsDatabaseColumns.CoordinateX, - SegmentPointsDatabaseColumns.CoordinateY, - SegmentDatabaseColumns.SegmentName, - StochasticSoilModelDatabaseColumns.StochasticSoilModelName, - StochasticSoilModelDatabaseColumns.StochasticSoilModelId + MechanismTableColumns.TableName, + SegmentTableColumns.TableName, + StochasticSoilModelTableColumns.TableName, + SegmentPointsTableColumns.TableName, + MechanismTableColumns.MechanismId, + StochasticSoilModelTableColumns.StochasticSoilModelId, + SegmentPointsTableColumns.SegmentId, + MechanismTableColumns.MechanismName, + SegmentPointsTableColumns.CoordinateX, + SegmentPointsTableColumns.CoordinateY, + SegmentTableColumns.SegmentName, + StochasticSoilModelTableColumns.StochasticSoilModelName, + StochasticSoilModelTableColumns.StochasticSoilModelId ); } @@ -75,15 +76,15 @@ "INNER JOIN {3} SP USING({6}) " + "WHERE M.{7} = @{7} GROUP BY {5}" + ");", - MechanismDatabaseColumns.TableName, - SegmentDatabaseColumns.TableName, - StochasticSoilModelDatabaseColumns.TableName, - SegmentPointsDatabaseColumns.TableName, - MechanismDatabaseColumns.MechanismId, - StochasticSoilModelDatabaseColumns.StochasticSoilModelId, - SegmentPointsDatabaseColumns.SegmentId, - MechanismDatabaseColumns.MechanismName, - StochasticSoilModelDatabaseColumns.Count + MechanismTableColumns.TableName, + SegmentTableColumns.TableName, + StochasticSoilModelTableColumns.TableName, + SegmentPointsTableColumns.TableName, + MechanismTableColumns.MechanismId, + StochasticSoilModelTableColumns.StochasticSoilModelId, + SegmentPointsTableColumns.SegmentId, + MechanismTableColumns.MechanismName, + StochasticSoilModelTableColumns.Count ); } @@ -95,11 +96,11 @@ public static string GetAllStochasticSoilProfileQuery() { return string.Format("SELECT {1}, {2}, {3}, {4} FROM {0} ORDER BY {1};", - StochasticSoilProfileDatabaseColumns.TableName, - StochasticSoilProfileDatabaseColumns.StochasticSoilModelId, - StochasticSoilProfileDatabaseColumns.Probability, - StochasticSoilProfileDatabaseColumns.SoilProfile1DId, - StochasticSoilProfileDatabaseColumns.SoilProfile2DId + StochasticSoilProfileTableColumns.TableName, + StochasticSoilProfileTableColumns.StochasticSoilModelId, + StochasticSoilProfileTableColumns.Probability, + StochasticSoilProfileTableColumns.SoilProfile1DId, + StochasticSoilProfileTableColumns.SoilProfile2DId ); } @@ -113,24 +114,34 @@ { return string.Format( "SELECT (" + - "SELECT COUNT(DISTINCT sl1D.SP1D_ID) " + - "FROM Mechanism AS m " + - "JOIN Segment AS segment USING(ME_ID) " + - "JOIN StochasticSoilProfile ssp USING(SSM_ID) " + - "JOIN SoilLayer1D sl1D USING(SP1D_ID) " + - "WHERE m.ME_Name = @{0}" + + "SELECT COUNT(DISTINCT sl1D.{5}) " + + "FROM {0} m " + + "JOIN {1} segment USING({2}) " + + "JOIN {3} ssp USING({4}) " + + "JOIN {9} sl1D USING({5}) " + + "WHERE m.{7} = @{7}" + ") + (" + - "SELECT COUNT(DISTINCT sl2D.SP2D_ID) " + - "FROM Mechanism AS m " + - "JOIN Segment AS segment USING(ME_ID) " + - "JOIN StochasticSoilProfile ssp USING(SSM_ID) " + - "JOIN SoilLayer2D sl2D USING(SP2D_ID) " + - "JOIN MechanismPointLocation mpl USING(ME_ID, SP2D_ID) " + - "WHERE m.ME_Name = @{0}" + + "SELECT COUNT(DISTINCT sl2D.{6}) " + + "FROM {0} m " + + "JOIN {1} segment USING({2}) " + + "JOIN {3} ssp USING({4}) " + + "JOIN {10} sl2D USING({6}) " + + "JOIN {8} mpl USING({2}, {6}) " + + "WHERE m.{7} = @{7}" + ") " + - "AS {1};", - MechanismDatabaseColumns.MechanismName, - SoilProfileDatabaseColumns.ProfileCount); + "AS {11};", + MechanismTableColumns.TableName, + SegmentTableColumns.TableName, + MechanismTableColumns.MechanismId, + StochasticSoilProfileTableColumns.TableName, + StochasticSoilProfileTableColumns.StochasticSoilModelId, + StochasticSoilProfileTableColumns.SoilProfile1DId, + StochasticSoilProfileTableColumns.SoilProfile2DId, + MechanismTableColumns.MechanismName, + MechanismPointLocationTableColumns.TableName, + SoilLayer1DTableColumns.TableName, + SoilLayer2DTableColumns.TableName, + SoilProfileTableColumns.ProfileCount); } /// @@ -143,10 +154,26 @@ { return string.Format( "SELECT {2} FROM {0} WHERE {1} = 'VERSION' AND {2} = @{2};", - MetaDataDatabaseColumns.TableName, - MetaDataDatabaseColumns.Key, - MetaDataDatabaseColumns.Value + MetaDataTableColumns.TableName, + MetaDataTableColumns.Key, + MetaDataTableColumns.Value ); } + + /// + /// Returns the SQL query to execute to check if segment names in the DSoil-Model database + /// are unique. + /// + /// The SQL query to execute. + public static string GetSoilModelNamesUniqueQuery() + { + return string.Format( + "SELECT [All].nameCount == [Distinct].nameCount as {0} " + + "FROM(SELECT COUNT({1}) nameCount FROM {2}) AS [All] " + + "JOIN(SELECT COUNT(DISTINCT {1}) nameCount FROM {2}) AS [Distinct];", + StochasticSoilModelTableColumns.AreSegmentsUnique, + StochasticSoilModelTableColumns.StochasticSoilModelName, + StochasticSoilModelTableColumns.TableName); + } } } \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/IStochasticSoilModelUpdateModelStrategy.cs =================================================================== diff -u -r0122d4ac58ee6f7be4ff804db1f6c65e88ce4562 -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/IStochasticSoilModelUpdateModelStrategy.cs (.../IStochasticSoilModelUpdateModelStrategy.cs) (revision 0122d4ac58ee6f7be4ff804db1f6c65e88ce4562) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/IStochasticSoilModelUpdateModelStrategy.cs (.../IStochasticSoilModelUpdateModelStrategy.cs) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -45,7 +45,7 @@ /// exception. /// A of updated instances. IEnumerable UpdateModelWithImportedData( - ObservableCollectionWithSourcePath targetCollection, + StochasticSoilModelCollection targetCollection, IEnumerable readStochasticSoilModels, string sourceFilePath); } Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/StochasticSoilModelImporter.cs =================================================================== diff -u -re010a3bcc0afc7dacd2e358604a96edabb9a1ed0 -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/StochasticSoilModelImporter.cs (.../StochasticSoilModelImporter.cs) (revision e010a3bcc0afc7dacd2e358604a96edabb9a1ed0) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/StochasticSoilModelImporter.cs (.../StochasticSoilModelImporter.cs) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -40,7 +40,7 @@ /// /// Imports .soil files (SqlLite database files) created with the D-Soil Model application. /// - public class StochasticSoilModelImporter : FileImporterBase> + public class StochasticSoilModelImporter : FileImporterBase { private readonly ILog log = LogManager.GetLogger(typeof(StochasticSoilModelImporter)); private readonly IStochasticSoilModelUpdateModelStrategy modelUpdateStrategy; @@ -54,7 +54,7 @@ /// when updating the . /// Thrown when or /// is null. - public StochasticSoilModelImporter(ObservableCollectionWithSourcePath importTarget, string filePath, IStochasticSoilModelUpdateModelStrategy modelUpdateStrategy) + public StochasticSoilModelImporter(StochasticSoilModelCollection importTarget, string filePath, IStochasticSoilModelUpdateModelStrategy modelUpdateStrategy) : base(filePath, importTarget) { if (modelUpdateStrategy == null) @@ -228,9 +228,7 @@ try { using (var stochasticSoilModelReader = new StochasticSoilModelReader(FilePath)) - { return GetStochasticSoilModelReadResult(stochasticSoilModelReader); - } } catch (CriticalFileReadException e) { Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj =================================================================== diff -u -r0122d4ac58ee6f7be4ff804db1f6c65e88ce4562 -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj (.../Ringtoets.Piping.IO.csproj) (revision 0122d4ac58ee6f7be4ff804db1f6c65e88ce4562) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj (.../Ringtoets.Piping.IO.csproj) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -64,13 +64,17 @@ - - - - - + + + + + + + + + - + @@ -87,7 +91,7 @@ True Resources.resx - + Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/CriticalProfileProperties.cs =================================================================== diff -u -r0df7cded06f5afbac08b97e025242ba55c90ec57 -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/CriticalProfileProperties.cs (.../CriticalProfileProperties.cs) (revision 0df7cded06f5afbac08b97e025242ba55c90ec57) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/CriticalProfileProperties.cs (.../CriticalProfileProperties.cs) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -24,6 +24,7 @@ using Core.Common.IO.Readers; using Core.Common.Utils.Builders; using Ringtoets.Piping.IO.Properties; +using Ringtoets.Piping.IO.SoilProfile.Schema; namespace Ringtoets.Piping.IO.SoilProfile { @@ -45,9 +46,9 @@ { try { - ProfileName = reader.Read(SoilProfileDatabaseColumns.ProfileName); - LayerCount = reader.Read(SoilProfileDatabaseColumns.LayerCount); - ProfileId = reader.Read(SoilProfileDatabaseColumns.SoilProfileId); + ProfileName = reader.Read(SoilProfileTableColumns.ProfileName); + LayerCount = reader.Read(SoilProfileTableColumns.LayerCount); + ProfileId = reader.Read(SoilProfileTableColumns.SoilProfileId); } catch (InvalidCastException e) { Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/LayerProperties.cs =================================================================== diff -u -rfa3b352bc1b1c01fc73a9a45268c5573807a6381 -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/LayerProperties.cs (.../LayerProperties.cs) (revision fa3b352bc1b1c01fc73a9a45268c5573807a6381) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/LayerProperties.cs (.../LayerProperties.cs) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -25,6 +25,7 @@ using Core.Common.Utils.Builders; using Ringtoets.Piping.IO.Exceptions; using Ringtoets.Piping.IO.Properties; +using Ringtoets.Piping.IO.SoilProfile.Schema; namespace Ringtoets.Piping.IO.SoilProfile { @@ -52,42 +53,42 @@ throw new ArgumentNullException(nameof(profileName)); } - string readColumn = SoilProfileDatabaseColumns.IsAquifer; + string readColumn = SoilProfileTableColumns.IsAquifer; try { IsAquifer = reader.ReadOrDefault(readColumn); - readColumn = SoilProfileDatabaseColumns.MaterialName; + readColumn = SoilProfileTableColumns.MaterialName; MaterialName = reader.ReadOrDefault(readColumn); - readColumn = SoilProfileDatabaseColumns.Color; + readColumn = SoilProfileTableColumns.Color; Color = reader.ReadOrDefault(readColumn); - readColumn = SoilProfileDatabaseColumns.BelowPhreaticLevelDistribution; + readColumn = SoilProfileTableColumns.BelowPhreaticLevelDistribution; BelowPhreaticLevelDistribution = reader.ReadOrDefault(readColumn); - readColumn = SoilProfileDatabaseColumns.BelowPhreaticLevelShift; + readColumn = SoilProfileTableColumns.BelowPhreaticLevelShift; BelowPhreaticLevelShift = reader.ReadOrDefault(readColumn); - readColumn = SoilProfileDatabaseColumns.BelowPhreaticLevelMean; + readColumn = SoilProfileTableColumns.BelowPhreaticLevelMean; BelowPhreaticLevelMean = reader.ReadOrDefault(readColumn); - readColumn = SoilProfileDatabaseColumns.BelowPhreaticLevelDeviation; + readColumn = SoilProfileTableColumns.BelowPhreaticLevelDeviation; BelowPhreaticLevelDeviation = reader.ReadOrDefault(readColumn); - readColumn = SoilProfileDatabaseColumns.DiameterD70Distribution; + readColumn = SoilProfileTableColumns.DiameterD70Distribution; DiameterD70Distribution = reader.ReadOrDefault(readColumn); - readColumn = SoilProfileDatabaseColumns.DiameterD70Shift; + readColumn = SoilProfileTableColumns.DiameterD70Shift; DiameterD70Shift = reader.ReadOrDefault(readColumn); - readColumn = SoilProfileDatabaseColumns.DiameterD70Mean; + readColumn = SoilProfileTableColumns.DiameterD70Mean; DiameterD70Mean = reader.ReadOrDefault(readColumn); - readColumn = SoilProfileDatabaseColumns.DiameterD70Deviation; + readColumn = SoilProfileTableColumns.DiameterD70Deviation; DiameterD70Deviation = reader.ReadOrDefault(readColumn); - readColumn = SoilProfileDatabaseColumns.PermeabilityDistribution; + readColumn = SoilProfileTableColumns.PermeabilityDistribution; PermeabilityDistribution = reader.ReadOrDefault(readColumn); - readColumn = SoilProfileDatabaseColumns.PermeabilityShift; + readColumn = SoilProfileTableColumns.PermeabilityShift; PermeabilityShift = reader.ReadOrDefault(readColumn); - readColumn = SoilProfileDatabaseColumns.PermeabilityMean; + readColumn = SoilProfileTableColumns.PermeabilityMean; PermeabilityMean = reader.ReadOrDefault(readColumn); - readColumn = SoilProfileDatabaseColumns.PermeabilityDeviation; + readColumn = SoilProfileTableColumns.PermeabilityDeviation; PermeabilityDeviation = reader.ReadOrDefault(readColumn); } catch (InvalidCastException e) Fisheye: Tag e1a8e98d60853beefbdb8c84e70f14165680ad7b refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/MechanismDatabaseColumns.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e1a8e98d60853beefbdb8c84e70f14165680ad7b refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/MetaDataDatabaseColumns.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/PipingSoilProfileReader.cs =================================================================== diff -u -r4e4ced94d27f939fc77f364201840814dc542af1 -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/PipingSoilProfileReader.cs (.../PipingSoilProfileReader.cs) (revision 4e4ced94d27f939fc77f364201840814dc542af1) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/PipingSoilProfileReader.cs (.../PipingSoilProfileReader.cs) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -28,6 +28,7 @@ using Ringtoets.Piping.IO.Builders; using Ringtoets.Piping.IO.Exceptions; using Ringtoets.Piping.IO.Properties; +using Ringtoets.Piping.IO.SoilProfile.Schema; using Ringtoets.Piping.Primitives; using UtilsResources = Core.Common.Utils.Properties.Resources; @@ -171,7 +172,7 @@ { try { - var dimensionValue = Read(SoilProfileDatabaseColumns.Dimension); + var dimensionValue = Read(SoilProfileTableColumns.Dimension); return dimensionValue == 1 ? SoilProfile1DReader.ReadFrom(this) : SoilProfile2DReader.ReadFrom(this); } catch (PipingSoilProfileReadException e) @@ -187,7 +188,7 @@ /// The name of the profile to skip. private void MoveToNextProfile(string profileName) { - while (HasNext && Read(SoilProfileDatabaseColumns.ProfileName).Equals(profileName)) + while (HasNext && Read(SoilProfileTableColumns.ProfileName).Equals(profileName)) { MoveNext(); } @@ -232,12 +233,12 @@ string.Format("SELECT SP1D_ID, COUNT(*) as {0} " + "FROM SoilLayer1D " + "GROUP BY SP1D_ID", - SoilProfileDatabaseColumns.LayerCount); + SoilProfileTableColumns.LayerCount); string subQueryGetNumberOfLayerProfile2D = string.Format("SELECT SP2D_ID, COUNT(*) as {0} " + "FROM SoilLayer2D " + "GROUP BY SP2D_ID", - SoilProfileDatabaseColumns.LayerCount); + SoilProfileTableColumns.LayerCount); string subQueryGetMaterialPropertiesOfLayer = string.Format( "SELECT " + @@ -261,20 +262,20 @@ "LEFT JOIN Stochast AS s USING(PN_ID) " + "JOIN Materials AS mat WHERE pv.MA_ID = mat.MA_ID OR s.MA_ID = mat.MA_ID " + "GROUP BY mat.MA_ID ", - SoilProfileDatabaseColumns.MaterialName, - SoilProfileDatabaseColumns.Color, - SoilProfileDatabaseColumns.BelowPhreaticLevelDistribution, - SoilProfileDatabaseColumns.BelowPhreaticLevelShift, - SoilProfileDatabaseColumns.BelowPhreaticLevelMean, - SoilProfileDatabaseColumns.BelowPhreaticLevelDeviation, - SoilProfileDatabaseColumns.PermeabilityDistribution, - SoilProfileDatabaseColumns.PermeabilityShift, - SoilProfileDatabaseColumns.PermeabilityMean, - SoilProfileDatabaseColumns.PermeabilityDeviation, - SoilProfileDatabaseColumns.DiameterD70Distribution, - SoilProfileDatabaseColumns.DiameterD70Shift, - SoilProfileDatabaseColumns.DiameterD70Mean, - SoilProfileDatabaseColumns.DiameterD70Deviation + SoilProfileTableColumns.MaterialName, + SoilProfileTableColumns.Color, + SoilProfileTableColumns.BelowPhreaticLevelDistribution, + SoilProfileTableColumns.BelowPhreaticLevelShift, + SoilProfileTableColumns.BelowPhreaticLevelMean, + SoilProfileTableColumns.BelowPhreaticLevelDeviation, + SoilProfileTableColumns.PermeabilityDistribution, + SoilProfileTableColumns.PermeabilityShift, + SoilProfileTableColumns.PermeabilityMean, + SoilProfileTableColumns.PermeabilityDeviation, + SoilProfileTableColumns.DiameterD70Distribution, + SoilProfileTableColumns.DiameterD70Shift, + SoilProfileTableColumns.DiameterD70Mean, + SoilProfileTableColumns.DiameterD70Deviation ); string subQueryGetLayerPropertiesOfLayer1D = string.Format( @@ -284,7 +285,7 @@ "FROM ParameterNames " + "JOIN LayerParameterValues USING(PN_ID) " + "WHERE PN_NAME = '{0}'", - SoilProfileDatabaseColumns.IsAquifer); + SoilProfileTableColumns.IsAquifer); string subQueryGetLayerPropertiesOfLayer2D = string.Format( "SELECT " + @@ -293,7 +294,7 @@ "FROM ParameterNames " + "JOIN LayerParameterValues USING(PN_ID) " + "WHERE PN_NAME = '{0}'", - SoilProfileDatabaseColumns.IsAquifer); + SoilProfileTableColumns.IsAquifer); var query1D = string.Format( "SELECT " + @@ -333,28 +334,28 @@ subQueryGetLayerPropertiesOfLayer1D + ") layerProperties USING(SL1D_ID) " + "WHERE m.{21} = @{21};", - SoilProfileDatabaseColumns.Dimension, - SoilProfileDatabaseColumns.ProfileName, - SoilProfileDatabaseColumns.LayerCount, - SoilProfileDatabaseColumns.Bottom, - SoilProfileDatabaseColumns.Top, - SoilProfileDatabaseColumns.MaterialName, - SoilProfileDatabaseColumns.IsAquifer, - SoilProfileDatabaseColumns.Color, - SoilProfileDatabaseColumns.BelowPhreaticLevelDistribution, - SoilProfileDatabaseColumns.BelowPhreaticLevelShift, - SoilProfileDatabaseColumns.BelowPhreaticLevelMean, - SoilProfileDatabaseColumns.BelowPhreaticLevelDeviation, - SoilProfileDatabaseColumns.DiameterD70Distribution, - SoilProfileDatabaseColumns.DiameterD70Shift, - SoilProfileDatabaseColumns.DiameterD70Mean, - SoilProfileDatabaseColumns.DiameterD70Deviation, - SoilProfileDatabaseColumns.PermeabilityDistribution, - SoilProfileDatabaseColumns.PermeabilityShift, - SoilProfileDatabaseColumns.PermeabilityMean, - SoilProfileDatabaseColumns.PermeabilityDeviation, - SoilProfileDatabaseColumns.SoilProfileId, - MechanismDatabaseColumns.MechanismName); + SoilProfileTableColumns.Dimension, + SoilProfileTableColumns.ProfileName, + SoilProfileTableColumns.LayerCount, + SoilProfileTableColumns.Bottom, + SoilProfileTableColumns.Top, + SoilProfileTableColumns.MaterialName, + SoilProfileTableColumns.IsAquifer, + SoilProfileTableColumns.Color, + SoilProfileTableColumns.BelowPhreaticLevelDistribution, + SoilProfileTableColumns.BelowPhreaticLevelShift, + SoilProfileTableColumns.BelowPhreaticLevelMean, + SoilProfileTableColumns.BelowPhreaticLevelDeviation, + SoilProfileTableColumns.DiameterD70Distribution, + SoilProfileTableColumns.DiameterD70Shift, + SoilProfileTableColumns.DiameterD70Mean, + SoilProfileTableColumns.DiameterD70Deviation, + SoilProfileTableColumns.PermeabilityDistribution, + SoilProfileTableColumns.PermeabilityShift, + SoilProfileTableColumns.PermeabilityMean, + SoilProfileTableColumns.PermeabilityDeviation, + SoilProfileTableColumns.SoilProfileId, + MechanismTableColumns.MechanismName); var query2D = string.Format( "SELECT " + @@ -395,28 +396,28 @@ subQueryGetLayerPropertiesOfLayer2D + ") layerProperties USING(SL2D_ID) " + "WHERE m.{21} = @{21};", - SoilProfileDatabaseColumns.Dimension, - SoilProfileDatabaseColumns.ProfileName, - SoilProfileDatabaseColumns.LayerCount, - SoilProfileDatabaseColumns.LayerGeometry, - SoilProfileDatabaseColumns.IntersectionX, - SoilProfileDatabaseColumns.MaterialName, - SoilProfileDatabaseColumns.IsAquifer, - SoilProfileDatabaseColumns.Color, - SoilProfileDatabaseColumns.BelowPhreaticLevelDistribution, - SoilProfileDatabaseColumns.BelowPhreaticLevelShift, - SoilProfileDatabaseColumns.BelowPhreaticLevelMean, - SoilProfileDatabaseColumns.BelowPhreaticLevelDeviation, - SoilProfileDatabaseColumns.DiameterD70Distribution, - SoilProfileDatabaseColumns.DiameterD70Shift, - SoilProfileDatabaseColumns.DiameterD70Mean, - SoilProfileDatabaseColumns.DiameterD70Deviation, - SoilProfileDatabaseColumns.PermeabilityDistribution, - SoilProfileDatabaseColumns.PermeabilityShift, - SoilProfileDatabaseColumns.PermeabilityMean, - SoilProfileDatabaseColumns.PermeabilityDeviation, - SoilProfileDatabaseColumns.SoilProfileId, - MechanismDatabaseColumns.MechanismName); + SoilProfileTableColumns.Dimension, + SoilProfileTableColumns.ProfileName, + SoilProfileTableColumns.LayerCount, + SoilProfileTableColumns.LayerGeometry, + SoilProfileTableColumns.IntersectionX, + SoilProfileTableColumns.MaterialName, + SoilProfileTableColumns.IsAquifer, + SoilProfileTableColumns.Color, + SoilProfileTableColumns.BelowPhreaticLevelDistribution, + SoilProfileTableColumns.BelowPhreaticLevelShift, + SoilProfileTableColumns.BelowPhreaticLevelMean, + SoilProfileTableColumns.BelowPhreaticLevelDeviation, + SoilProfileTableColumns.DiameterD70Distribution, + SoilProfileTableColumns.DiameterD70Shift, + SoilProfileTableColumns.DiameterD70Mean, + SoilProfileTableColumns.DiameterD70Deviation, + SoilProfileTableColumns.PermeabilityDistribution, + SoilProfileTableColumns.PermeabilityShift, + SoilProfileTableColumns.PermeabilityMean, + SoilProfileTableColumns.PermeabilityDeviation, + SoilProfileTableColumns.SoilProfileId, + MechanismTableColumns.MechanismName); dataReader = CreateDataReader(countQuery + query2D + query1D, new SQLiteParameter { @@ -426,15 +427,15 @@ }, new SQLiteParameter { DbType = DbType.String, - ParameterName = string.Format("@{0}", MechanismDatabaseColumns.MechanismName), + ParameterName = string.Format("@{0}", MechanismTableColumns.MechanismName), Value = pipingMechanismName }); } private void GetCount() { dataReader.Read(); - Count = (int) Read(SoilProfileDatabaseColumns.ProfileCount); + Count = (int) Read(SoilProfileTableColumns.ProfileCount); dataReader.NextResult(); } } Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/Schema/MechanismPointLocationTableColumns.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/Schema/MechanismPointLocationTableColumns.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/Schema/MechanismPointLocationTableColumns.cs (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -0,0 +1,33 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +namespace Ringtoets.Piping.IO.SoilProfile.Schema +{ + /// + /// This class contains the names of the table and columns of the table + /// 'Mechanism' of the DSoil-Model database. + /// + internal static class MechanismPointLocationTableColumns + { + internal const string TableName = "MechanismPointLocation"; + internal const string MechanismId = "ME_ID"; + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/Schema/MechanismTableColumns.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/Schema/MechanismTableColumns.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/Schema/MechanismTableColumns.cs (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -0,0 +1,34 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +namespace Ringtoets.Piping.IO.SoilProfile.Schema +{ + /// + /// This class contains the names of the table and columns of the table + /// 'Mechanism' of the DSoil-Model database. + /// + internal static class MechanismTableColumns + { + internal const string TableName = "Mechanism"; + internal const string MechanismId = "ME_ID"; + internal const string MechanismName = "ME_Name"; + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/Schema/MetaDataTableColumns.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/Schema/MetaDataTableColumns.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/Schema/MetaDataTableColumns.cs (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -0,0 +1,34 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +namespace Ringtoets.Piping.IO.SoilProfile.Schema +{ + /// + /// This class contains the names of the table and columns of the table + /// '_MetaData' of the DSoil-Model database. + /// + internal static class MetaDataTableColumns + { + internal const string TableName = "_MetaData"; + internal const string Key = "Key"; + internal const string Value = "Value"; + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/Schema/SegmentPointsTableColumns.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/Schema/SegmentPointsTableColumns.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/Schema/SegmentPointsTableColumns.cs (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -0,0 +1,35 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +namespace Ringtoets.Piping.IO.SoilProfile.Schema +{ + /// + /// This class contains the names of the table and columns of the table + /// 'SegmentPoints' of the DSoil-Model database. + /// + internal static class SegmentPointsTableColumns + { + internal const string TableName = "SegmentPoints"; + internal const string SegmentId = "SE_ID"; + internal const string CoordinateX = "XWorld"; + internal const string CoordinateY = "YWorld"; + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/Schema/SegmentTableColumns.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/Schema/SegmentTableColumns.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/Schema/SegmentTableColumns.cs (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -0,0 +1,33 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +namespace Ringtoets.Piping.IO.SoilProfile.Schema +{ + /// + /// This class contains the names of the table and columns of the table + /// 'Segment' of the DSoil-Model database. + /// + internal static class SegmentTableColumns + { + internal const string TableName = "Segment"; + internal const string SegmentName = "SE_Name"; + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/Schema/SoilLayer1DTableColumns.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/Schema/SoilLayer1DTableColumns.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/Schema/SoilLayer1DTableColumns.cs (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -0,0 +1,31 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +namespace Ringtoets.Piping.IO.SoilProfile.Schema +{ + /// + /// This class contains the column names that are used when querying the DSoil-Model database. + /// + internal static class SoilLayer1DTableColumns + { + internal const string TableName = "SoilLayer1D"; + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/Schema/SoilLayer2DTableColumns.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/Schema/SoilLayer2DTableColumns.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/Schema/SoilLayer2DTableColumns.cs (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -0,0 +1,31 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +namespace Ringtoets.Piping.IO.SoilProfile.Schema +{ + /// + /// This class contains the column names that are used when querying the DSoil-Model database. + /// + internal static class SoilLayer2DTableColumns + { + internal const string TableName = "SoilLayer2D"; + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/Schema/SoilProfileTableColumns.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/Schema/SoilProfileTableColumns.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/Schema/SoilProfileTableColumns.cs (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -0,0 +1,54 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +namespace Ringtoets.Piping.IO.SoilProfile.Schema +{ + /// + /// This class contains the column names that are used when querying the DSoil-Model database. + /// + internal static class SoilProfileTableColumns + { + internal const string SoilProfileId = "SoilProfileId"; + internal const string ProfileCount = "nrOfRows"; + internal const string Dimension = "Dimension"; + internal const string IsAquifer = "IsAquifer"; + internal const string ProfileName = "ProfileName"; + internal const string IntersectionX = "IntersectionX"; + internal const string Bottom = "Bottom"; + internal const string Top = "Top"; + internal const string Color = "Color"; + internal const string MaterialName = "MaterialName"; + internal const string LayerGeometry = "LayerGeometry"; + internal const string BelowPhreaticLevelDistribution = "BelowPhreaticLevelDistribution"; + internal const string BelowPhreaticLevelShift = "BelowPhreaticLevelShift"; + internal const string BelowPhreaticLevelMean = "BelowPhreaticLevelMean"; + internal const string BelowPhreaticLevelDeviation = "BelowPhreaticLevelDeviation"; + internal const string PermeabilityDistribution = "PermeabKxDistribution"; + internal const string PermeabilityShift = "PermeabKxShift"; + internal const string PermeabilityMean = "PermeabKxMean"; + internal const string PermeabilityDeviation = "PermeabKxDeviation"; + internal const string DiameterD70Distribution = "DiameterD70Distribution"; + internal const string DiameterD70Shift = "DiameterD70Shift"; + internal const string DiameterD70Mean = "DiameterD70Mean"; + internal const string DiameterD70Deviation = "DiameterD70Deviation"; + internal const string LayerCount = "LayerCount"; + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/Schema/StochasticSoilModelTableColumns.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/Schema/StochasticSoilModelTableColumns.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/Schema/StochasticSoilModelTableColumns.cs (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -0,0 +1,36 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +namespace Ringtoets.Piping.IO.SoilProfile.Schema +{ + /// + /// This class contains the names of the table and columns of the table + /// 'StochasticSoilModel' of the DSoil-Model database. + /// + internal static class StochasticSoilModelTableColumns + { + internal const string Count = "nrOfRows"; + internal const string TableName = "StochasticSoilModel"; + internal const string StochasticSoilModelId = "SSM_ID"; + internal const string StochasticSoilModelName = "SSM_Name"; + internal const string AreSegmentsUnique = "AreSegmentsUnique"; + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/Schema/StochasticSoilProfileTableColumns.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/Schema/StochasticSoilProfileTableColumns.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/Schema/StochasticSoilProfileTableColumns.cs (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -0,0 +1,36 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +namespace Ringtoets.Piping.IO.SoilProfile.Schema +{ + /// + /// This class contains the names of the table and columns of the table + /// 'StochasticSoilProfile' of the DSoil-Model database. + /// + internal static class StochasticSoilProfileTableColumns + { + internal const string TableName = "StochasticSoilProfile"; + internal const string StochasticSoilModelId = "SSM_ID"; + internal const string SoilProfile1DId = "SP1D_ID"; + internal const string SoilProfile2DId = "SP2D_ID"; + internal const string Probability = "Probability"; + } +} \ No newline at end of file Fisheye: Tag e1a8e98d60853beefbdb8c84e70f14165680ad7b refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SegmentDatabaseColumns.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e1a8e98d60853beefbdb8c84e70f14165680ad7b refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SegmentPointsDatabaseColumns.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilDatabaseConstraintsReader.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilDatabaseConstraintsReader.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilDatabaseConstraintsReader.cs (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -0,0 +1,96 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Data; +using System.Data.SQLite; +using Core.Common.IO.Exceptions; +using Core.Common.IO.Readers; +using Core.Common.Utils.Builders; +using Ringtoets.Piping.IO.Builders; +using Ringtoets.Piping.IO.Properties; +using Ringtoets.Piping.IO.SoilProfile.Schema; + +namespace Ringtoets.Piping.IO.SoilProfile +{ + /// + /// This class reads a soil database file and validates whether it meets required constraints. + /// + public class SoilDatabaseConstraintsReader : SqLiteDatabaseReaderBase + { + /// + /// 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. + /// No file could be found at . + /// The database version could not be read. + /// + public SoilDatabaseConstraintsReader(string databaseFilePath) : base(databaseFilePath) {} + + /// + /// Verifies if the database has the required version. + /// + /// Thrown when: + /// Required information for constraint evaluation could not be read. + /// The database segment names are not unique. + /// + public void VerifyConstraints() + { + try + { + ReadUniqueSegements(); + } + catch (SQLiteException exception) + { + throw new CriticalFileReadException( + BuildMessageWithPath("Kan geen ondergrondmodellen lezen. Mogelijk bestaat de 'Segment' tabel niet."), exception); + } + } + + private void ReadUniqueSegements() + { + string checkSegmentNameUniqueness = SoilDatabaseQueryBuilder.GetSoilModelNamesUniqueQuery(); + using (IDataReader dataReader = CreateDataReader(checkSegmentNameUniqueness)) + { + if (!dataReader.Read()) + { + throw new CriticalFileReadException( + BuildMessageWithPath("Onverwachte fout tijdens het verifiëren van unieke ondergrondmodelnamen.")); + } + if (!Convert.ToBoolean(dataReader[StochasticSoilModelTableColumns.AreSegmentsUnique])) + { + throw new CriticalFileReadException( + BuildMessageWithPath("Namen van ondergrondmodellen zijn niet uniek.")); + } + } + } + + private string BuildMessageWithPath(string innerMessage) + { + string message = new FileReaderErrorMessageBuilder(Path) + .Build(innerMessage); + return message; + } + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilDatabaseVersionReader.cs =================================================================== diff -u -rd73c509c93f18a87da76086c871eca2a2c903e12 -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilDatabaseVersionReader.cs (.../SoilDatabaseVersionReader.cs) (revision d73c509c93f18a87da76086c871eca2a2c903e12) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilDatabaseVersionReader.cs (.../SoilDatabaseVersionReader.cs) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -26,6 +26,7 @@ using Core.Common.Utils.Builders; using Ringtoets.Piping.IO.Builders; using Ringtoets.Piping.IO.Properties; +using Ringtoets.Piping.IO.SoilProfile.Schema; namespace Ringtoets.Piping.IO.SoilProfile { @@ -62,7 +63,7 @@ var sqliteParameter = new SQLiteParameter { DbType = DbType.String, - ParameterName = string.Format("@{0}", MetaDataDatabaseColumns.Value), + ParameterName = $"@{MetaDataTableColumns.Value}", Value = databaseRequiredVersion }; Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfile1DReader.cs =================================================================== diff -u -rfa3b352bc1b1c01fc73a9a45268c5573807a6381 -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfile1DReader.cs (.../SoilProfile1DReader.cs) (revision fa3b352bc1b1c01fc73a9a45268c5573807a6381) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfile1DReader.cs (.../SoilProfile1DReader.cs) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -27,6 +27,7 @@ using Ringtoets.Piping.IO.Builders; using Ringtoets.Piping.IO.Exceptions; using Ringtoets.Piping.IO.Properties; +using Ringtoets.Piping.IO.SoilProfile.Schema; using Ringtoets.Piping.Primitives; namespace Ringtoets.Piping.IO.SoilProfile @@ -149,7 +150,7 @@ internal Layer1DProperties(IRowBasedDatabaseReader reader, string profileName) : base(reader, profileName) { - string readColumn = SoilProfileDatabaseColumns.Top; + string readColumn = SoilProfileTableColumns.Top; try { Top = reader.Read(readColumn); @@ -182,7 +183,7 @@ /// casted to the expected column types. internal RequiredProfileProperties(IRowBasedDatabaseReader reader, string profileName) { - string readColumn = SoilProfileDatabaseColumns.Bottom; + string readColumn = SoilProfileTableColumns.Bottom; try { Bottom = reader.Read(readColumn); Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfile2DReader.cs =================================================================== diff -u -rfa3b352bc1b1c01fc73a9a45268c5573807a6381 -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfile2DReader.cs (.../SoilProfile2DReader.cs) (revision fa3b352bc1b1c01fc73a9a45268c5573807a6381) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfile2DReader.cs (.../SoilProfile2DReader.cs) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -27,6 +27,7 @@ using Ringtoets.Piping.IO.Builders; using Ringtoets.Piping.IO.Exceptions; using Ringtoets.Piping.IO.Properties; +using Ringtoets.Piping.IO.SoilProfile.Schema; using Ringtoets.Piping.Primitives; namespace Ringtoets.Piping.IO.SoilProfile @@ -142,7 +143,7 @@ { try { - return reader.Read(SoilProfileDatabaseColumns.LayerGeometry); + return reader.Read(SoilProfileTableColumns.LayerGeometry); } catch (InvalidCastException e) { @@ -181,7 +182,7 @@ /// casted to the expected column types. internal RequiredProfileProperties(IRowBasedDatabaseReader reader, string profileName) { - string readColumn = SoilProfileDatabaseColumns.IntersectionX; + string readColumn = SoilProfileTableColumns.IntersectionX; try { IntersectionX = reader.Read(readColumn); Fisheye: Tag e1a8e98d60853beefbdb8c84e70f14165680ad7b refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfileDatabaseColumns.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e1a8e98d60853beefbdb8c84e70f14165680ad7b refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/StochasticSoilModelDatabaseColumns.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/StochasticSoilModelReader.cs =================================================================== diff -u -rd73c509c93f18a87da76086c871eca2a2c903e12 -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/StochasticSoilModelReader.cs (.../StochasticSoilModelReader.cs) (revision d73c509c93f18a87da76086c871eca2a2c903e12) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/StochasticSoilModelReader.cs (.../StochasticSoilModelReader.cs) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -30,6 +30,7 @@ using Ringtoets.Piping.IO.Builders; using Ringtoets.Piping.IO.Exceptions; using Ringtoets.Piping.IO.Properties; +using Ringtoets.Piping.IO.SoilProfile.Schema; namespace Ringtoets.Piping.IO.SoilProfile { @@ -57,6 +58,7 @@ { filePath = databaseFilePath; VerifyVersion(databaseFilePath); + VerifyConstraints(databaseFilePath); InitializeReader(); } @@ -106,7 +108,7 @@ private int ReadStochasticSoilModelCount() { - return !dataReader.Read() ? 0 : Convert.ToInt32(dataReader[StochasticSoilModelDatabaseColumns.Count]); + return !dataReader.Read() ? 0 : Convert.ToInt32(dataReader[StochasticSoilModelTableColumns.Count]); } private StochasticSoilModel ReadPipingStochasticSoilModel() @@ -179,7 +181,7 @@ var sqliteParameter = new SQLiteParameter { DbType = DbType.String, - ParameterName = string.Format("@{0}", MechanismDatabaseColumns.MechanismName), + ParameterName = string.Format("@{0}", MechanismTableColumns.MechanismName), Value = pipingMechanismName }; try @@ -212,18 +214,34 @@ } } + private void VerifyConstraints(string databaseFilePath) + { + using (var versionReader = new SoilDatabaseConstraintsReader(databaseFilePath)) + { + try + { + versionReader.VerifyConstraints(); + } + catch (CriticalFileReadException) + { + CloseConnection(); + throw; + } + } + } + private StochasticSoilModel ReadStochasticSoilModelSegment() { - var stochasticSoilModelId = Convert.ToInt64(dataReader[StochasticSoilModelDatabaseColumns.StochasticSoilModelId]); - var stochasticSoilModelName = Convert.ToString(dataReader[StochasticSoilModelDatabaseColumns.StochasticSoilModelName]); - var segmentName = Convert.ToString(dataReader[SegmentDatabaseColumns.SegmentName]); + var stochasticSoilModelId = Convert.ToInt64(dataReader[StochasticSoilModelTableColumns.StochasticSoilModelId]); + var stochasticSoilModelName = Convert.ToString(dataReader[StochasticSoilModelTableColumns.StochasticSoilModelName]); + var segmentName = Convert.ToString(dataReader[SegmentTableColumns.SegmentName]); return new StochasticSoilModel(stochasticSoilModelId, stochasticSoilModelName, segmentName); } private Point2D ReadSegmentPoint() { - double coordinateX = Convert.ToDouble(dataReader[SegmentPointsDatabaseColumns.CoordinateX]); - double coordinateY = Convert.ToDouble(dataReader[SegmentPointsDatabaseColumns.CoordinateY]); + double coordinateX = Convert.ToDouble(dataReader[SegmentPointsTableColumns.CoordinateX]); + double coordinateY = Convert.ToDouble(dataReader[SegmentPointsTableColumns.CoordinateY]); return new Point2D(coordinateX, coordinateY); } } Fisheye: Tag e1a8e98d60853beefbdb8c84e70f14165680ad7b refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/StochasticSoilProfileDatabaseColumns.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/StochasticSoilProfileReader.cs =================================================================== diff -u -r24145cb7feea063e2986e8f4b2270bb2a478b3fd -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/StochasticSoilProfileReader.cs (.../StochasticSoilProfileReader.cs) (revision 24145cb7feea063e2986e8f4b2270bb2a478b3fd) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/StochasticSoilProfileReader.cs (.../StochasticSoilProfileReader.cs) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -29,6 +29,7 @@ using Ringtoets.Piping.IO.Builders; using Ringtoets.Piping.IO.Exceptions; using Ringtoets.Piping.IO.Properties; +using Ringtoets.Piping.IO.SoilProfile.Schema; using Ringtoets.Piping.Primitives; namespace Ringtoets.Piping.IO.SoilProfile @@ -189,12 +190,12 @@ private long ReadStochasticSoilModelId() { - return Convert.ToInt64(dataReader[StochasticSoilProfileDatabaseColumns.StochasticSoilModelId]); + return Convert.ToInt64(dataReader[StochasticSoilProfileTableColumns.StochasticSoilModelId]); } private StochasticSoilProfile ReadStochasticSoilProfileProbability() { - var valueProbability = dataReader[StochasticSoilProfileDatabaseColumns.Probability]; + var valueProbability = dataReader[StochasticSoilProfileTableColumns.Probability]; var probability = valueProbability.Equals(DBNull.Value) ? 0 : Convert.ToDouble(valueProbability); var soilProfile1DId = ReadSoilProfile1DId(probability); @@ -216,7 +217,7 @@ private StochasticSoilProfile ReadSoilProfile2DId(double probability) { - var valueSoilProfile2DId = dataReader[StochasticSoilProfileDatabaseColumns.SoilProfile2DId]; + var valueSoilProfile2DId = dataReader[StochasticSoilProfileTableColumns.SoilProfile2DId]; if (!valueSoilProfile2DId.Equals(DBNull.Value)) { var soilProfileId = Convert.ToInt64(valueSoilProfile2DId); @@ -227,7 +228,7 @@ private StochasticSoilProfile ReadSoilProfile1DId(double probability) { - var valueSoilProfile1DId = dataReader[StochasticSoilProfileDatabaseColumns.SoilProfile1DId]; + var valueSoilProfile1DId = dataReader[StochasticSoilProfileTableColumns.SoilProfile1DId]; if (!valueSoilProfile1DId.Equals(DBNull.Value)) { var soilProfileId = Convert.ToInt64(valueSoilProfile1DId); Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/StochasticSoilModelReplaceDataStrategy.cs =================================================================== diff -u -re010a3bcc0afc7dacd2e358604a96edabb9a1ed0 -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/StochasticSoilModelReplaceDataStrategy.cs (.../StochasticSoilModelReplaceDataStrategy.cs) (revision e010a3bcc0afc7dacd2e358604a96edabb9a1ed0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/StochasticSoilModelReplaceDataStrategy.cs (.../StochasticSoilModelReplaceDataStrategy.cs) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -23,6 +23,7 @@ using System.Collections.Generic; using System.Linq; using Core.Common.Base; +using Core.Common.Base.Storage; using log4net; using Ringtoets.Piping.Data; using Ringtoets.Piping.IO.Importers; @@ -52,7 +53,7 @@ this.failureMechanism = failureMechanism; } - public IEnumerable UpdateModelWithImportedData(ObservableCollectionWithSourcePath targetCollection, + public IEnumerable UpdateModelWithImportedData(StochasticSoilModelCollection targetCollection, IEnumerable readStochasticSoilModels, string sourceFilePath) { @@ -74,16 +75,18 @@ targetCollection }; - var modelsToAdd = new List(); - foreach (StochasticSoilModel readStochasticSoilModel in readStochasticSoilModels) - { - modelsToAdd.Add(readStochasticSoilModel); - } foreach (StochasticSoilModel model in targetCollection.ToArray()) { affectedObjects.AddRange(PipingDataSynchronizationService.RemoveStochasticSoilModel(failureMechanism, model)); } - targetCollection.AddRange(modelsToAdd, sourceFilePath); + try + { + targetCollection.AddRange(readStochasticSoilModels.ToList(), sourceFilePath); + } + catch (ArgumentException e) + { + throw new StochasticSoilModelUpdateException(e.Message, e); + } return affectedObjects.Distinct(); } } Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/StochasticSoilModelUpdateDataStrategy.cs =================================================================== diff -u -r8c8285c58f677a2905127f1c3576eb7d6ea4206b -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/StochasticSoilModelUpdateDataStrategy.cs (.../StochasticSoilModelUpdateDataStrategy.cs) (revision 8c8285c58f677a2905127f1c3576eb7d6ea4206b) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/StochasticSoilModelUpdateDataStrategy.cs (.../StochasticSoilModelUpdateDataStrategy.cs) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -57,7 +57,7 @@ this.failureMechanism = failureMechanism; } - public IEnumerable UpdateModelWithImportedData(ObservableCollectionWithSourcePath targetCollection, + public IEnumerable UpdateModelWithImportedData(StochasticSoilModelCollection targetCollection, IEnumerable readStochasticSoilModels, string sourceFilePath) { @@ -86,7 +86,7 @@ } private IEnumerable ModifyModelCollection(IEnumerable readStochasticSoilModels, - ObservableCollectionWithSourcePath targetCollection, + StochasticSoilModelCollection targetCollection, string sourceFilePath) { List readModelList = readStochasticSoilModels.ToList(); @@ -103,14 +103,29 @@ affectedObjects.AddRange(RemoveModels(removedModels)); targetCollection.Clear(); - targetCollection.AddRange(addedModels.Union(updatedModels), sourceFilePath); + try + { + targetCollection.AddRange(addedModels.Union(updatedModels), sourceFilePath); + } + catch (Exception e) + { + throw new StochasticSoilModelUpdateException(e.Message, e); + } + return affectedObjects.Distinct(new ReferenceEqualityComparer()); } private static IEnumerable GetAddedReadModels(IEnumerable existingCollection, IEnumerable readStochasticSoilModels) { - return readStochasticSoilModels.Except(existingCollection, new SoilModelNameEqualityComparer()); + var comparer = new SoilModelNameEqualityComparer(); + foreach (StochasticSoilModel source in readStochasticSoilModels) + { + if (!existingCollection.Contains(source, comparer)) + { + yield return source; + } + } } private static IEnumerable GetUpdatedExistingModels(IEnumerable existingCollection, IEnumerable readStochasticSoilModels) Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Ringtoets.Piping.Data.Test.csproj =================================================================== diff -u -r5ad23eae9f87bb12cbf453126070e8967e32d7ad -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Ringtoets.Piping.Data.Test.csproj (.../Ringtoets.Piping.Data.Test.csproj) (revision 5ad23eae9f87bb12cbf453126070e8967e32d7ad) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Ringtoets.Piping.Data.Test.csproj (.../Ringtoets.Piping.Data.Test.csproj) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -75,6 +75,7 @@ + Fisheye: Tag 5ad23eae9f87bb12cbf453126070e8967e32d7ad refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/StochasticSoilModelCollectionTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/StochasticSoilModelCollectionContextTest.cs =================================================================== diff -u -r5ad23eae9f87bb12cbf453126070e8967e32d7ad -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/StochasticSoilModelCollectionContextTest.cs (.../StochasticSoilModelCollectionContextTest.cs) (revision 5ad23eae9f87bb12cbf453126070e8967e32d7ad) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/StochasticSoilModelCollectionContextTest.cs (.../StochasticSoilModelCollectionContextTest.cs) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -47,7 +47,7 @@ var context = new StochasticSoilModelCollectionContext(failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); // Assert - Assert.IsInstanceOf>>(context); + Assert.IsInstanceOf>(context); Assert.AreSame(failureMechanism.StochasticSoilModels, context.WrappedData); Assert.AreSame(failureMechanism, context.FailureMechanism); Assert.AreSame(assessmentSection, context.AssessmentSection); @@ -62,7 +62,7 @@ var assessmentSection = mocks.Stub(); mocks.ReplayAll(); - var stochasticSoilModels = new ObservableCollectionWithSourcePath(); + var stochasticSoilModels = new StochasticSoilModelCollection(); // Call TestDelegate test = () => new StochasticSoilModelCollectionContext(stochasticSoilModels, null, assessmentSection); Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilDatabaseQueryBuilderTest.cs =================================================================== diff -u -r2d7f22520e157ccfefbf12a4d9845de8bfb04f50 -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilDatabaseQueryBuilderTest.cs (.../SoilDatabaseQueryBuilderTest.cs) (revision 2d7f22520e157ccfefbf12a4d9845de8bfb04f50) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilDatabaseQueryBuilderTest.cs (.../SoilDatabaseQueryBuilderTest.cs) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -66,15 +66,15 @@ // Setup const string expectedQuery = "SELECT (" + "SELECT COUNT(DISTINCT sl1D.SP1D_ID) " + - "FROM Mechanism AS m " + - "JOIN Segment AS segment USING(ME_ID) " + + "FROM Mechanism m " + + "JOIN Segment segment USING(ME_ID) " + "JOIN StochasticSoilProfile ssp USING(SSM_ID) " + "JOIN SoilLayer1D sl1D USING(SP1D_ID) " + "WHERE m.ME_Name = @ME_Name" + ") + (" + "SELECT COUNT(DISTINCT sl2D.SP2D_ID) " + - "FROM Mechanism AS m " + - "JOIN Segment AS segment USING(ME_ID) " + + "FROM Mechanism m " + + "JOIN Segment segment USING(ME_ID) " + "JOIN StochasticSoilProfile ssp USING(SSM_ID) " + "JOIN SoilLayer2D sl2D USING(SP2D_ID) " + "JOIN MechanismPointLocation mpl USING(ME_ID, SP2D_ID) " + @@ -107,6 +107,22 @@ } [Test] + public void GetSegmentNamesUniqueQuery_Always_ReturnsExpectedValues() + { + // Setup + const string expectedQuery = + "SELECT [All].nameCount == [Distinct].nameCount as AreSegmentsUnique " + + "FROM(SELECT COUNT(SSM_Name) nameCount FROM StochasticSoilModel) AS [All] " + + "JOIN(SELECT COUNT(DISTINCT SSM_Name) nameCount FROM StochasticSoilModel) AS [Distinct];"; + + // Call + string query = SoilDatabaseQueryBuilder.GetSoilModelNamesUniqueQuery(); + + // Assert + Assert.AreEqual(expectedQuery, query); + } + + [Test] public void GetCheckVersionQuery_Always_ReturnsExpectedValues() { // Setup Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Exporters/CalculationGroupWriterTest.cs =================================================================== diff -u -r182439744861ddb032d90ace9041f96d8ec5fe28 -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Exporters/CalculationGroupWriterTest.cs (.../CalculationGroupWriterTest.cs) (revision 182439744861ddb032d90ace9041f96d8ec5fe28) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Exporters/CalculationGroupWriterTest.cs (.../CalculationGroupWriterTest.cs) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -214,7 +214,6 @@ var actualXml = File.ReadAllText(filePath); var expectedXml = File.ReadAllText(Path.Combine(directoryPath, $"{expectedFileName}.xml")); - Assert.AreEqual(expectedXml, actualXml); } finally Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/StochasticSoilModelImporterTest.cs =================================================================== diff -u -r8c8285c58f677a2905127f1c3576eb7d6ea4206b -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/StochasticSoilModelImporterTest.cs (.../StochasticSoilModelImporterTest.cs) (revision 8c8285c58f677a2905127f1c3576eb7d6ea4206b) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/StochasticSoilModelImporterTest.cs (.../StochasticSoilModelImporterTest.cs) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -67,7 +67,7 @@ { // Call TestDelegate call = () => new StochasticSoilModelImporter( - new ObservableCollectionWithSourcePath(), + new StochasticSoilModelCollection(), "", null); @@ -79,7 +79,7 @@ [Test] public void Constructor_ExpectedValues() { - var list = new ObservableCollectionWithSourcePath(); + var list = new StochasticSoilModelCollection(); // Call var importer = new StochasticSoilModelImporter( @@ -88,7 +88,7 @@ new TestStochasticSoilModelUpdateModelStrategy()); // Assert - Assert.IsInstanceOf>>(importer); + Assert.IsInstanceOf>(importer); } [Test] @@ -106,9 +106,6 @@ updateStrategy); importer.SetProgressChanged(IncrementProgress); - // Precondition - CollectionAssert.IsEmpty(failureMechanism.StochasticSoilModels); - var importResult = true; // Call @@ -130,7 +127,7 @@ public void Import_FromInvalidFileName_LogError() { // Setup - var file = "/"; + const string file = "/"; string invalidFilePath = Path.Combine(testDataPath, file); var failureMechanism = new PipingFailureMechanism(); @@ -141,9 +138,6 @@ updateStrategy); importer.SetProgressChanged(IncrementProgress); - // Precondition - CollectionAssert.IsEmpty(failureMechanism.StochasticSoilModels); - var importResult = true; // Call @@ -230,19 +224,13 @@ importer.SetProgressChanged(IncrementProgress); var importResult = false; - - // Precondition importer.Import(); - IEnumerable alreadyImportedSoilModelNames = failureMechanism.StochasticSoilModels.Select(ssm => ssm.Name); // Call Action call = () => importResult = importer.Import(); // Assert - string[] expectedLogMessages = alreadyImportedSoilModelNames - .Select(name => $"Het stochastische ondergrondmodel '{name}' bestaat al in het toetsspoor.") - .ToArray(); - TestHelper.AssertLogMessagesAreGenerated(call, expectedLogMessages, expectedLogMessages.Length); + TestHelper.AssertLogMessagesCount(call, 0); Assert.AreEqual(35 * 2, progress); StochasticSoilModel[] readModels = AssertSuccessfulImport(validFilePath, importResult, updateStrategy); @@ -269,10 +257,6 @@ } }); - // Precondition - CollectionAssert.IsEmpty(failureMechanism.StochasticSoilModels); - Assert.IsTrue(File.Exists(validFilePath)); - var importResult = true; // Call @@ -303,10 +287,6 @@ } }); - // Precondition - CollectionAssert.IsEmpty(failureMechanism.StochasticSoilModels); - Assert.IsTrue(File.Exists(validFilePath)); - var importResult = true; // Call @@ -337,10 +317,6 @@ } }); - // Precondition - CollectionAssert.IsEmpty(failureMechanism.StochasticSoilModels); - Assert.IsTrue(File.Exists(validFilePath)); - var importResult = true; // Call @@ -371,10 +347,6 @@ } }); - // Precondition - CollectionAssert.IsEmpty(failureMechanism.StochasticSoilModels); - Assert.IsTrue(File.Exists(validFilePath)); - var importResult = false; // Call @@ -400,11 +372,6 @@ updateStrategy); importer.SetProgressChanged((description, step, steps) => importer.Cancel()); - // Precondition - CollectionAssert.IsEmpty(failureMechanism.StochasticSoilModels); - Assert.IsTrue(File.Exists(validFilePath)); - - // Setup (second part) bool importResult = importer.Import(); Assert.IsFalse(importResult); @@ -705,10 +672,6 @@ updateStrategy); importer.SetProgressChanged(IncrementProgress); - // Precondition - CollectionAssert.IsEmpty(failureMechanism.StochasticSoilModels); - Assert.IsTrue(File.Exists(validFilePath)); - // Call bool importResult = importer.Import(); @@ -763,10 +726,6 @@ updateStrategy); importer.SetProgressChanged(IncrementProgress); - // Precondition - CollectionAssert.IsEmpty(failureMechanism.StochasticSoilModels); - Assert.IsTrue(File.Exists(validFilePath)); - // Call bool importResult = importer.Import(); @@ -850,7 +809,7 @@ observableB }; var importer = new StochasticSoilModelImporter( - new ObservableCollectionWithSourcePath(), + new StochasticSoilModelCollection(), validFilePath, updateStrategy); importer.Import(); Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/CriticalProfilePropertiesTest.cs =================================================================== diff -u -r2d7f22520e157ccfefbf12a4d9845de8bfb04f50 -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/CriticalProfilePropertiesTest.cs (.../CriticalProfilePropertiesTest.cs) (revision 2d7f22520e157ccfefbf12a4d9845de8bfb04f50) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/CriticalProfilePropertiesTest.cs (.../CriticalProfilePropertiesTest.cs) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -27,6 +27,7 @@ using Rhino.Mocks; using Ringtoets.Piping.IO.Properties; using Ringtoets.Piping.IO.SoilProfile; +using Ringtoets.Piping.IO.SoilProfile.Schema; namespace Ringtoets.Piping.IO.Test.SoilProfile { @@ -50,9 +51,9 @@ var layerCount = 1; long soilProfileId = 1234; - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.ProfileName)).IgnoreArguments().Return(profileName); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).IgnoreArguments().Return(layerCount); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.SoilProfileId)).IgnoreArguments().Return(soilProfileId); + reader.Expect(r => r.Read(SoilProfileTableColumns.ProfileName)).IgnoreArguments().Return(profileName); + reader.Expect(r => r.Read(SoilProfileTableColumns.LayerCount)).IgnoreArguments().Return(layerCount); + reader.Expect(r => r.Read(SoilProfileTableColumns.SoilProfileId)).IgnoreArguments().Return(soilProfileId); mocks.ReplayAll(); @@ -76,8 +77,8 @@ string path = "A"; var invalidCastException = new InvalidCastException(); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.ProfileName)).IgnoreArguments().Throw(invalidCastException); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).IgnoreArguments().Return(layerCount).Repeat.Any(); + reader.Expect(r => r.Read(SoilProfileTableColumns.ProfileName)).IgnoreArguments().Throw(invalidCastException); + reader.Expect(r => r.Read(SoilProfileTableColumns.LayerCount)).IgnoreArguments().Return(layerCount).Repeat.Any(); reader.Expect(r => r.Path).Return(path); mocks.ReplayAll(); @@ -104,8 +105,8 @@ string path = "A"; var invalidCastException = new InvalidCastException(); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.ProfileName)).IgnoreArguments().Return(profileName).Repeat.Any(); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Throw(invalidCastException); + reader.Expect(r => r.Read(SoilProfileTableColumns.ProfileName)).IgnoreArguments().Return(profileName).Repeat.Any(); + reader.Expect(r => r.Read(SoilProfileTableColumns.LayerCount)).Throw(invalidCastException); reader.Expect(r => r.Path).Return(path); mocks.ReplayAll(); Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/LayerPropertiesTest.cs =================================================================== diff -u -r2aa9661130f20e88c41dac921ffb780573dcf799 -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/LayerPropertiesTest.cs (.../LayerPropertiesTest.cs) (revision 2aa9661130f20e88c41dac921ffb780573dcf799) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/LayerPropertiesTest.cs (.../LayerPropertiesTest.cs) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -25,6 +25,7 @@ using Rhino.Mocks; using Ringtoets.Piping.IO.Exceptions; using Ringtoets.Piping.IO.SoilProfile; +using Ringtoets.Piping.IO.SoilProfile.Schema; namespace Ringtoets.Piping.IO.Test.SoilProfile { @@ -81,21 +82,21 @@ var mocks = new MockRepository(); IRowBasedDatabaseReader reader = mocks.StrictMock(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.IsAquifer)).Return(1.0); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.MaterialName)).Return(""); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.Color)).Return(color); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.BelowPhreaticLevelDistribution)).Return(belowPhreaticLevelDistribution); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.BelowPhreaticLevelShift)).Return(belowPhreaticLevelShift); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.BelowPhreaticLevelMean)).Return(belowPhreaticLevelMean); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.BelowPhreaticLevelDeviation)).Return(belowPhreaticLevelDeviation); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.DiameterD70Distribution)).Return(diameterD70Distribution); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.DiameterD70Shift)).Return(diameterD70Shift); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.DiameterD70Mean)).Return(diameterD70Mean); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.DiameterD70Deviation)).Return(diameterD70Deviation); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.PermeabilityDistribution)).Return(permeabilityDistribution); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.PermeabilityShift)).Return(permeabilityShift); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.PermeabilityMean)).Return(permeabilityMean); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.PermeabilityDeviation)).Return(permeabilityDeviation); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.IsAquifer)).Return(1.0); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.MaterialName)).Return(""); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.Color)).Return(color); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.BelowPhreaticLevelDistribution)).Return(belowPhreaticLevelDistribution); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.BelowPhreaticLevelShift)).Return(belowPhreaticLevelShift); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.BelowPhreaticLevelMean)).Return(belowPhreaticLevelMean); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.BelowPhreaticLevelDeviation)).Return(belowPhreaticLevelDeviation); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.DiameterD70Distribution)).Return(diameterD70Distribution); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.DiameterD70Shift)).Return(diameterD70Shift); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.DiameterD70Mean)).Return(diameterD70Mean); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.DiameterD70Deviation)).Return(diameterD70Deviation); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.PermeabilityDistribution)).Return(permeabilityDistribution); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.PermeabilityShift)).Return(permeabilityShift); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.PermeabilityMean)).Return(permeabilityMean); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.PermeabilityDeviation)).Return(permeabilityDeviation); mocks.ReplayAll(); // Call @@ -127,7 +128,7 @@ var mocks = new MockRepository(); IRowBasedDatabaseReader reader = mocks.StrictMock(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.IsAquifer)).Throw(new InvalidCastException()); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.IsAquifer)).Throw(new InvalidCastException()); reader.Expect(r => r.Path).Return(path); mocks.ReplayAll(); Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile1DReaderTest.cs =================================================================== diff -u -r2aa9661130f20e88c41dac921ffb780573dcf799 -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile1DReaderTest.cs (.../SoilProfile1DReaderTest.cs) (revision 2aa9661130f20e88c41dac921ffb780573dcf799) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile1DReaderTest.cs (.../SoilProfile1DReaderTest.cs) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -30,6 +30,7 @@ using Ringtoets.Piping.IO.Builders; using Ringtoets.Piping.IO.Exceptions; using Ringtoets.Piping.IO.SoilProfile; +using Ringtoets.Piping.IO.SoilProfile.Schema; using Ringtoets.Piping.Primitives; namespace Ringtoets.Piping.IO.Test.SoilProfile @@ -54,8 +55,8 @@ const string profileName = ""; const string path = "A"; - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.ProfileName)).Return(profileName); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Throw(new InvalidCastException()); + reader.Expect(r => r.Read(SoilProfileTableColumns.ProfileName)).Return(profileName); + reader.Expect(r => r.Read(SoilProfileTableColumns.LayerCount)).Throw(new InvalidCastException()); reader.Expect(r => r.Path).Return(path); mocks.ReplayAll(); @@ -81,9 +82,9 @@ const string path = "A"; reader.Expect(r => r.Path).Return(path); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1).Repeat.Any(); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.ProfileName)).Return(profileName).Repeat.Any(); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.Bottom)).Throw(new InvalidCastException()); + reader.Expect(r => r.Read(SoilProfileTableColumns.LayerCount)).Return(1).Repeat.Any(); + reader.Expect(r => r.Read(SoilProfileTableColumns.ProfileName)).Return(profileName).Repeat.Any(); + reader.Expect(r => r.Read(SoilProfileTableColumns.Bottom)).Throw(new InvalidCastException()); mocks.ReplayAll(); @@ -132,10 +133,10 @@ const string path = "A"; const string profileName = ""; - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.ProfileName)).Return(profileName); + reader.Expect(r => r.Read(SoilProfileTableColumns.ProfileName)).Return(profileName); reader.Expect(r => r.Path).Return(path); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.IsAquifer)).Throw(new InvalidCastException()); + reader.Expect(r => r.Read(SoilProfileTableColumns.LayerCount)).Return(1).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.IsAquifer)).Throw(new InvalidCastException()); mocks.ReplayAll(); // Call @@ -189,9 +190,9 @@ public void ReadFrom_InvalidBelowPhreaticLevelDistributionValue_ThrowsPipingSoilProfileReadException() { // Setup - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.ProfileName)).Return(""); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.BelowPhreaticLevelDistribution)).Return(1); + reader.Expect(r => r.Read(SoilProfileTableColumns.LayerCount)).Return(1); + reader.Expect(r => r.Read(SoilProfileTableColumns.ProfileName)).Return(""); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.BelowPhreaticLevelDistribution)).Return(1); mocks.ReplayAll(); // Call @@ -210,9 +211,9 @@ public void ReadFrom_InvalidDiameterD70DistributionValue_ThrowsPipingSoilProfileReadException() { // Setup - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.ProfileName)).Return(""); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.DiameterD70Distribution)).Return(1); + reader.Expect(r => r.Read(SoilProfileTableColumns.LayerCount)).Return(1); + reader.Expect(r => r.Read(SoilProfileTableColumns.ProfileName)).Return(""); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.DiameterD70Distribution)).Return(1); mocks.ReplayAll(); // Call @@ -231,10 +232,10 @@ public void ReadFrom_InvalidDiameterD70ShiftValue_ThrowsPipingSoilProfileReadException() { // Setup - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.ProfileName)).Return(""); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.DiameterD70Distribution)).Return(SoilLayerConstants.LogNormalDistributionValue); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.DiameterD70Shift)).Return(1); + reader.Expect(r => r.Read(SoilProfileTableColumns.LayerCount)).Return(1); + reader.Expect(r => r.Read(SoilProfileTableColumns.ProfileName)).Return(""); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.DiameterD70Distribution)).Return(SoilLayerConstants.LogNormalDistributionValue); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.DiameterD70Shift)).Return(1); mocks.ReplayAll(); // Call @@ -253,9 +254,9 @@ public void ReadFrom_InvalidPermeabilityDistributionValue_ThrowsPipingSoilProfileReadException() { // Setup - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.ProfileName)).Return(""); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.PermeabilityDistribution)).Return(1); + reader.Expect(r => r.Read(SoilProfileTableColumns.LayerCount)).Return(1); + reader.Expect(r => r.Read(SoilProfileTableColumns.ProfileName)).Return(""); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.PermeabilityDistribution)).Return(1); mocks.ReplayAll(); // Call @@ -274,10 +275,10 @@ public void ReadFrom_InvalidPermeabilityShiftValue_ThrowsPipingSoilProfileReadException() { // Setup - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.ProfileName)).Return(""); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.PermeabilityDistribution)).Return(SoilLayerConstants.LogNormalDistributionValue); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.PermeabilityShift)).Return(1); + reader.Expect(r => r.Read(SoilProfileTableColumns.LayerCount)).Return(1); + reader.Expect(r => r.Read(SoilProfileTableColumns.ProfileName)).Return(""); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.PermeabilityDistribution)).Return(SoilLayerConstants.LogNormalDistributionValue); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.PermeabilityShift)).Return(1); mocks.ReplayAll(); // Call @@ -355,28 +356,28 @@ private void SetExpectations(int layerCount, string profileName, double bottom, double top, double? isAquifer, string materialName, double? color, double? belowPhreaticLevelMean, double? belowPhreaticLevelDeviation, double? diameterD70Mean, double? diameterD70Deviation, double? permeabilityMean, double? permeabilityDeviation) { - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(layerCount).Repeat.Any(); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.ProfileName)).Return(profileName).Repeat.Any(); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.Bottom)).Return(bottom).Repeat.Any(); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.Top)).Return(top).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.IsAquifer)).Return(isAquifer).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.MaterialName)).Return(materialName).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.Color)).Return(color).Repeat.Any(); + reader.Expect(r => r.Read(SoilProfileTableColumns.LayerCount)).Return(layerCount).Repeat.Any(); + reader.Expect(r => r.Read(SoilProfileTableColumns.ProfileName)).Return(profileName).Repeat.Any(); + reader.Expect(r => r.Read(SoilProfileTableColumns.Bottom)).Return(bottom).Repeat.Any(); + reader.Expect(r => r.Read(SoilProfileTableColumns.Top)).Return(top).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.IsAquifer)).Return(isAquifer).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.MaterialName)).Return(materialName).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.Color)).Return(color).Repeat.Any(); var logNormalDistribution = 3; var logNormalShift = 0; - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.BelowPhreaticLevelDistribution)).Return(logNormalDistribution).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.BelowPhreaticLevelShift)).Return(logNormalShift).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.BelowPhreaticLevelMean)).Return(belowPhreaticLevelMean).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.BelowPhreaticLevelDeviation)).Return(belowPhreaticLevelDeviation).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.DiameterD70Distribution)).Return(logNormalDistribution).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.DiameterD70Shift)).Return(logNormalShift).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.DiameterD70Mean)).Return(diameterD70Mean).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.DiameterD70Deviation)).Return(diameterD70Deviation).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.PermeabilityDistribution)).Return(logNormalDistribution).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.PermeabilityShift)).Return(logNormalShift).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.PermeabilityMean)).Return(permeabilityMean).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.PermeabilityDeviation)).Return(permeabilityDeviation).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.BelowPhreaticLevelDistribution)).Return(logNormalDistribution).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.BelowPhreaticLevelShift)).Return(logNormalShift).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.BelowPhreaticLevelMean)).Return(belowPhreaticLevelMean).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.BelowPhreaticLevelDeviation)).Return(belowPhreaticLevelDeviation).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.DiameterD70Distribution)).Return(logNormalDistribution).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.DiameterD70Shift)).Return(logNormalShift).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.DiameterD70Mean)).Return(diameterD70Mean).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.DiameterD70Deviation)).Return(diameterD70Deviation).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.PermeabilityDistribution)).Return(logNormalDistribution).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.PermeabilityShift)).Return(logNormalShift).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.PermeabilityMean)).Return(permeabilityMean).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.PermeabilityDeviation)).Return(permeabilityDeviation).Repeat.Any(); } } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile2DReaderTest.cs =================================================================== diff -u -r2aa9661130f20e88c41dac921ffb780573dcf799 -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile2DReaderTest.cs (.../SoilProfile2DReaderTest.cs) (revision 2aa9661130f20e88c41dac921ffb780573dcf799) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile2DReaderTest.cs (.../SoilProfile2DReaderTest.cs) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -30,6 +30,7 @@ using Ringtoets.Piping.IO.Builders; using Ringtoets.Piping.IO.Exceptions; using Ringtoets.Piping.IO.SoilProfile; +using Ringtoets.Piping.IO.SoilProfile.Schema; using Ringtoets.Piping.IO.Test.TestHelpers; using Ringtoets.Piping.Primitives; @@ -66,8 +67,8 @@ const string name = "B"; reader.Expect(r => r.Path).Return(path); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.ProfileName)).Return(name); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Throw(new InvalidCastException()); + reader.Expect(r => r.Read(SoilProfileTableColumns.ProfileName)).Return(name); + reader.Expect(r => r.Read(SoilProfileTableColumns.LayerCount)).Throw(new InvalidCastException()); mocks.ReplayAll(); @@ -90,9 +91,9 @@ const string path = "B"; reader.Expect(r => r.Path).Return(path); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1).Repeat.Any(); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.ProfileName)).Return(name).Repeat.Any(); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.IntersectionX)).Throw(new InvalidCastException()); + reader.Expect(r => r.Read(SoilProfileTableColumns.LayerCount)).Return(1).Repeat.Any(); + reader.Expect(r => r.Read(SoilProfileTableColumns.ProfileName)).Return(name).Repeat.Any(); + reader.Expect(r => r.Read(SoilProfileTableColumns.IntersectionX)).Throw(new InvalidCastException()); mocks.ReplayAll(); @@ -115,9 +116,9 @@ const string path = "A"; reader.Expect(r => r.Path).Return(path); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1).Repeat.Any(); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.ProfileName)).Return(name).Repeat.Any(); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.IntersectionX)).Return(double.NaN); + reader.Expect(r => r.Read(SoilProfileTableColumns.LayerCount)).Return(1).Repeat.Any(); + reader.Expect(r => r.Read(SoilProfileTableColumns.ProfileName)).Return(name).Repeat.Any(); + reader.Expect(r => r.Read(SoilProfileTableColumns.IntersectionX)).Return(double.NaN); mocks.ReplayAll(); @@ -209,9 +210,9 @@ const string path = "A"; reader.Expect(r => r.Path).Return(path); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.ProfileName)).Return(name); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.IsAquifer)).Throw(new InvalidCastException()); + reader.Expect(r => r.Read(SoilProfileTableColumns.ProfileName)).Return(name); + reader.Expect(r => r.Read(SoilProfileTableColumns.LayerCount)).Return(1).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.IsAquifer)).Throw(new InvalidCastException()); mocks.ReplayAll(); // Call @@ -321,11 +322,11 @@ public void ReadFrom_InvalidBelowPhreaticLevelDistributionValue_ThrowsPipingSoilProfileReadException() { // Setup - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.ProfileName)).Return(""); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.IntersectionX)).Return(0.0).Repeat.Any(); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerGeometry)).Return(someGeometry).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.BelowPhreaticLevelDistribution)).Return(1); + reader.Expect(r => r.Read(SoilProfileTableColumns.LayerCount)).Return(1); + reader.Expect(r => r.Read(SoilProfileTableColumns.ProfileName)).Return(""); + reader.Expect(r => r.Read(SoilProfileTableColumns.IntersectionX)).Return(0.0).Repeat.Any(); + reader.Expect(r => r.Read(SoilProfileTableColumns.LayerGeometry)).Return(someGeometry).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.BelowPhreaticLevelDistribution)).Return(1); mocks.ReplayAll(); // Call @@ -344,11 +345,11 @@ public void ReadFrom_InvalidDiameterD70DistributionValue_ThrowsPipingSoilProfileReadException() { // Setup - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.ProfileName)).Return(""); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.IntersectionX)).Return(0.0).Repeat.Any(); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerGeometry)).Return(someGeometry).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.DiameterD70Distribution)).Return(1); + reader.Expect(r => r.Read(SoilProfileTableColumns.LayerCount)).Return(1); + reader.Expect(r => r.Read(SoilProfileTableColumns.ProfileName)).Return(""); + reader.Expect(r => r.Read(SoilProfileTableColumns.IntersectionX)).Return(0.0).Repeat.Any(); + reader.Expect(r => r.Read(SoilProfileTableColumns.LayerGeometry)).Return(someGeometry).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.DiameterD70Distribution)).Return(1); mocks.ReplayAll(); // Call @@ -367,12 +368,12 @@ public void ReadFrom_InvalidDiameterD70ShiftValue_ThrowsPipingSoilProfileReadException() { // Setup - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.ProfileName)).Return(""); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.IntersectionX)).Return(0.0).Repeat.Any(); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerGeometry)).Return(someGeometry).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.DiameterD70Distribution)).Return(SoilLayerConstants.LogNormalDistributionValue); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.DiameterD70Shift)).Return(1); + reader.Expect(r => r.Read(SoilProfileTableColumns.LayerCount)).Return(1); + reader.Expect(r => r.Read(SoilProfileTableColumns.ProfileName)).Return(""); + reader.Expect(r => r.Read(SoilProfileTableColumns.IntersectionX)).Return(0.0).Repeat.Any(); + reader.Expect(r => r.Read(SoilProfileTableColumns.LayerGeometry)).Return(someGeometry).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.DiameterD70Distribution)).Return(SoilLayerConstants.LogNormalDistributionValue); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.DiameterD70Shift)).Return(1); mocks.ReplayAll(); // Call @@ -391,11 +392,11 @@ public void ReadFrom_InvalidPermeabilityDistributionValue_ThrowsPipingSoilProfileReadException() { // Setup - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.ProfileName)).Return(""); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.IntersectionX)).Return(0.0).Repeat.Any(); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerGeometry)).Return(someGeometry).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.PermeabilityDistribution)).Return(1); + reader.Expect(r => r.Read(SoilProfileTableColumns.LayerCount)).Return(1); + reader.Expect(r => r.Read(SoilProfileTableColumns.ProfileName)).Return(""); + reader.Expect(r => r.Read(SoilProfileTableColumns.IntersectionX)).Return(0.0).Repeat.Any(); + reader.Expect(r => r.Read(SoilProfileTableColumns.LayerGeometry)).Return(someGeometry).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.PermeabilityDistribution)).Return(1); mocks.ReplayAll(); // Call @@ -414,12 +415,12 @@ public void ReadFrom_InvalidPermeabilityShiftValue_ThrowsPipingSoilProfileReadException() { // Setup - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.ProfileName)).Return(""); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.IntersectionX)).Return(0.0).Repeat.Any(); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerGeometry)).Return(someGeometry).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.PermeabilityDistribution)).Return(SoilLayerConstants.LogNormalDistributionValue); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.PermeabilityShift)).Return(1); + reader.Expect(r => r.Read(SoilProfileTableColumns.LayerCount)).Return(1); + reader.Expect(r => r.Read(SoilProfileTableColumns.ProfileName)).Return(""); + reader.Expect(r => r.Read(SoilProfileTableColumns.IntersectionX)).Return(0.0).Repeat.Any(); + reader.Expect(r => r.Read(SoilProfileTableColumns.LayerGeometry)).Return(someGeometry).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.PermeabilityDistribution)).Return(SoilLayerConstants.LogNormalDistributionValue); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.PermeabilityShift)).Return(1); mocks.ReplayAll(); // Call @@ -436,28 +437,28 @@ 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(); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.ProfileName)).Return(profileName).Repeat.Any(); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.IntersectionX)).Return(intersectionX).Repeat.Any(); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerGeometry)).Return(geometry).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.IsAquifer)).Return(isAquifer).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.MaterialName)).Return(materialName).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.Color)).Return(color).Repeat.Any(); + reader.Expect(r => r.Read(SoilProfileTableColumns.LayerCount)).Return(layerCount).Repeat.Any(); + reader.Expect(r => r.Read(SoilProfileTableColumns.ProfileName)).Return(profileName).Repeat.Any(); + reader.Expect(r => r.Read(SoilProfileTableColumns.IntersectionX)).Return(intersectionX).Repeat.Any(); + reader.Expect(r => r.Read(SoilProfileTableColumns.LayerGeometry)).Return(geometry).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.IsAquifer)).Return(isAquifer).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.MaterialName)).Return(materialName).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.Color)).Return(color).Repeat.Any(); var logNormalDistribution = 3; var logNormalShift = 0; - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.BelowPhreaticLevelDistribution)).Return(logNormalDistribution).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.BelowPhreaticLevelShift)).Return(logNormalShift).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.BelowPhreaticLevelMean)).Return(belowPhreaticLevelMean).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.BelowPhreaticLevelDeviation)).Return(belowPhreaticLevelDeviation).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.DiameterD70Distribution)).Return(logNormalDistribution).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.DiameterD70Shift)).Return(logNormalShift).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.DiameterD70Mean)).Return(diameterD70Mean).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.DiameterD70Deviation)).Return(diameterD70Deviation).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.PermeabilityDistribution)).Return(logNormalDistribution).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.PermeabilityShift)).Return(logNormalShift).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.PermeabilityMean)).Return(permeabilityMean).Repeat.Any(); - reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.PermeabilityDeviation)).Return(permeabilityDeviation).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.BelowPhreaticLevelDistribution)).Return(logNormalDistribution).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.BelowPhreaticLevelShift)).Return(logNormalShift).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.BelowPhreaticLevelMean)).Return(belowPhreaticLevelMean).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.BelowPhreaticLevelDeviation)).Return(belowPhreaticLevelDeviation).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.DiameterD70Distribution)).Return(logNormalDistribution).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.DiameterD70Shift)).Return(logNormalShift).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.DiameterD70Mean)).Return(diameterD70Mean).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.DiameterD70Deviation)).Return(diameterD70Deviation).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.PermeabilityDistribution)).Return(logNormalDistribution).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.PermeabilityShift)).Return(logNormalShift).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.PermeabilityMean)).Return(permeabilityMean).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileTableColumns.PermeabilityDeviation)).Return(permeabilityDeviation).Repeat.Any(); } private static string GetExpectedSoilProfileReaderErrorMessage(string path, string name, string errorMessage) Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/StochasticSoilModelReaderTest.cs =================================================================== diff -u -r2aa9661130f20e88c41dac921ffb780573dcf799 -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/StochasticSoilModelReaderTest.cs (.../StochasticSoilModelReaderTest.cs) (revision 2aa9661130f20e88c41dac921ffb780573dcf799) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/StochasticSoilModelReaderTest.cs (.../StochasticSoilModelReaderTest.cs) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -73,7 +73,7 @@ [Test] [TestCase("text.txt")] [TestCase("empty.soil")] - public void Constructor_IncorrectFormatFileOrInvalidSchema_ThrowsPipingCriticalFileReadException(string dbName) + public void Constructor_IncorrectFormatFileOrInvalidSchema_ThrowsCriticalFileReadException(string dbName) { // Setup string dbFile = Path.Combine(testDataPath, dbName); @@ -94,12 +94,12 @@ [Test] [TestCase("withoutSoilModelTables.soil")] - public void Constructor_InvalidSchemaThatPassesValidation_ThrowsPipingCriticalFileReadException(string dbName) + public void Constructor_InvalidSchemaThatPassesValidation_ThrowsCriticalFileReadException(string dbName) { // Setup string dbFile = Path.Combine(testDataPath, dbName); string expectedMessage = new FileReaderErrorMessageBuilder(dbFile). - Build(string.Format(Resources.StochasticSoilModelDatabaseReader_Failed_to_read_database, dbName)); + Build("Kan geen ondergrondmodellen lezen. Mogelijk bestaat de 'Segment' tabel niet."); // Precondition Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile), "Precondition: file can be opened for edits."); @@ -114,6 +114,27 @@ } [Test] + [TestCase("nonUniqueSoilModelNames.soil")] + public void Constructor_NonUniqueSoilModelNames_ThrowsCriticalFileReadException(string dbName) + { + // Setup + string dbFile = Path.Combine(testDataPath, dbName); + string expectedMessage = new FileReaderErrorMessageBuilder(dbFile). + Build("Namen van ondergrondmodellen zijn niet uniek."); + + // Precondition + Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile), "Precondition: file can be opened for edits."); + + // Call + TestDelegate test = () => { using (new StochasticSoilModelReader(dbFile)) {} }; + + // Assert + CriticalFileReadException exception = Assert.Throws(test); + Assert.AreEqual(expectedMessage, exception.Message); + Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile)); + } + + [Test] public void ParameteredConstructor_PathToExistingFile_ExpectedValues() { // Setup Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/StochasticSoilModelDatabaseReader/nonUniqueSoilModelNames.soil =================================================================== diff -u Binary files differ Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.TestUtil/TestStochasticSoilModelUpdateModelStrategy.cs =================================================================== diff -u -r8c8285c58f677a2905127f1c3576eb7d6ea4206b -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Ringtoets/Piping/test/Ringtoets.Piping.IO.TestUtil/TestStochasticSoilModelUpdateModelStrategy.cs (.../TestStochasticSoilModelUpdateModelStrategy.cs) (revision 8c8285c58f677a2905127f1c3576eb7d6ea4206b) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.TestUtil/TestStochasticSoilModelUpdateModelStrategy.cs (.../TestStochasticSoilModelUpdateModelStrategy.cs) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -19,7 +19,6 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -using System; using System.Collections.Generic; using System.Linq; using Core.Common.Base; @@ -35,7 +34,7 @@ public string FilePath { get; private set; } public IEnumerable UpdatedInstances { get; set; } = Enumerable.Empty(); - public IEnumerable UpdateModelWithImportedData(ObservableCollectionWithSourcePath targetCollection, + public IEnumerable UpdateModelWithImportedData(StochasticSoilModelCollection targetCollection, IEnumerable readStochasticSoilModels, string sourceFilePath) { Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelReplaceDataStrategyTest.cs =================================================================== diff -u -re010a3bcc0afc7dacd2e358604a96edabb9a1ed0 -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelReplaceDataStrategyTest.cs (.../StochasticSoilModelReplaceDataStrategyTest.cs) (revision e010a3bcc0afc7dacd2e358604a96edabb9a1ed0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelReplaceDataStrategyTest.cs (.../StochasticSoilModelReplaceDataStrategyTest.cs) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -27,9 +27,7 @@ using Ringtoets.Piping.Data; using Ringtoets.Piping.Data.TestUtil; using Ringtoets.Piping.IO.Importers; -using Ringtoets.Piping.KernelWrapper.TestUtil; using Ringtoets.Piping.Plugin.FileImporter; -using Ringtoets.Piping.Primitives; namespace Ringtoets.Piping.Plugin.Test.FileImporter { @@ -66,7 +64,7 @@ var strategy = new StochasticSoilModelReplaceDataStrategy(new PipingFailureMechanism()); // Call - TestDelegate test = () => strategy.UpdateModelWithImportedData(new ObservableCollectionWithSourcePath(), null, string.Empty); + TestDelegate test = () => strategy.UpdateModelWithImportedData(new StochasticSoilModelCollection(), null, string.Empty); // Assert string paramName = Assert.Throws(test).ParamName; @@ -80,7 +78,7 @@ var strategy = new StochasticSoilModelReplaceDataStrategy(new PipingFailureMechanism()); // Call - TestDelegate test = () => strategy.UpdateModelWithImportedData(new ObservableCollectionWithSourcePath(), new List(), null); + TestDelegate test = () => strategy.UpdateModelWithImportedData(new StochasticSoilModelCollection(), new List(), null); // Assert string paramName = Assert.Throws(test).ParamName; @@ -111,7 +109,7 @@ new TestStochasticSoilModel("B") }; var strategy = new StochasticSoilModelReplaceDataStrategy(new PipingFailureMechanism()); - var targetCollection = new ObservableCollectionWithSourcePath(); + var targetCollection = new StochasticSoilModelCollection(); // Call IEnumerable affectedObjects = strategy.UpdateModelWithImportedData(targetCollection, importedStochasticSoilModels, "path"); @@ -131,8 +129,8 @@ var failureMechanism = new PipingFailureMechanism(); failureMechanism.StochasticSoilModels.AddRange(new[] { - new TestStochasticSoilModel(), - new TestStochasticSoilModel() + new TestStochasticSoilModel("A"), + new TestStochasticSoilModel("B") }, sourceFilePath); var strategy = new StochasticSoilModelReplaceDataStrategy(failureMechanism); @@ -193,7 +191,7 @@ var strategy = new StochasticSoilModelReplaceDataStrategy(failureMechanism); - var targetCollection = new ObservableCollectionWithSourcePath(); + var targetCollection = new StochasticSoilModelCollection(); targetCollection.AddRange(new[] { existingModel, @@ -209,5 +207,26 @@ CollectionAssert.Contains(affectedObjects, calculation); CollectionAssert.Contains(affectedObjects, calculation.InputParameters); } + + [Test] + public void UpdateModelWithImportedData_ImportedModelsContainDuplicateNames_ThrowsUpdateException() + { + // Setup + var importedStochasticSoilModels = new[] + { + new TestStochasticSoilModel("B"), + new TestStochasticSoilModel("B") + }; + var strategy = new StochasticSoilModelReplaceDataStrategy(new PipingFailureMechanism()); + var targetCollection = new StochasticSoilModelCollection(); + + // Call + TestDelegate test = () => strategy.UpdateModelWithImportedData(targetCollection, importedStochasticSoilModels, "path"); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("Ondergrondmodellen moeten een unieke naam hebben. Gevonden dubbele namen: B.", exception.Message); + Assert.IsInstanceOf(exception.InnerException); + } } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelUpdateDataStrategyTest.cs =================================================================== diff -u -r0122d4ac58ee6f7be4ff804db1f6c65e88ce4562 -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelUpdateDataStrategyTest.cs (.../StochasticSoilModelUpdateDataStrategyTest.cs) (revision 0122d4ac58ee6f7be4ff804db1f6c65e88ce4562) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelUpdateDataStrategyTest.cs (.../StochasticSoilModelUpdateDataStrategyTest.cs) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -66,7 +66,7 @@ var strategy = new StochasticSoilModelUpdateDataStrategy(new PipingFailureMechanism()); // Call - TestDelegate test = () => strategy.UpdateModelWithImportedData(new ObservableCollectionWithSourcePath(), null, string.Empty); + TestDelegate test = () => strategy.UpdateModelWithImportedData(new StochasticSoilModelCollection(), null, string.Empty); // Assert string paramName = Assert.Throws(test).ParamName; @@ -80,7 +80,7 @@ var strategy = new StochasticSoilModelUpdateDataStrategy(new PipingFailureMechanism()); // Call - TestDelegate test = () => strategy.UpdateModelWithImportedData(new ObservableCollectionWithSourcePath(), new List(), null); + TestDelegate test = () => strategy.UpdateModelWithImportedData(new StochasticSoilModelCollection(), new List(), null); // Assert string paramName = Assert.Throws(test).ParamName; @@ -107,7 +107,7 @@ // Setup const string nonUniqueName = "non-unique name"; - var targetCollection = new ObservableCollectionWithSourcePath(); + var targetCollection = new StochasticSoilModelCollection(); targetCollection.AddRange(new[] { new TestStochasticSoilModel(nonUniqueName) @@ -130,6 +130,30 @@ } [Test] + public void UpdateModelWithImportedData_WithoutCurrentModelsAndImportedMultipleModelsWithSameName_ThrowsStochasticSoilModelUpdateException() + { + // Setup + const string nonUniqueName = "non-unique name"; + + var targetCollection = new StochasticSoilModelCollection(); + + var strategy = new StochasticSoilModelUpdateDataStrategy(new PipingFailureMechanism()); + var importedStochasticSoilModels = new[] + { + new TestStochasticSoilModel(nonUniqueName), + new TestStochasticSoilModel(nonUniqueName) + }; + + // Call + TestDelegate test = () => strategy.UpdateModelWithImportedData(targetCollection, importedStochasticSoilModels, sourceFilePath); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("Ondergrondmodellen moeten een unieke naam hebben. Gevonden dubbele namen: non-unique name.", exception.Message); + Assert.IsInstanceOf(exception.InnerException); + } + + [Test] public void UpdateModelWithImportedData_WithoutCurrentModelAndModelsImported_NewModelsAdded() { // Setup @@ -139,7 +163,7 @@ new TestStochasticSoilModel("B") }; var strategy = new StochasticSoilModelUpdateDataStrategy(new PipingFailureMechanism()); - var targetCollection = new ObservableCollectionWithSourcePath(); + var targetCollection = new StochasticSoilModelCollection(); // Call IEnumerable affectedObjects = strategy.UpdateModelWithImportedData(targetCollection, importedStochasticSoilModels, "path"); @@ -156,11 +180,11 @@ public void UpdateModelWithImportedData_WithCurrentModelsAndImportedDataEmpty_ModelsRemoved() { // Setup - var targetCollection = new ObservableCollectionWithSourcePath(); + var targetCollection = new StochasticSoilModelCollection(); targetCollection.AddRange(new[] { - new TestStochasticSoilModel(), - new TestStochasticSoilModel() + new TestStochasticSoilModel("A"), + new TestStochasticSoilModel("B") }, sourceFilePath); var strategy = new StochasticSoilModelUpdateDataStrategy(new PipingFailureMechanism()); @@ -213,7 +237,7 @@ var modelsName = "same model"; var existingModel = new TestStochasticSoilModel(modelsName); - var targetCollection = new ObservableCollectionWithSourcePath(); + var targetCollection = new StochasticSoilModelCollection(); targetCollection.AddRange(new[] { existingModel, @@ -244,7 +268,7 @@ var modelsName = "same model"; var existingModel = new TestStochasticSoilModel(modelsName); - var targetCollection = new ObservableCollectionWithSourcePath(); + var targetCollection = new StochasticSoilModelCollection(); targetCollection.AddRange(new[] { existingModel, @@ -276,7 +300,7 @@ var modelsName = "same model"; var existingModel = new TestStochasticSoilModel(modelsName); - var targetCollection = new ObservableCollectionWithSourcePath(); + var targetCollection = new StochasticSoilModelCollection(); targetCollection.AddRange(new[] { existingModel, @@ -330,7 +354,7 @@ var modelsName = "same model"; var existingModel = new TestStochasticSoilModel(modelsName); - var targetCollection = new ObservableCollectionWithSourcePath(); + var targetCollection = new StochasticSoilModelCollection(); targetCollection.AddRange(new[] { existingModel, @@ -398,7 +422,7 @@ var strategy = new StochasticSoilModelUpdateDataStrategy(failureMechanism); - var targetCollection = new ObservableCollectionWithSourcePath(); + var targetCollection = new StochasticSoilModelCollection(); targetCollection.AddRange(new[] { existingModel, Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/PropertyInfos/StochasticSoilModelCollectionContextPropertyInfoTest.cs =================================================================== diff -u -r4eba092cb591f9f164f1e22f5b2bba25b148dda5 -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/PropertyInfos/StochasticSoilModelCollectionContextPropertyInfoTest.cs (.../StochasticSoilModelCollectionContextPropertyInfoTest.cs) (revision 4eba092cb591f9f164f1e22f5b2bba25b148dda5) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/PropertyInfos/StochasticSoilModelCollectionContextPropertyInfoTest.cs (.../StochasticSoilModelCollectionContextPropertyInfoTest.cs) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -68,7 +68,7 @@ var failureMechanism = new PipingFailureMechanism(); - var collection = new ObservableCollectionWithSourcePath(); + var collection = new StochasticSoilModelCollection(); var context = new StochasticSoilModelCollectionContext(collection, failureMechanism, assessmentSection); // Call Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/StochasticSoilModelCollectionContextTreeNodeInfoTest.cs =================================================================== diff -u -r45440093089496f59ed420e772136756c229e30b -re1a8e98d60853beefbdb8c84e70f14165680ad7b --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/StochasticSoilModelCollectionContextTreeNodeInfoTest.cs (.../StochasticSoilModelCollectionContextTreeNodeInfoTest.cs) (revision 45440093089496f59ed420e772136756c229e30b) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/StochasticSoilModelCollectionContextTreeNodeInfoTest.cs (.../StochasticSoilModelCollectionContextTreeNodeInfoTest.cs) (revision e1a8e98d60853beefbdb8c84e70f14165680ad7b) @@ -260,7 +260,7 @@ using (var treeViewControl = new TreeViewControl()) { var context = new StochasticSoilModelCollectionContext( - new ObservableCollectionWithSourcePath(), + new StochasticSoilModelCollection(), new PipingFailureMechanism(), assessmentSection); var gui = mocks.Stub();