Index: Core/Common/src/Core.Common.Base/Geometry/Math2D.cs
===================================================================
diff -u -rade19e1279bda9dfc9959fd0fe88495f7cc90052 -re04155c0cc0efa8bbd13e0a82cb8643711a2dfd6
--- Core/Common/src/Core.Common.Base/Geometry/Math2D.cs (.../Math2D.cs) (revision ade19e1279bda9dfc9959fd0fe88495f7cc90052)
+++ Core/Common/src/Core.Common.Base/Geometry/Math2D.cs (.../Math2D.cs) (revision e04155c0cc0efa8bbd13e0a82cb8643711a2dfd6)
@@ -38,7 +38,7 @@
///
/// Constant which is used to precision errors in comparisons.
///
- private const double epsilonForComparisons = 1e-8;
+ private const double epsilonForComparisons = 1e-6;
///
/// Splits the line geometry at given lengths.
@@ -49,7 +49,8 @@
/// of elements in .
/// When the sum of all elements in
/// does not fully cover the line given by - or - when
- /// contains negative values - or -
+ /// contains negative values - or - when
+ /// does not have 2 or more elements.
public static Point2D[][] SplitLineAtLengths(IEnumerable linePoints, double[] lengths)
{
if (lengths.Any(l => l < 0))
@@ -62,7 +63,7 @@
}
Segment2D[] lineSegments = ConvertLinePointsToLineSegments(linePoints).ToArray();
- if (Math.Abs(lengths.Sum(l => l) - lineSegments.Sum(s => s.Length)) > 1e-6)
+ if (Math.Abs(lengths.Sum(l => l) - lineSegments.Sum(s => s.Length)) > epsilonForComparisons)
{
throw new ArgumentException(Resources.Math2D_SplitLineAtLengths_Sum_of_lengths_must_equal_line_length, "lengths");
}
@@ -172,15 +173,15 @@
Point2D startPoint = lineSegments[index].FirstPoint;
for (int i = 0; i < lengths.Length; i++)
{
- double splitDistance = lengths[i];
+ double splitDistanceRemainder = lengths[i];
var subLine = new List
{
startPoint
};
- while (splitDistance > lineSegmentRemainder)
+ while (splitDistanceRemainder > lineSegmentRemainder)
{
- splitDistance -= lineSegmentRemainder;
+ splitDistanceRemainder -= lineSegmentRemainder;
subLine.Add(lineSegments[index].SecondPoint);
if (index < lineSegments.Length - 1)
@@ -192,11 +193,11 @@
if (i < lengths.Length - 1)
{
- Point2D interpolatedPoint = GetInterpolatedPoint(lineSegments[index], distanceOnSegment + splitDistance);
+ Point2D interpolatedPoint = GetInterpolatedPoint(lineSegments[index], distanceOnSegment + splitDistanceRemainder);
subLine.Add(interpolatedPoint);
- distanceOnSegment += splitDistance;
- lineSegmentRemainder -= splitDistance;
+ distanceOnSegment += splitDistanceRemainder;
+ lineSegmentRemainder -= splitDistanceRemainder;
startPoint = interpolatedPoint;
}
else
Index: Core/Common/src/Core.Common.Base/Geometry/Point2D.cs
===================================================================
diff -u -rfcc49aac894f989182fb9faa487e50a585fbed03 -re04155c0cc0efa8bbd13e0a82cb8643711a2dfd6
--- Core/Common/src/Core.Common.Base/Geometry/Point2D.cs (.../Point2D.cs) (revision fcc49aac894f989182fb9faa487e50a585fbed03)
+++ Core/Common/src/Core.Common.Base/Geometry/Point2D.cs (.../Point2D.cs) (revision e04155c0cc0efa8bbd13e0a82cb8643711a2dfd6)
@@ -26,17 +26,11 @@
namespace Core.Common.Base.Geometry
{
///
- /// Defines a mathematical point in 2D Euclidean space.
+ /// Defines a mathematical, immutable point in 2D Euclidean space.
///
- public class Point2D
+ public sealed class Point2D
{
///
- /// Creates a new instance of , with set to 0
- /// and set to 0.
- ///
- public Point2D() {}
-
- ///
/// Creates a new instance of , with set to
/// and set to .
///
Index: Core/Common/src/Core.Common.Base/Geometry/Point3D.cs
===================================================================
diff -u -rfcc49aac894f989182fb9faa487e50a585fbed03 -re04155c0cc0efa8bbd13e0a82cb8643711a2dfd6
--- Core/Common/src/Core.Common.Base/Geometry/Point3D.cs (.../Point3D.cs) (revision fcc49aac894f989182fb9faa487e50a585fbed03)
+++ Core/Common/src/Core.Common.Base/Geometry/Point3D.cs (.../Point3D.cs) (revision e04155c0cc0efa8bbd13e0a82cb8643711a2dfd6)
@@ -24,9 +24,9 @@
namespace Core.Common.Base.Geometry
{
///
- /// Defines a mathematical point in 3D Euclidean space.
+ /// Defines a mathematical, immutable point in 3D Euclidean space.
///
- public class Point3D
+ public sealed class Point3D
{
///
/// Creates a new instance of .
@@ -94,7 +94,7 @@
///
/// A to compare with.
/// True if the coordinates of the matches the coordinate of . False otherwise.
- protected bool Equals(Point3D other)
+ private bool Equals(Point3D other)
{
return X.Equals(other.X) && Y.Equals(other.Y) && Z.Equals(other.Z);
}
Index: Core/Common/src/Core.Common.Base/Geometry/Segment2D.cs
===================================================================
diff -u -rfcc49aac894f989182fb9faa487e50a585fbed03 -re04155c0cc0efa8bbd13e0a82cb8643711a2dfd6
--- Core/Common/src/Core.Common.Base/Geometry/Segment2D.cs (.../Segment2D.cs) (revision fcc49aac894f989182fb9faa487e50a585fbed03)
+++ Core/Common/src/Core.Common.Base/Geometry/Segment2D.cs (.../Segment2D.cs) (revision e04155c0cc0efa8bbd13e0a82cb8643711a2dfd6)
@@ -28,9 +28,9 @@
namespace Core.Common.Base.Geometry
{
///
- /// This class represents lines between two .
+ /// This class represents an immutable line-segment between two .
///
- public class Segment2D
+ public sealed class Segment2D
{
///
/// Creates a new instance of , with the set to
@@ -123,16 +123,16 @@
return point.GetEuclideanDistanceTo(FirstPoint);
}
// 2. Use denominator part of vector projection to determine relative location of 'point':
- double dotProdcutSegmentVector = segmentVector.DotProduct(segmentVector);
- if (dotProdcutSegmentVector <= dotProductOrientationVector)
+ double dotProductSegmentVector = segmentVector.DotProduct(segmentVector);
+ if (dotProductSegmentVector <= dotProductOrientationVector)
{
// 'point' falls outside the perpendicular area defined by segment, specifically: Zone C
return point.GetEuclideanDistanceTo(SecondPoint);
}
// 'point' falls within the perpendicular area defined by the segment (zone B).
// 3. Use remainder of vector projection to determine point on segment for perpendicular line:
- double projectionFactor = dotProductOrientationVector / dotProdcutSegmentVector;
+ double projectionFactor = dotProductOrientationVector / dotProductSegmentVector;
double perpendicularOnSegmentX = FirstPoint.X + projectionFactor * segmentVector[0];
double perpendicularOnSegmentY = FirstPoint.Y + projectionFactor * segmentVector[1];
var perpendicularLineIntersectionPoint = new Point2D(perpendicularOnSegmentX, perpendicularOnSegmentY);
Index: Core/Common/src/Core.Common.Base/IO/FileImporterBase.cs
===================================================================
diff -u -r97fb97c5677e2afbd1675ba0fb3e989028a65d09 -re04155c0cc0efa8bbd13e0a82cb8643711a2dfd6
--- Core/Common/src/Core.Common.Base/IO/FileImporterBase.cs (.../FileImporterBase.cs) (revision 97fb97c5677e2afbd1675ba0fb3e989028a65d09)
+++ Core/Common/src/Core.Common.Base/IO/FileImporterBase.cs (.../FileImporterBase.cs) (revision e04155c0cc0efa8bbd13e0a82cb8643711a2dfd6)
@@ -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.Drawing;
using System.Linq;
@@ -33,8 +32,9 @@
/// change notifications for objects that have been affected
/// during the import.
///
+ /// The type of the item supported by the importer.
///
- public abstract class FileImporterBase : IFileImporter
+ public abstract class FileImporterBase : IFileImporter
{
///
/// Indicates if a cancel request has been made. When true, no changes should be
@@ -46,13 +46,12 @@
public abstract string Name { get; }
public abstract string Category { get; }
public abstract Bitmap Image { get; }
- public abstract Type SupportedItemType { get; }
public abstract string FileFilter { get; }
public abstract ProgressChangedDelegate ProgressChanged { protected get; set; }
public virtual bool CanImportOn(object targetItem)
{
- return targetItem.GetType().Implements(SupportedItemType);
+ return targetItem.GetType().Implements();
}
public abstract bool Import(object targetItem, string filePath);
Index: Core/Common/src/Core.Common.Base/IO/IFileImporter.cs
===================================================================
diff -u -r97fb97c5677e2afbd1675ba0fb3e989028a65d09 -re04155c0cc0efa8bbd13e0a82cb8643711a2dfd6
--- Core/Common/src/Core.Common.Base/IO/IFileImporter.cs (.../IFileImporter.cs) (revision 97fb97c5677e2afbd1675ba0fb3e989028a65d09)
+++ Core/Common/src/Core.Common.Base/IO/IFileImporter.cs (.../IFileImporter.cs) (revision e04155c0cc0efa8bbd13e0a82cb8643711a2dfd6)
@@ -46,11 +46,6 @@
Bitmap Image { get; }
///
- /// Gets the of the item supported by the .
- ///
- Type SupportedItemType { get; }
-
- ///
/// Gets the file filter of the .
///
///
Index: Core/Common/test/Core.Common.Base.Test/Geometry/Math2DTest.cs
===================================================================
diff -u -rd36795ad93a8aaf9daccd85f143b15562f963fb3 -re04155c0cc0efa8bbd13e0a82cb8643711a2dfd6
--- Core/Common/test/Core.Common.Base.Test/Geometry/Math2DTest.cs (.../Math2DTest.cs) (revision d36795ad93a8aaf9daccd85f143b15562f963fb3)
+++ Core/Common/test/Core.Common.Base.Test/Geometry/Math2DTest.cs (.../Math2DTest.cs) (revision e04155c0cc0efa8bbd13e0a82cb8643711a2dfd6)
@@ -215,7 +215,7 @@
public void ConvertLinePointsToLineSegments_TooFewPoints_ReturnEmpty(int pointCount)
{
// Setup
- var linePoints = Enumerable.Repeat(new Point2D(), pointCount);
+ var linePoints = Enumerable.Repeat(new Point2D(0, 0), pointCount);
// Call
IEnumerable segments = Math2D.ConvertLinePointsToLineSegments(linePoints);
Index: Core/Common/test/Core.Common.Base.Test/Geometry/Point2DTest.cs
===================================================================
diff -u -rfcc49aac894f989182fb9faa487e50a585fbed03 -re04155c0cc0efa8bbd13e0a82cb8643711a2dfd6
--- Core/Common/test/Core.Common.Base.Test/Geometry/Point2DTest.cs (.../Point2DTest.cs) (revision fcc49aac894f989182fb9faa487e50a585fbed03)
+++ Core/Common/test/Core.Common.Base.Test/Geometry/Point2DTest.cs (.../Point2DTest.cs) (revision e04155c0cc0efa8bbd13e0a82cb8643711a2dfd6)
@@ -33,17 +33,6 @@
public class Point2DTest
{
[Test]
- public void DefaultConstructor_ExpectedValues()
- {
- // Call
- var point = new Point2D();
-
- // Assert
- Assert.AreEqual(0, point.X);
- Assert.AreEqual(0, point.Y);
- }
-
- [Test]
public void Constructor_WithXandY_SetPropeties()
{
// Setup
@@ -63,7 +52,7 @@
public void Equals_ToNull_ReturnsFalse()
{
// Setup
- var point = new Point2D();
+ var point = new Point2D(0, 0);
// Call
var result = point.Equals(null);
@@ -76,10 +65,10 @@
public void Equals_ToOtherType_ReturnsFalse()
{
// Setup
- var point = new Point2D();
+ var point = new Point2D(0, 0);
// Call
- var result = point.Equals(new Point3D(0,0,0));
+ var result = point.Equals(new Point3D(0, 0, 0));
// Assert
Assert.IsFalse(result);
@@ -89,7 +78,7 @@
public void Equals_ToItself_ReturnsTrue()
{
// Setup
- var point = new Point2D();
+ var point = new Point2D(0, 0);
// Call
var result = point.Equals(point);
Index: Core/Common/test/Core.Common.Base.Test/Geometry/Point3DTest.cs
===================================================================
diff -u -rfcc49aac894f989182fb9faa487e50a585fbed03 -re04155c0cc0efa8bbd13e0a82cb8643711a2dfd6
--- Core/Common/test/Core.Common.Base.Test/Geometry/Point3DTest.cs (.../Point3DTest.cs) (revision fcc49aac894f989182fb9faa487e50a585fbed03)
+++ Core/Common/test/Core.Common.Base.Test/Geometry/Point3DTest.cs (.../Point3DTest.cs) (revision e04155c0cc0efa8bbd13e0a82cb8643711a2dfd6)
@@ -46,7 +46,7 @@
var point = new Point3D(0,0,0);
// Call
- var result = point.Equals(new Point2D());
+ var result = point.Equals(new Point2D(0, 0));
// Assert
Assert.IsFalse(result);
Index: Core/Common/test/Core.Common.Base.Test/Geometry/Segment2DTest.cs
===================================================================
diff -u -rfcc49aac894f989182fb9faa487e50a585fbed03 -re04155c0cc0efa8bbd13e0a82cb8643711a2dfd6
--- Core/Common/test/Core.Common.Base.Test/Geometry/Segment2DTest.cs (.../Segment2DTest.cs) (revision fcc49aac894f989182fb9faa487e50a585fbed03)
+++ Core/Common/test/Core.Common.Base.Test/Geometry/Segment2DTest.cs (.../Segment2DTest.cs) (revision e04155c0cc0efa8bbd13e0a82cb8643711a2dfd6)
@@ -13,8 +13,8 @@
public void Constructor_WithTwoPoints_ReturnsSegmentWithPointsSet()
{
// Setup
- var firstPoint = new Point2D();
- var secondPoint = new Point2D();
+ var firstPoint = new Point2D(0, 0);
+ var secondPoint = new Point2D(0, 0);
// Call
var segment = new Segment2D(firstPoint, secondPoint);
@@ -28,7 +28,7 @@
public void Constructor_WithNullFirstPoint_ThrowsArgumentNullException()
{
// Setup
- var secondPoint = new Point2D();
+ var secondPoint = new Point2D(0, 0);
// Call
TestDelegate test = () => new Segment2D(null, secondPoint);
@@ -42,7 +42,7 @@
public void Constructor_WithNullSecondPoint_ThrowsArgumentNullException()
{
// Setup
- var firstPoint = new Point2D();
+ var firstPoint = new Point2D(0, 0);
// Call
TestDelegate test = () => new Segment2D(firstPoint, null);
Index: Core/Common/test/Core.Common.Base.Test/IO/FileImporterBaseTest.cs
===================================================================
diff -u -r97fb97c5677e2afbd1675ba0fb3e989028a65d09 -re04155c0cc0efa8bbd13e0a82cb8643711a2dfd6
--- Core/Common/test/Core.Common.Base.Test/IO/FileImporterBaseTest.cs (.../FileImporterBaseTest.cs) (revision 97fb97c5677e2afbd1675ba0fb3e989028a65d09)
+++ Core/Common/test/Core.Common.Base.Test/IO/FileImporterBaseTest.cs (.../FileImporterBaseTest.cs) (revision e04155c0cc0efa8bbd13e0a82cb8643711a2dfd6)
@@ -179,7 +179,7 @@
Assert.AreEqual(1, progressChangedCallCount);
}
- private class SimpleFileImporter : FileImporterBase
+ private class SimpleFileImporter : FileImporterBase
{
public override string Name
{
@@ -205,14 +205,6 @@
}
}
- public override Type SupportedItemType
- {
- get
- {
- return typeof(SimpleFileImporterTargetType);
- }
- }
-
public override string FileFilter
{
get
Index: Core/Common/test/Core.Common.Base.Test/Plugin/ApplicationCoreTest.cs
===================================================================
diff -u -r97fb97c5677e2afbd1675ba0fb3e989028a65d09 -re04155c0cc0efa8bbd13e0a82cb8643711a2dfd6
--- Core/Common/test/Core.Common.Base.Test/Plugin/ApplicationCoreTest.cs (.../ApplicationCoreTest.cs) (revision 97fb97c5677e2afbd1675ba0fb3e989028a65d09)
+++ Core/Common/test/Core.Common.Base.Test/Plugin/ApplicationCoreTest.cs (.../ApplicationCoreTest.cs) (revision e04155c0cc0efa8bbd13e0a82cb8643711a2dfd6)
@@ -414,7 +414,7 @@
}
}
- private class SimpleFileImporter : FileImporterBase
+ private class SimpleFileImporter : FileImporterBase
{
public override string Name
{
@@ -440,14 +440,6 @@
}
}
- public override Type SupportedItemType
- {
- get
- {
- return typeof(T);
- }
- }
-
public override string FileFilter
{
get
Index: Core/Common/test/Core.Common.Base.Test/Service/FileImportActivityTest.cs
===================================================================
diff -u -r925d8a1d7dec6ef95d89b2ff67d78c8d5a49387f -re04155c0cc0efa8bbd13e0a82cb8643711a2dfd6
--- Core/Common/test/Core.Common.Base.Test/Service/FileImportActivityTest.cs (.../FileImportActivityTest.cs) (revision 925d8a1d7dec6ef95d89b2ff67d78c8d5a49387f)
+++ Core/Common/test/Core.Common.Base.Test/Service/FileImportActivityTest.cs (.../FileImportActivityTest.cs) (revision e04155c0cc0efa8bbd13e0a82cb8643711a2dfd6)
@@ -160,7 +160,7 @@
mocks.VerifyAll();
}
- private class SimpleFileImporter : FileImporterBase
+ private class SimpleFileImporter : FileImporterBase
- public class PipingSurfaceLinesCsvImporter : FileImporterBase
+ public class PipingSurfaceLinesCsvImporter : FileImporterBase>
{
private readonly ILog log = LogManager.GetLogger(typeof(PipingSurfaceLinesCsvImporter));
@@ -75,14 +75,6 @@
}
}
- public override Type SupportedItemType
- {
- get
- {
- return typeof(ICollection);
- }
- }
-
public override string FileFilter
{
get
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/PipingFailureMechanismContextTest.cs
===================================================================
diff -u -r69bae9f753011e0f962a3ffa9b3c696efe5852dd -re04155c0cc0efa8bbd13e0a82cb8643711a2dfd6
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/PipingFailureMechanismContextTest.cs (.../PipingFailureMechanismContextTest.cs) (revision 69bae9f753011e0f962a3ffa9b3c696efe5852dd)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/PipingFailureMechanismContextTest.cs (.../PipingFailureMechanismContextTest.cs) (revision e04155c0cc0efa8bbd13e0a82cb8643711a2dfd6)
@@ -1,5 +1,7 @@
-using NUnit.Framework;
+using System;
+using NUnit.Framework;
+
using Rhino.Mocks;
using Ringtoets.Common.Data;
@@ -29,5 +31,34 @@
Assert.IsInstanceOf>(context);
mocks.VerifyAll();
}
+
+ [Test]
+ public void Constructor_FailureMechanismIsNull_ThrowArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate call = () => new PipingFailureMechanismContext(null, assessmentSection);
+
+ // Assert
+ Assert.Throws(call);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Constructor_AssessmentSectionIsNull_ThrowArgumentNullException()
+ {
+ // Setup
+ var failureMechanism = new PipingFailureMechanism();
+
+ // Call
+ TestDelegate call = () => new PipingFailureMechanismContext(failureMechanism, null);
+
+ // Assert
+ Assert.Throws(call);
+ }
}
}
\ No newline at end of file
Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSoilProfilesImporterTest.cs
===================================================================
diff -u -rdcd6469f6000957bc1604da8e92bd5ea09e43769 -re04155c0cc0efa8bbd13e0a82cb8643711a2dfd6
--- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSoilProfilesImporterTest.cs (.../PipingSoilProfilesImporterTest.cs) (revision dcd6469f6000957bc1604da8e92bd5ea09e43769)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSoilProfilesImporterTest.cs (.../PipingSoilProfilesImporterTest.cs) (revision e04155c0cc0efa8bbd13e0a82cb8643711a2dfd6)
@@ -40,12 +40,11 @@
var importer = new PipingSoilProfilesImporter();
// Assert
- Assert.IsInstanceOf(importer);
+ Assert.IsInstanceOf>>(importer);
Assert.AreEqual(PipingFormsResources.PipingSoilProfilesCollection_DisplayName, importer.Name);
Assert.AreEqual(RingtoetsFormsResources.Ringtoets_Category, importer.Category);
Assert.AreEqual(16, importer.Image.Width);
Assert.AreEqual(16, importer.Image.Height);
- Assert.AreEqual(typeof(ICollection), importer.SupportedItemType);
Assert.AreEqual(expectedFileFilter, importer.FileFilter);
}
Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSurfaceLinesCsvImporterTest.cs
===================================================================
diff -u -r82c08997cab1058c739a21c9339e4fef59ee58ff -re04155c0cc0efa8bbd13e0a82cb8643711a2dfd6
--- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSurfaceLinesCsvImporterTest.cs (.../PipingSurfaceLinesCsvImporterTest.cs) (revision 82c08997cab1058c739a21c9339e4fef59ee58ff)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSurfaceLinesCsvImporterTest.cs (.../PipingSurfaceLinesCsvImporterTest.cs) (revision e04155c0cc0efa8bbd13e0a82cb8643711a2dfd6)
@@ -36,12 +36,11 @@
var importer = new PipingSurfaceLinesCsvImporter();
// Assert
- Assert.IsInstanceOf(importer);
+ Assert.IsInstanceOf>>(importer);
Assert.AreEqual(PipingFormsResources.PipingSurfaceLinesCollection_DisplayName, importer.Name);
Assert.AreEqual(RingtoetsFormsResources.Ringtoets_Category, importer.Category);
Assert.AreEqual(16, importer.Image.Width);
Assert.AreEqual(16, importer.Image.Height);
- Assert.AreEqual(typeof(ICollection), importer.SupportedItemType);
var expectedFileFilter = String.Format("{0} {1} (*.csv)|*.csv",
PipingFormsResources.PipingSurfaceLinesCollection_DisplayName, ApplicationResources.Csv_file_name);
Assert.AreEqual(expectedFileFilter, importer.FileFilter);