Index: Ringtoets/Piping/src/Ringtoets.Piping.Primitives/RingtoetsPipingSurfaceLine.cs
===================================================================
diff -u -rb2b9fdf365e70928a05c57966eeed30d9050e528 -r34023112e9d57acf92ed6a713d6e2d1df8548098
--- Ringtoets/Piping/src/Ringtoets.Piping.Primitives/RingtoetsPipingSurfaceLine.cs (.../RingtoetsPipingSurfaceLine.cs) (revision b2b9fdf365e70928a05c57966eeed30d9050e528)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Primitives/RingtoetsPipingSurfaceLine.cs (.../RingtoetsPipingSurfaceLine.cs) (revision 34023112e9d57acf92ed6a713d6e2d1df8548098)
@@ -23,6 +23,7 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
+using Core.Common.Base;
using Core.Common.Base.Data;
using Core.Common.Base.Geometry;
using Ringtoets.Piping.Primitives.Exceptions;
@@ -33,7 +34,7 @@
///
/// Definition of a surfaceline for piping.
///
- public class RingtoetsPipingSurfaceLine
+ public class RingtoetsPipingSurfaceLine : Observable
{
private const int numberOfDecimalPlaces = 2;
private Point2D[] localGeometry;
@@ -350,6 +351,25 @@
new RoundedDouble(numberOfDecimalPlaces, localCoordinate.Y));
}
+ ///
+ /// Updates the with the properties of
+ /// .
+ ///
+ /// The
+ /// to get the property values from.
+ /// Thrown when
+ /// is null.
+ public void Update(RingtoetsPipingSurfaceLine fromSurfaceLine)
+ {
+ if (fromSurfaceLine == null)
+ {
+ throw new ArgumentNullException(nameof(fromSurfaceLine));
+ }
+
+ Name = fromSurfaceLine.Name;
+ SetGeometry(fromSurfaceLine.Points);
+ }
+
public override string ToString()
{
return Name;
Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/RingtoetsPipingSurfaceLineTest.cs
===================================================================
diff -u -r11f0867b39150ae5fac83dc178a89fee46d27611 -r34023112e9d57acf92ed6a713d6e2d1df8548098
--- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/RingtoetsPipingSurfaceLineTest.cs (.../RingtoetsPipingSurfaceLineTest.cs) (revision 11f0867b39150ae5fac83dc178a89fee46d27611)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/RingtoetsPipingSurfaceLineTest.cs (.../RingtoetsPipingSurfaceLineTest.cs) (revision 34023112e9d57acf92ed6a713d6e2d1df8548098)
@@ -21,6 +21,7 @@
using System;
using System.Linq;
+using Core.Common.Base;
using Core.Common.Base.Data;
using Core.Common.Base.Geometry;
using Core.Common.TestUtil;
@@ -43,6 +44,7 @@
var surfaceLine = new RingtoetsPipingSurfaceLine();
// Assert
+ Assert.IsInstanceOf(surfaceLine);
Assert.AreEqual(string.Empty, surfaceLine.Name);
CollectionAssert.IsEmpty(surfaceLine.Points);
Assert.IsNull(surfaceLine.StartingWorldPoint);
@@ -179,12 +181,12 @@
RoundedPoint2DCollection actual = surfaceLine.ProjectGeometryToLZ();
// Assert
- var length = Math.Sqrt(2*2 + 3*3);
- const double secondCoordinateFactor = (2.0*1.0 + 3.0*2.0)/(2.0*2.0 + 3.0*3.0);
+ var length = Math.Sqrt(2 * 2 + 3 * 3);
+ const double secondCoordinateFactor = (2.0 * 1.0 + 3.0 * 2.0) / (2.0 * 2.0 + 3.0 * 3.0);
var expectedCoordinatesX = new[]
{
0.0,
- secondCoordinateFactor*length,
+ secondCoordinateFactor * length,
length
};
CollectionAssert.AreEqual(expectedCoordinatesX, actual.Select(p => p.X).ToArray(), new DoubleWithToleranceComparer(actual.GetAccuracy()));
@@ -724,6 +726,48 @@
Assert.AreEqual(new Point2D(double.NaN, double.NaN), localPoint);
}
+ [Test]
+ public void Update_WithNullModel_ThrowsArgumentNullException()
+ {
+ // Setup
+ var surfaceLine = new RingtoetsPipingSurfaceLine();
+
+ // Call
+ TestDelegate call = () => surfaceLine.Update(null);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("fromSurfaceLine", paramName);
+ }
+
+ [Test]
+ public void Update_ModelWithUpdatedProperties_PropertiesUpdated()
+ {
+ // Setup
+ var surfaceLine = new RingtoetsPipingSurfaceLine();
+
+ const string expectedName = "Other name";
+ Point3D[] expectedGeometry =
+ {
+ new Point3D(0, 1, 2),
+ new Point3D(3, 4, 5),
+ new Point3D(6, 7, 8)
+ };
+
+ var surfaceLineToUpdateFrom = new RingtoetsPipingSurfaceLine
+ {
+ Name = expectedName
+ };
+ surfaceLineToUpdateFrom.SetGeometry(expectedGeometry);
+
+ // Call
+ surfaceLine.Update(surfaceLineToUpdateFrom);
+
+ // Assert
+ Assert.AreEqual(expectedName, surfaceLine.Name);
+ CollectionAssert.AreEqual(expectedGeometry, surfaceLine.Points);
+ }
+
private static void CreateTestGeometry(Point3D testPoint, RingtoetsPipingSurfaceLine surfaceLine)
{
var random = new Random(21);
Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/StochasticSoilModelTest.cs
===================================================================
diff -u -r34f1b5a53b9c554d1a0a35365da4f8d258117304 -r34023112e9d57acf92ed6a713d6e2d1df8548098
--- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/StochasticSoilModelTest.cs (.../StochasticSoilModelTest.cs) (revision 34f1b5a53b9c554d1a0a35365da4f8d258117304)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/StochasticSoilModelTest.cs (.../StochasticSoilModelTest.cs) (revision 34023112e9d57acf92ed6a713d6e2d1df8548098)
@@ -113,7 +113,7 @@
[Test]
public void Update_ModelWithUpdatedProperties_PropertiesUpdated()
{
- // Assert
+ // Setup
var model = new StochasticSoilModel(1234, "name", "segment");
model.Geometry.AddRange(new[]
{