Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/IStochasticSoilModelUpdateModelStrategy.cs
===================================================================
diff -u -r8c8285c58f677a2905127f1c3576eb7d6ea4206b -r0122d4ac58ee6f7be4ff804db1f6c65e88ce4562
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/IStochasticSoilModelUpdateModelStrategy.cs (.../IStochasticSoilModelUpdateModelStrategy.cs) (revision 8c8285c58f677a2905127f1c3576eb7d6ea4206b)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/IStochasticSoilModelUpdateModelStrategy.cs (.../IStochasticSoilModelUpdateModelStrategy.cs) (revision 0122d4ac58ee6f7be4ff804db1f6c65e88ce4562)
@@ -40,10 +40,10 @@
/// The stochastic soil models which were imported.
/// The path to the source file from which the soil models were imported.
/// Thrown when any parameter is null.
- /// Thrown when applying the strategy failed.
- /// is set with the more detailed
+ /// Thrown when applying the strategy failed.
+ /// is set with the more detailed
/// exception.
- /// of updated instances.
+ /// A of updated instances.
IEnumerable UpdateModelWithImportedData(
ObservableCollectionWithSourcePath targetCollection,
IEnumerable readStochasticSoilModels,
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/ISurfaceLineUpdateSurfaceLineStrategy.cs
===================================================================
diff -u -r8c8285c58f677a2905127f1c3576eb7d6ea4206b -r0122d4ac58ee6f7be4ff804db1f6c65e88ce4562
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/ISurfaceLineUpdateSurfaceLineStrategy.cs (.../ISurfaceLineUpdateSurfaceLineStrategy.cs) (revision 8c8285c58f677a2905127f1c3576eb7d6ea4206b)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/ISurfaceLineUpdateSurfaceLineStrategy.cs (.../ISurfaceLineUpdateSurfaceLineStrategy.cs) (revision 0122d4ac58ee6f7be4ff804db1f6c65e88ce4562)
@@ -40,7 +40,10 @@
/// The imported surface lines.
/// The source path from where the surface lines were imported from.
/// An of updated instances.
- /// Thrown when any of the input parameters is null
+ /// Thrown when any of the input parameters is null.
+ /// Thrown when applying the strategy has failed. The
+ /// is set with a more detailed explanation
+ /// of why the exception occurs.
IEnumerable UpdateSurfaceLinesWithImportedData(
ObservableCollectionWithSourcePath targetCollection,
IEnumerable readRingtoetsPipingSurfaceLines,
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/RingtoetsPipingSurfaceLineUpdateException.cs
===================================================================
diff -u
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/RingtoetsPipingSurfaceLineUpdateException.cs (revision 0)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/RingtoetsPipingSurfaceLineUpdateException.cs (revision 0122d4ac58ee6f7be4ff804db1f6c65e88ce4562)
@@ -0,0 +1,57 @@
+// 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.Runtime.Serialization;
+
+namespace Ringtoets.Piping.IO.Importers
+{
+ ///
+ /// Exception that is thrown when applying the surface line update strategy has failed.
+ ///
+ [Serializable]
+ public class RingtoetsPipingSurfaceLineUpdateException : Exception
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public RingtoetsPipingSurfaceLineUpdateException() {}
+
+ ///
+ /// Initializes a new instance of the class
+ /// with a specified error message.
+ ///
+ /// The error message that explains the reason for the exception.
+ public RingtoetsPipingSurfaceLineUpdateException(string message) : base(message) {}
+
+ ///
+ /// Initializes a new instance of the class
+ /// with a specified error message and a reference to the inner exception that is
+ /// the cause of this exception.
+ ///
+ /// The error message that explains the reason for the exception.
+ /// The exception that is the cause of the current exception,
+ /// or a null reference if no inner exception is specified.
+ public RingtoetsPipingSurfaceLineUpdateException(string message, Exception inner) : base(message, inner) {}
+
+ protected RingtoetsPipingSurfaceLineUpdateException(SerializationInfo info, StreamingContext context) : base(info, context) {}
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj
===================================================================
diff -u -r3793f0710b624c5e9896dd9e8ec91232e5584b23 -r0122d4ac58ee6f7be4ff804db1f6c65e88ce4562
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj (.../Ringtoets.Piping.IO.csproj) (revision 3793f0710b624c5e9896dd9e8ec91232e5584b23)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj (.../Ringtoets.Piping.IO.csproj) (revision 0122d4ac58ee6f7be4ff804db1f6c65e88ce4562)
@@ -56,6 +56,7 @@
+
Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/RingtoetsPipingSurfaceLineUpdateStrategy.cs
===================================================================
diff -u -r85e72b5765dd231d4d4a4ea6c51431d169a0fb72 -r0122d4ac58ee6f7be4ff804db1f6c65e88ce4562
--- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/RingtoetsPipingSurfaceLineUpdateStrategy.cs (.../RingtoetsPipingSurfaceLineUpdateStrategy.cs) (revision 85e72b5765dd231d4d4a4ea6c51431d169a0fb72)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/RingtoetsPipingSurfaceLineUpdateStrategy.cs (.../RingtoetsPipingSurfaceLineUpdateStrategy.cs) (revision 0122d4ac58ee6f7be4ff804db1f6c65e88ce4562)
@@ -26,6 +26,7 @@
using Core.Common.Utils;
using Ringtoets.Piping.Data;
using Ringtoets.Piping.IO.Importers;
+using Ringtoets.Piping.Plugin.Properties;
using Ringtoets.Piping.Primitives;
using Ringtoets.Piping.Service;
@@ -39,7 +40,7 @@
///
public class RingtoetsPipingSurfaceLineUpdateDataStrategy : ISurfaceLineUpdateSurfaceLineStrategy
{
- private PipingFailureMechanism failureMechanism;
+ private readonly PipingFailureMechanism failureMechanism;
///
/// Creates a new instance of .
@@ -72,7 +73,15 @@
throw new ArgumentNullException(nameof(sourceFilePath));
}
- return ModifySurfaceLineCollection(targetCollection, readRingtoetsPipingSurfaceLines, sourceFilePath);
+ try
+ {
+ return ModifySurfaceLineCollection(targetCollection, readRingtoetsPipingSurfaceLines, sourceFilePath);
+ }
+ catch (InvalidOperationException e)
+ {
+ var message = Resources.RingtoetsPipingSurfaceLineUpdateDataStrategy_UpdateSurfaceLinesWithImportedData_Update_of_RingtoetsPipingSurfaceLine_has_failed;
+ throw new RingtoetsPipingSurfaceLineUpdateException(message, e);
+ }
}
private IEnumerable ModifySurfaceLineCollection(ObservableCollectionWithSourcePath existingCollection,
@@ -89,6 +98,7 @@
{
affectedObjects.Add(existingCollection);
}
+ affectedObjects.AddRange(UpdateSurfaceLines(updatedSurfaceLines, readSurfaceLineList));
affectedObjects.AddRange(RemoveSurfaceLines(removedSurfaceLines));
existingCollection.Clear();
@@ -135,8 +145,27 @@
#endregion
+ #region Updating surface line helpers
+
+ private IEnumerable UpdateSurfaceLines(IEnumerable updatedSurfaceLines,
+ IList readSurfaceLines)
+ {
+ var affectedObjects = new List();
+
+ foreach (RingtoetsPipingSurfaceLine updatedSurfaceLine in updatedSurfaceLines)
+ {
+ RingtoetsPipingSurfaceLine matchingSurfaceLine = readSurfaceLines.Single(sl => sl.Name == updatedSurfaceLine.Name);
+ updatedSurfaceLine.Update(matchingSurfaceLine);
+ affectedObjects.Add(updatedSurfaceLine);
+ }
+
+ return affectedObjects;
+ }
+
+ #endregion
+
///
- /// Class fpr comparing by only the name.
+ /// Class for comparing by only the name.
///
private class RingtoetsPipingSurfaceLineNameEqualityComparer : IEqualityComparer
{
Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.Designer.cs
===================================================================
diff -u -r6ad658313ed97085f5a2653f9e769b77f3b94d80 -r0122d4ac58ee6f7be4ff804db1f6c65e88ce4562
--- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 6ad658313ed97085f5a2653f9e769b77f3b94d80)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 0122d4ac58ee6f7be4ff804db1f6c65e88ce4562)
@@ -364,6 +364,16 @@
}
///
+ /// Looks up a localized string similar to Het bijwerken van de profielschematisaties is mislukt..
+ ///
+ public static string RingtoetsPipingSurfaceLineUpdateDataStrategy_UpdateSurfaceLinesWithImportedData_Update_of_RingtoetsPipingSurfaceLine_has_failed {
+ get {
+ return ResourceManager.GetString("RingtoetsPipingSurfaceLineUpdateDataStrategy_UpdateSurfaceLinesWithImportedData_U" +
+ "pdate_of_RingtoetsPipingSurfaceLine_has_failed", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to D-Soil Model bestand.
///
public static string Soil_file_name {
Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.resx
===================================================================
diff -u -r6ad658313ed97085f5a2653f9e769b77f3b94d80 -r0122d4ac58ee6f7be4ff804db1f6c65e88ce4562
--- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.resx (.../Resources.resx) (revision 6ad658313ed97085f5a2653f9e769b77f3b94d80)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.resx (.../Resources.resx) (revision 0122d4ac58ee6f7be4ff804db1f6c65e88ce4562)
@@ -219,4 +219,7 @@
Wanneer ondergrondschematisaties wijzigen als gevolg van het bijwerken, zullen de resultaten van berekeningen die deze ondergrondschematisaties worden verwijderd. Weet u zeker dat u wilt doorgaan?
+
+ Het bijwerken van de profielschematisaties is mislukt.
+
\ No newline at end of file
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/RingtoetsPipingSurfaceLineUpdateExceptionTest.cs
===================================================================
diff -u
--- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/RingtoetsPipingSurfaceLineUpdateExceptionTest.cs (revision 0)
+++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/RingtoetsPipingSurfaceLineUpdateExceptionTest.cs (revision 0122d4ac58ee6f7be4ff804db1f6c65e88ce4562)
@@ -0,0 +1,32 @@
+// 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 Core.Common.TestUtil;
+using NUnit.Framework;
+using Ringtoets.Piping.IO.Importers;
+
+namespace Ringtoets.Piping.IO.Test.Importers
+{
+ [TestFixture]
+ public class RingtoetsPipingSurfaceLineUpdateExceptionTest :
+ CustomExceptionDesignGuidelinesTestFixture {}
+}
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj
===================================================================
diff -u -r0e8f4dc487699dda631e50c389624f191f8e946d -r0122d4ac58ee6f7be4ff804db1f6c65e88ce4562
--- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj (.../Ringtoets.Piping.IO.Test.csproj) (revision 0e8f4dc487699dda631e50c389624f191f8e946d)
+++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj (.../Ringtoets.Piping.IO.Test.csproj) (revision 0122d4ac58ee6f7be4ff804db1f6c65e88ce4562)
@@ -73,6 +73,7 @@
+
Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/RingtoetsPipingSurfaceLineUpdateDataStrategyTest.cs
===================================================================
diff -u -r85e72b5765dd231d4d4a4ea6c51431d169a0fb72 -r0122d4ac58ee6f7be4ff804db1f6c65e88ce4562
--- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/RingtoetsPipingSurfaceLineUpdateDataStrategyTest.cs (.../RingtoetsPipingSurfaceLineUpdateDataStrategyTest.cs) (revision 85e72b5765dd231d4d4a4ea6c51431d169a0fb72)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/RingtoetsPipingSurfaceLineUpdateDataStrategyTest.cs (.../RingtoetsPipingSurfaceLineUpdateDataStrategyTest.cs) (revision 0122d4ac58ee6f7be4ff804db1f6c65e88ce4562)
@@ -23,6 +23,7 @@
using System.Collections.Generic;
using System.Linq;
using Core.Common.Base;
+using Core.Common.Base.Geometry;
using NUnit.Framework;
using Ringtoets.Piping.Data;
using Ringtoets.Piping.IO.Importers;
@@ -36,7 +37,6 @@
{
private const string sourceFilePath = "some/path";
-
[Test]
public void Constructor_FailureMechanismNull_ThrowsArgumentNullException()
{
@@ -89,7 +89,7 @@
}
[Test]
- public void UpdatSurfaceLinesWithImportedData_SourceFilePathNull_ThrowsArgumentNullException()
+ public void UpdateSurfaceLinesWithImportedData_SourceFilePathNull_ThrowsArgumentNullException()
{
// Setup
var strategy = new RingtoetsPipingSurfaceLineUpdateDataStrategy(new PipingFailureMechanism());
@@ -105,7 +105,7 @@
}
[Test]
- public void UpdatSurfaceLinesWithImportedData_ReadSurfaceLinesNotInTargetCollection_NewSurfaceLinesAdded()
+ public void UpdateSurfaceLinesWithImportedData_ReadSurfaceLinesNotInTargetCollection_NewSurfaceLinesAdded()
{
// Setup
var importedSurfaceLines = new[]
@@ -130,13 +130,52 @@
// Assert
CollectionAssert.AreEqual(importedSurfaceLines, targetCollection);
- CollectionAssert.AreEqual(new []
+ CollectionAssert.AreEqual(new[]
{
targetCollection
}, affectedObjects);
}
-
+
[Test]
+ public void UpdateSurfaceLinesWithImportedData_WithCurrentModelsAndImportedMultipleLinesWithSameNames_ThrowsRingtoetsPipingSurfaceLineUpdateException()
+ {
+ // Setup
+ const string duplicateName = "Duplicate name it is";
+ var targetCollection = new ObservableCollectionWithSourcePath();
+ targetCollection.AddRange(new[]
+ {
+ new RingtoetsPipingSurfaceLine
+ {
+ Name = duplicateName
+ }
+ }, sourceFilePath);
+
+ RingtoetsPipingSurfaceLine[] importedSurfaceLines =
+ {
+ new RingtoetsPipingSurfaceLine
+ {
+ Name = duplicateName
+ },
+ new RingtoetsPipingSurfaceLine
+ {
+ Name = duplicateName
+ }
+ };
+
+ var strategy = new RingtoetsPipingSurfaceLineUpdateDataStrategy(new PipingFailureMechanism());
+
+ // Call
+ TestDelegate call = () => strategy.UpdateSurfaceLinesWithImportedData(targetCollection,
+ importedSurfaceLines,
+ sourceFilePath);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("Het bijwerken van de profielschematisaties is mislukt.", exception.Message);
+ Assert.IsInstanceOf(exception.InnerException);
+ }
+
+ [Test]
public void UpdateSurfaceLinesWithImportedData_WithCurrentModelsAndImportedDataEmpty_SurfaceLinesRemoved()
{
// Setup
@@ -158,10 +197,57 @@
// Assert
CollectionAssert.IsEmpty(targetCollection);
- CollectionAssert.AreEqual(new []
+ CollectionAssert.AreEqual(new[]
{
targetCollection
}, affectedObjects);
}
+
+ [Test]
+ public void UpdateSurfaceLinesWithImportedData_WithCurrentLinesAndImportedDataHasSameName_UpdatesTargetCollection()
+ {
+ // Setup
+ var targetSurfaceLine = new RingtoetsPipingSurfaceLine
+ {
+ Name = "Name A"
+ };
+ var targetCollection = new ObservableCollectionWithSourcePath();
+ targetCollection.AddRange(new[]
+ {
+ targetSurfaceLine
+ }, sourceFilePath);
+
+ Point3D[] expectedGeometry =
+ {
+ new Point3D(0, 1, 2),
+ new Point3D(3, 4, 5),
+ new Point3D(6, 7, 8)
+ };
+ var readSurfaceLine = new RingtoetsPipingSurfaceLine
+ {
+ Name = "Name A"
+ };
+ readSurfaceLine.SetGeometry(expectedGeometry);
+ var readSurfacelines = new[]
+ {
+ readSurfaceLine
+ };
+
+ var strategy = new RingtoetsPipingSurfaceLineUpdateDataStrategy(new PipingFailureMechanism());
+
+ // Call
+ IEnumerable affectedObjects = strategy.UpdateSurfaceLinesWithImportedData(targetCollection,
+ readSurfacelines,
+ sourceFilePath);
+
+ // Assert
+ Assert.AreEqual(1, targetCollection.Count);
+ Assert.AreSame(targetSurfaceLine, targetCollection[0]);
+ CollectionAssert.AreEqual(expectedGeometry, targetSurfaceLine.Points);
+ CollectionAssert.AreEqual(new[]
+ {
+ targetSurfaceLine
+ }, affectedObjects);
+ }
}
}
\ No newline at end of file
Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelUpdateDataStrategyTest.cs
===================================================================
diff -u -r6ad658313ed97085f5a2653f9e769b77f3b94d80 -r0122d4ac58ee6f7be4ff804db1f6c65e88ce4562
--- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelUpdateDataStrategyTest.cs (.../StochasticSoilModelUpdateDataStrategyTest.cs) (revision 6ad658313ed97085f5a2653f9e769b77f3b94d80)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelUpdateDataStrategyTest.cs (.../StochasticSoilModelUpdateDataStrategyTest.cs) (revision 0122d4ac58ee6f7be4ff804db1f6c65e88ce4562)
@@ -102,7 +102,7 @@
}
[Test]
- public void UpdateModelWithImportedData_WithCurrentModelsAndImportedMultipleModelsWithSameName_ThrowsInvalidOperationException()
+ public void UpdateModelWithImportedData_WithCurrentModelsAndImportedMultipleModelsWithSameName_ThrowsStochasticSoilModelUpdateException()
{
// Setup
const string nonUniqueName = "non-unique name";