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 override string Name { @@ -186,14 +186,6 @@ } } - public override Type SupportedItemType - { - get - { - return null; - } - } - public override string FileFilter { get Index: Core/Common/test/Core.Common.Gui.Test/Commands/ExportImportCommandHandlerTest.cs =================================================================== diff -u -r97fb97c5677e2afbd1675ba0fb3e989028a65d09 -re04155c0cc0efa8bbd13e0a82cb8643711a2dfd6 --- Core/Common/test/Core.Common.Gui.Test/Commands/ExportImportCommandHandlerTest.cs (.../ExportImportCommandHandlerTest.cs) (revision 97fb97c5677e2afbd1675ba0fb3e989028a65d09) +++ Core/Common/test/Core.Common.Gui.Test/Commands/ExportImportCommandHandlerTest.cs (.../ExportImportCommandHandlerTest.cs) (revision e04155c0cc0efa8bbd13e0a82cb8643711a2dfd6) @@ -100,7 +100,7 @@ } [Test] - public void CanImportOn_HasMultipleFileImporterForTarget_ReturnTrue() + public void CanImportOn_HasMultipleFileImporterForTargetWhereAtLeastOneCanHandleTargetItem_ReturnTrue() { // Setup var target = new object(); Index: Core/Common/test/Core.Common.TestUtil.Test/Core.Common.TestUtil.Test.csproj =================================================================== diff -u -r1a6f65407809a58d25b871af1fc77d6323c6c83a -re04155c0cc0efa8bbd13e0a82cb8643711a2dfd6 --- Core/Common/test/Core.Common.TestUtil.Test/Core.Common.TestUtil.Test.csproj (.../Core.Common.TestUtil.Test.csproj) (revision 1a6f65407809a58d25b871af1fc77d6323c6c83a) +++ Core/Common/test/Core.Common.TestUtil.Test/Core.Common.TestUtil.Test.csproj (.../Core.Common.TestUtil.Test.csproj) (revision e04155c0cc0efa8bbd13e0a82cb8643711a2dfd6) @@ -51,6 +51,7 @@ + True True Index: Core/Common/test/Core.Common.TestUtil.Test/DoubleWithToleranceComparerTest.cs =================================================================== diff -u --- Core/Common/test/Core.Common.TestUtil.Test/DoubleWithToleranceComparerTest.cs (revision 0) +++ Core/Common/test/Core.Common.TestUtil.Test/DoubleWithToleranceComparerTest.cs (revision e04155c0cc0efa8bbd13e0a82cb8643711a2dfd6) @@ -0,0 +1,114 @@ +using System; +using System.Collections; +using System.Collections.Generic; + +using NUnit.Framework; + +namespace Core.Common.TestUtil.Test +{ + [TestFixture] + public class DoubleWithToleranceComparerTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Setup + + // Call + var comparer = new DoubleWithToleranceComparer(1.1); + + // Assert + Assert.IsInstanceOf(comparer); + Assert.IsInstanceOf>(comparer); + } + + [Test] + public void Compare_FirstObjectOfIncorrectType_ThrowArgumentException() + { + // Setup + object firstObject = new object(); + object secondObject = 1.1; + + var comparer = new DoubleWithToleranceComparer(2.2); + + // Call + TestDelegate call = () => comparer.Compare(firstObject, secondObject); + + // Assert + var message = Assert.Throws(call).Message; + Assert.AreEqual("Cannot compare objects other than System.Double with this comparer.", message); + } + + [Test] + public void Compare_SecondObjectOfIncorrectType_ThrowArgumentException() + { + // Setup + object firstObject = 2.2; + object secondObject = new object(); + + var comparer = new DoubleWithToleranceComparer(2.2); + + // Call + TestDelegate call = () => comparer.Compare(firstObject, secondObject); + + // Assert + var message = Assert.Throws(call).Message; + Assert.AreEqual("Cannot compare objects other than System.Double with this comparer.", message); + } + + [Test] + [TestCase(1.1, 2.2, 1.1)] + [TestCase(1.1, 1.1, 0.0)] + [TestCase(-2.2, 0.0, 2.2)] + [TestCase(0.0, -1.6, 2)] + public void Compare_ValuesWithinTolerance_ReturnZero(double first, double second, double tolerance) + { + // Setup + var comparer = new DoubleWithToleranceComparer(tolerance); + + // Call + int result = comparer.Compare(first, second); + + // Assert + Assert.AreEqual(0, result); + } + + [Test] + [Combinatorial] + public void Compare_FirstLessThanSecond_ReturnLessThanZero( + [Values(1.1)]double first, + [Values(2.2 + 1e-6, 6.8)]double second, + [Values(true, false)]bool castToObject) + { + // Setup + var comparer = new DoubleWithToleranceComparer(1.1); + + // Call + var result = castToObject ? + comparer.Compare((object)first, second) : + comparer.Compare(first, second); + + // Assert + Assert.Less(result, 0); + } + + [Test] + [Combinatorial] + public void Compare_FirstGreaterThanSecond_ReturnGreaterThanZero( + [Values(1.1)]double first, + [Values(0.6 - 1e-6, -9.65)]double second, + [Values(true, false)]bool castToObject) + { + // Setup + var comparer = new DoubleWithToleranceComparer(0.5); + + // Call + var result = castToObject ? + comparer.Compare((object)first, second) : + comparer.Compare(first, second); + + // Assert + Assert.Greater(result, 0); + } + } +} \ No newline at end of file Index: Core/Common/test/Core.Common.TestUtil/DoubleWithToleranceComparer.cs =================================================================== diff -u -rd36795ad93a8aaf9daccd85f143b15562f963fb3 -re04155c0cc0efa8bbd13e0a82cb8643711a2dfd6 --- Core/Common/test/Core.Common.TestUtil/DoubleWithToleranceComparer.cs (.../DoubleWithToleranceComparer.cs) (revision d36795ad93a8aaf9daccd85f143b15562f963fb3) +++ Core/Common/test/Core.Common.TestUtil/DoubleWithToleranceComparer.cs (.../DoubleWithToleranceComparer.cs) (revision e04155c0cc0efa8bbd13e0a82cb8643711a2dfd6) @@ -2,8 +2,6 @@ using System.Collections; using System.Collections.Generic; -using Core.Common.Base.Geometry; - namespace Core.Common.TestUtil { /// @@ -23,7 +21,7 @@ { var diff = firstDouble - secondDouble; - var tolerable = Math.Abs(diff) < tolerance; + var tolerable = Math.Abs(diff) <= tolerance; var nonTolerableDiff = !tolerable && diff < 0 ? -1 : 1; @@ -34,7 +32,7 @@ { if (!(x is double) || !(y is double)) { - throw new NotSupportedException(string.Format("Cannot compare objects other than {0} with this comparer.", typeof(Double))); + throw new ArgumentException(string.Format("Cannot compare objects other than {0} with this comparer.", typeof(Double))); } return Compare((double)x, (double)y); } Index: Ringtoets/Common/src/Ringtoets.Common.Data/IFailureMechanism.cs =================================================================== diff -u -rc6a3cd9e25138d35bf0881f3ff6df9dfe1776fd2 -re04155c0cc0efa8bbd13e0a82cb8643711a2dfd6 --- Ringtoets/Common/src/Ringtoets.Common.Data/IFailureMechanism.cs (.../IFailureMechanism.cs) (revision c6a3cd9e25138d35bf0881f3ff6df9dfe1776fd2) +++ Ringtoets/Common/src/Ringtoets.Common.Data/IFailureMechanism.cs (.../IFailureMechanism.cs) (revision e04155c0cc0efa8bbd13e0a82cb8643711a2dfd6) @@ -51,7 +51,7 @@ /// /// Gets the sections that define area's for which a calculation could determine - /// a representative result. + /// a representative result. Cannot return null. /// IEnumerable Sections { get; } Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/BaseFailureMechanismTest.cs =================================================================== diff -u -r8f1db6ac4fd537aba5d537744eb55e557d977cac -re04155c0cc0efa8bbd13e0a82cb8643711a2dfd6 --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/BaseFailureMechanismTest.cs (.../BaseFailureMechanismTest.cs) (revision 8f1db6ac4fd537aba5d537744eb55e557d977cac) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/BaseFailureMechanismTest.cs (.../BaseFailureMechanismTest.cs) (revision e04155c0cc0efa8bbd13e0a82cb8643711a2dfd6) @@ -182,7 +182,7 @@ } [Test] - public void ClearAllSections_HasSections_DoNothing() + public void ClearAllSections_HasSections_ClearSections() { // Setup var section = new FailureMechanismSection("A", new[] Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/FileImporters/FailureMechanismSectionsImporter.cs =================================================================== diff -u -r97fb97c5677e2afbd1675ba0fb3e989028a65d09 -re04155c0cc0efa8bbd13e0a82cb8643711a2dfd6 --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/FileImporters/FailureMechanismSectionsImporter.cs (.../FailureMechanismSectionsImporter.cs) (revision 97fb97c5677e2afbd1675ba0fb3e989028a65d09) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/FileImporters/FailureMechanismSectionsImporter.cs (.../FailureMechanismSectionsImporter.cs) (revision e04155c0cc0efa8bbd13e0a82cb8643711a2dfd6) @@ -25,7 +25,7 @@ /// Imports instances from a shapefile that contains /// one or more polylines and stores them in a . /// - public class FailureMechanismSectionsImporter : FileImporterBase + public class FailureMechanismSectionsImporter : FileImporterBase { /// /// The snapping tolerance in meters. @@ -63,14 +63,6 @@ } } - public override Type SupportedItemType - { - get - { - return typeof(FailureMechanismSectionsContext); - } - } - public override string FileFilter { get @@ -83,13 +75,13 @@ public override bool CanImportOn(object targetItem) { - return base.CanImportOn(targetItem) && ReferenceLineAvailable(targetItem); + return base.CanImportOn(targetItem) && IsReferenceLineAvailable(targetItem); } public override bool Import(object targetItem, string filePath) { var context = (FailureMechanismSectionsContext)targetItem; - if (context.ParentAssessmentSection.ReferenceLine == null) + if (!IsReferenceLineAvailable(targetItem)) { LogCriticalFileReadError(Resources.FailureMechanismSectionsImporter_Import_Required_referenceline_missing); return false; @@ -115,7 +107,9 @@ } NotifyProgress(Resources.FailureMechanismSectionsImporter_ProgressText_Validating_imported_sections, 2, 3); - if (!SectionsCorrespondToReferenceLine(context, readResults)) + ReferenceLine referenceLine = context.ParentAssessmentSection.ReferenceLine; + ICollection readFailureMechanismSections = readResults.ImportedItems; + if (!SectionsCorrespondToReferenceLine(referenceLine, readFailureMechanismSections)) { LogCriticalFileReadError(Resources.FailureMechanismSectionsImporter_Import_Imported_sections_do_not_correspond_to_current_referenceline); return false; @@ -128,11 +122,11 @@ } NotifyProgress(Resources.FailureMechanismSectionsImporter_ProgressText_Adding_imported_data_to_failureMechanism, 3, 3); - AddImportedDataToModel(context, readResults); + AddImportedDataToModel(readFailureMechanismSections, context.ParentFailureMechanism, referenceLine); return true; } - private static bool ReferenceLineAvailable(object targetItem) + private static bool IsReferenceLineAvailable(object targetItem) { return ((FailureMechanismSectionsContext)targetItem).ParentAssessmentSection.ReferenceLine != null; } @@ -214,41 +208,58 @@ log.Error(errorMessage); } - private bool SectionsCorrespondToReferenceLine(FailureMechanismSectionsContext context, ReadResult readResults) + private bool SectionsCorrespondToReferenceLine(ReferenceLine referenceLine, ICollection mechanismSections) { - ICollection failureMechanismSections = readResults.ImportedItems; - ReferenceLine referenceLine = context.ParentAssessmentSection.ReferenceLine; - - IEnumerable allStartAndEndPoints = failureMechanismSections.Select(s => s.GetStart()).Concat(failureMechanismSections.Select(s => s.GetLast())); - if (allStartAndEndPoints.Any(point => GetDistanceToReferenceLine(point, referenceLine) > snappingTolerance)) + if (HasStartOrEndPointsTooFarFromReferenceLine(referenceLine, mechanismSections)) { return false; } - var totalSectionsLength = failureMechanismSections.Sum(s => GetSectionLength(s)); - var referenceLineLength = GetLengthOfLine(referenceLine.Points); - if (Math.Abs(totalSectionsLength - referenceLineLength) > lengthDifferenceTolerance) + if (IsTotalLengthOfSectionsTooDifferentFromReferenceLineLength(referenceLine, mechanismSections)) { return false; } return true; } + private bool HasStartOrEndPointsTooFarFromReferenceLine(ReferenceLine referenceLine, ICollection mechanismSections) + { + foreach (var failureMechanismSection in mechanismSections) + { + if (GetDistanceToReferenceLine(failureMechanismSection.GetStart(), referenceLine) > snappingTolerance) + { + return true; + } + if (GetDistanceToReferenceLine(failureMechanismSection.GetLast(), referenceLine) > snappingTolerance) + { + return true; + } + } + return false; + } + private double GetDistanceToReferenceLine(Point2D point, ReferenceLine referenceLine) { return GetLineSegments(referenceLine.Points) - .Select(segment => segment.GetEuclideanDistanceToPoint(point)) - .Min(); + .Min(segment => segment.GetEuclideanDistanceToPoint(point)); } - private void AddImportedDataToModel(FailureMechanismSectionsContext context, ReadResult readResults) + private bool IsTotalLengthOfSectionsTooDifferentFromReferenceLineLength(ReferenceLine referenceLine, ICollection mechanismSections) { - IEnumerable snappedSections = SnapReadSectionsToReferenceLine(readResults.ImportedItems, context.ParentAssessmentSection.ReferenceLine); - context.ParentFailureMechanism.ClearAllSections(); + var totalSectionsLength = mechanismSections.Sum(s => GetSectionLength(s)); + var referenceLineLength = GetLengthOfLine(referenceLine.Points); + return Math.Abs(totalSectionsLength - referenceLineLength) > lengthDifferenceTolerance; + } + + private void AddImportedDataToModel(IEnumerable failureMechanismSections, IFailureMechanism failureMechanism, ReferenceLine referenceLine) + { + IEnumerable snappedSections = SnapReadSectionsToReferenceLine(failureMechanismSections, referenceLine); + + failureMechanism.ClearAllSections(); foreach (FailureMechanismSection section in snappedSections) { - context.ParentFailureMechanism.AddSection(section); + failureMechanism.AddSection(section); } } @@ -351,16 +362,6 @@ return orderedSectionLengths; } - private static List CreateFailureMechanismSectionsSnappedOnReferenceLine(IList orderedReadSections, Point2D[][] splitResults) - { - var snappedSections = new List(orderedReadSections.Count); - for (int i = 0; i < orderedReadSections.Count; i++) - { - snappedSections.Add(new FailureMechanismSection(orderedReadSections[i].Name, splitResults[i])); - } - return snappedSections; - } - private double GetSectionLength(FailureMechanismSection section) { return GetLengthOfLine(section.Points); @@ -375,5 +376,15 @@ { return Math2D.ConvertLinePointsToLineSegments(linePoints); } + + private static List CreateFailureMechanismSectionsSnappedOnReferenceLine(IList orderedReadSections, Point2D[][] splitResults) + { + var snappedSections = new List(orderedReadSections.Count); + for (int i = 0; i < orderedReadSections.Count; i++) + { + snappedSections.Add(new FailureMechanismSection(orderedReadSections[i].Name, splitResults[i])); + } + return snappedSections; + } } } \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/FileImporters/ReferenceLineImporter.cs =================================================================== diff -u -rc9f9c04e4fc62406231afd07d63cd7da11673ec6 -re04155c0cc0efa8bbd13e0a82cb8643711a2dfd6 --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/FileImporters/ReferenceLineImporter.cs (.../ReferenceLineImporter.cs) (revision c9f9c04e4fc62406231afd07d63cd7da11673ec6) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/FileImporters/ReferenceLineImporter.cs (.../ReferenceLineImporter.cs) (revision e04155c0cc0efa8bbd13e0a82cb8643711a2dfd6) @@ -48,7 +48,7 @@ /// Imports a and stores in on a , /// taking data from a shapefile containing a single polyline. /// - public class ReferenceLineImporter : FileImporterBase + public class ReferenceLineImporter : FileImporterBase { private static readonly ILog log = LogManager.GetLogger(typeof(ReferenceLineImporter)); @@ -78,14 +78,6 @@ } } - public override Type SupportedItemType - { - get - { - return typeof(ReferenceLineContext); - } - } - public override string FileFilter { get Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.Designer.cs =================================================================== diff -u -r2f01022374461fa646d0d4185ca5c248c330de7e -re04155c0cc0efa8bbd13e0a82cb8643711a2dfd6 --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 2f01022374461fa646d0d4185ca5c248c330de7e) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision e04155c0cc0efa8bbd13e0a82cb8643711a2dfd6) @@ -80,7 +80,7 @@ } /// - /// Looks up a localized string similar to Vakkenindeling komt niet overeen met de huidige referentielijn.. + /// Looks up a localized string similar to Vakindeling komt niet overeen met de huidige referentielijn.. /// public static string FailureMechanismSectionsImporter_Import_Imported_sections_do_not_correspond_to_current_referenceline { get { @@ -99,7 +99,7 @@ } /// - /// Looks up a localized string similar to Er is geen referentielijn beschikbaar om een vakindeling voor de definiëren.. + /// Looks up a localized string similar to Er is geen referentielijn beschikbaar om een vakindeling voor te definiëren.. /// public static string FailureMechanismSectionsImporter_Import_Required_referenceline_missing { get { Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.resx =================================================================== diff -u -r2f01022374461fa646d0d4185ca5c248c330de7e -re04155c0cc0efa8bbd13e0a82cb8643711a2dfd6 --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.resx (.../Resources.resx) (revision 2f01022374461fa646d0d4185ca5c248c330de7e) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.resx (.../Resources.resx) (revision e04155c0cc0efa8bbd13e0a82cb8643711a2dfd6) @@ -158,13 +158,13 @@ Er is geen referentielijn beschikbaar om een vakindeling voor de definiëren. - Er is geen referentielijn beschikbaar om een vakindeling voor de definiëren. + Er is geen referentielijn beschikbaar om een vakindeling voor te definiëren. Het bestand heeft geen vakindeling. - Vakkenindeling komt niet overeen met de huidige referentielijn. + Vakindeling komt niet overeen met de huidige referentielijn. Vakindeling importeren afgebroken. Geen data ingelezen. Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/FileImporters/FailureMechanismSectionsImporterTest.cs =================================================================== diff -u -r97fb97c5677e2afbd1675ba0fb3e989028a65d09 -re04155c0cc0efa8bbd13e0a82cb8643711a2dfd6 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/FileImporters/FailureMechanismSectionsImporterTest.cs (.../FailureMechanismSectionsImporterTest.cs) (revision 97fb97c5677e2afbd1675ba0fb3e989028a65d09) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/FileImporters/FailureMechanismSectionsImporterTest.cs (.../FailureMechanismSectionsImporterTest.cs) (revision e04155c0cc0efa8bbd13e0a82cb8643711a2dfd6) @@ -32,11 +32,10 @@ var importer = new FailureMechanismSectionsImporter(); // Assert - Assert.IsInstanceOf(importer); + Assert.IsInstanceOf>(importer); Assert.AreEqual("Vakindeling", importer.Name); Assert.AreEqual("Algemeen", importer.Category); TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.Sections, importer.Image); - Assert.AreEqual(typeof(FailureMechanismSectionsContext), importer.SupportedItemType); Assert.AreEqual("Vakindeling shapefile (*.shp)|*.shp", importer.FileFilter); } @@ -106,10 +105,10 @@ var failureMechanismSectionsContext = new FailureMechanismSectionsContext(failureMechanism, assessmentSection); // Call - var importSuccesful = importer.Import(failureMechanismSectionsContext, sectionsFilePath); + var importSuccessful = importer.Import(failureMechanismSectionsContext, sectionsFilePath); // Assert - Assert.IsTrue(importSuccesful); + Assert.IsTrue(importSuccessful); FailureMechanismSection[] sections = failureMechanism.Sections.ToArray(); Assert.AreEqual(62, sections.Length); @@ -140,10 +139,10 @@ var failureMechanismSectionsContext = new FailureMechanismSectionsContext(failureMechanism, assessmentSection); // Call - var importSuccesful = importer.Import(failureMechanismSectionsContext, sectionsFilePath); + var importSuccessful = importer.Import(failureMechanismSectionsContext, sectionsFilePath); // Assert - Assert.IsTrue(importSuccesful); + Assert.IsTrue(importSuccessful); FailureMechanismSection[] sections = failureMechanism.Sections.ToArray(); Assert.AreEqual(62, sections.Length); @@ -173,10 +172,10 @@ var failureMechanismSectionsContext = new FailureMechanismSectionsContext(failureMechanism, assessmentSection); // Call - var importSuccesful = importer.Import(failureMechanismSectionsContext, sectionsFilePath); + var importSuccessful = importer.Import(failureMechanismSectionsContext, sectionsFilePath); // Assert - Assert.IsTrue(importSuccesful); + Assert.IsTrue(importSuccessful); FailureMechanismSection[] sections = failureMechanism.Sections.ToArray(); Assert.AreEqual(7, sections.Length); @@ -214,10 +213,10 @@ var failureMechanismSectionsContext = new FailureMechanismSectionsContext(failureMechanism, assessmentSection); // Call - var importSuccesful = importer.Import(failureMechanismSectionsContext, sectionsFilePath); + var importSuccessful = importer.Import(failureMechanismSectionsContext, sectionsFilePath); // Assert - Assert.IsTrue(importSuccesful); + Assert.IsTrue(importSuccessful); var expectedProgressMessages = new[] { new ProgressNotification("Inlezen vakindeling.", 1, 3), @@ -258,21 +257,21 @@ var failureMechanismSectionsContext = new FailureMechanismSectionsContext(failureMechanism, assessmentSection); // Call - bool importSuccesful = true; - Action call = () => importSuccesful = importer.Import(failureMechanismSectionsContext, sectionsFilePath); + bool importSuccessful = true; + Action call = () => importSuccessful = importer.Import(failureMechanismSectionsContext, sectionsFilePath); // Assert var expectedMessage = string.Format(@"Fout bij het lezen van bestand '{0}': Bestandspad mag niet naar een map verwijzen.", sectionsFilePath) + Environment.NewLine + "Er is geen vakindeling geïmporteerd."; TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1); - Assert.IsFalse(importSuccesful); + Assert.IsFalse(importSuccessful); CollectionAssert.IsEmpty(failureMechanism.Sections); CollectionAssert.IsEmpty(failureMechanismSectionsContext.WrappedData); mocks.VerifyAll(); } [Test] - public void Import_PathToDirectory_CancelImportWithErrorMessage() + public void Import_FileDoesNotExist_CancelImportWithErrorMessage() { // Setup var referenceLineFilePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, "traject_1-1.shp"); @@ -293,14 +292,14 @@ var failureMechanismSectionsContext = new FailureMechanismSectionsContext(failureMechanism, assessmentSection); // Call - bool importSuccesful = true; - Action call = () => importSuccesful = importer.Import(failureMechanismSectionsContext, sectionsFilePath); + bool importSuccessful = true; + Action call = () => importSuccessful = importer.Import(failureMechanismSectionsContext, sectionsFilePath); // Assert var expectedMessage = string.Format(@"Fout bij het lezen van bestand '{0}': Het bestand bestaat niet.", sectionsFilePath) + Environment.NewLine + "Er is geen vakindeling geïmporteerd."; TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1); - Assert.IsFalse(importSuccesful); + Assert.IsFalse(importSuccessful); CollectionAssert.IsEmpty(failureMechanism.Sections); CollectionAssert.IsEmpty(failureMechanismSectionsContext.WrappedData); mocks.VerifyAll(); @@ -323,14 +322,14 @@ var failureMechanismSectionsContext = new FailureMechanismSectionsContext(failureMechanism, assessmentSection); // Call - bool importSuccesful = true; - Action call = () => importSuccesful = importer.Import(failureMechanismSectionsContext, sectionsFilePath); + bool importSuccessful = true; + Action call = () => importSuccessful = importer.Import(failureMechanismSectionsContext, sectionsFilePath); // Assert - var expectedMessage = "Er is geen referentielijn beschikbaar om een vakindeling voor de definiëren." + Environment.NewLine + - "Er is geen vakindeling geïmporteerd."; + var expectedMessage = "Er is geen referentielijn beschikbaar om een vakindeling voor te definiëren." + Environment.NewLine + + "Er is geen vakindeling geïmporteerd."; TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1); - Assert.IsFalse(importSuccesful); + Assert.IsFalse(importSuccessful); CollectionAssert.IsEmpty(failureMechanism.Sections); CollectionAssert.IsEmpty(failureMechanismSectionsContext.WrappedData); mocks.VerifyAll(); @@ -358,14 +357,14 @@ var failureMechanismSectionsContext = new FailureMechanismSectionsContext(failureMechanism, assessmentSection); // Call - bool importSuccesful = true; - Action call = () => importSuccesful = importer.Import(failureMechanismSectionsContext, sectionsFilePath); + bool importSuccessful = true; + Action call = () => importSuccessful = importer.Import(failureMechanismSectionsContext, sectionsFilePath); // Assert var expectedMessage = "Het bestand heeft geen vakindeling." + Environment.NewLine + "Er is geen vakindeling geïmporteerd."; TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1); - Assert.IsFalse(importSuccesful); + Assert.IsFalse(importSuccessful); CollectionAssert.IsEmpty(failureMechanism.Sections); CollectionAssert.IsEmpty(failureMechanismSectionsContext.WrappedData); mocks.VerifyAll(); @@ -395,14 +394,14 @@ var failureMechanismSectionsContext = new FailureMechanismSectionsContext(failureMechanism, assessmentSection); // Call - bool importSuccesful = true; - Action call = () => importSuccesful = importer.Import(failureMechanismSectionsContext, sectionsFilePath); + bool importSuccessful = true; + Action call = () => importSuccessful = importer.Import(failureMechanismSectionsContext, sectionsFilePath); // Assert - var expectedMessage = "Vakkenindeling komt niet overeen met de huidige referentielijn." + Environment.NewLine + + var expectedMessage = "Vakindeling komt niet overeen met de huidige referentielijn." + Environment.NewLine + "Er is geen vakindeling geïmporteerd."; TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1); - Assert.IsFalse(importSuccesful); + Assert.IsFalse(importSuccessful); CollectionAssert.IsEmpty(failureMechanism.Sections); CollectionAssert.IsEmpty(failureMechanismSectionsContext.WrappedData); mocks.VerifyAll(); @@ -432,14 +431,14 @@ var failureMechanismSectionsContext = new FailureMechanismSectionsContext(failureMechanism, assessmentSection); // Call - bool importSuccesful = true; - Action call = () => importSuccesful = importer.Import(failureMechanismSectionsContext, sectionsFilePath); + bool importSuccessful = true; + Action call = () => importSuccessful = importer.Import(failureMechanismSectionsContext, sectionsFilePath); // Assert - var expectedMessage = "Vakkenindeling komt niet overeen met de huidige referentielijn." + Environment.NewLine + + var expectedMessage = "Vakindeling komt niet overeen met de huidige referentielijn." + Environment.NewLine + "Er is geen vakindeling geïmporteerd."; TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1); - Assert.IsFalse(importSuccesful); + Assert.IsFalse(importSuccessful); CollectionAssert.IsEmpty(failureMechanism.Sections); CollectionAssert.IsEmpty(failureMechanismSectionsContext.WrappedData); mocks.VerifyAll(); @@ -467,14 +466,14 @@ var failureMechanismSectionsContext = new FailureMechanismSectionsContext(failureMechanism, assessmentSection); // Call - bool importSuccesful = true; - Action call = () => importSuccesful = importer.Import(failureMechanismSectionsContext, sectionsFilePath); + bool importSuccessful = true; + Action call = () => importSuccessful = importer.Import(failureMechanismSectionsContext, sectionsFilePath); // Assert - var expectedMessage = "Vakkenindeling komt niet overeen met de huidige referentielijn." + Environment.NewLine + + var expectedMessage = "Vakindeling komt niet overeen met de huidige referentielijn." + Environment.NewLine + "Er is geen vakindeling geïmporteerd."; TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1); - Assert.IsFalse(importSuccesful); + Assert.IsFalse(importSuccessful); CollectionAssert.IsEmpty(failureMechanism.Sections); CollectionAssert.IsEmpty(failureMechanismSectionsContext.WrappedData); mocks.VerifyAll(); @@ -502,14 +501,14 @@ var failureMechanismSectionsContext = new FailureMechanismSectionsContext(failureMechanism, assessmentSection); // Call - bool importSuccesful = true; - Action call = () => importSuccesful = importer.Import(failureMechanismSectionsContext, sectionsFilePath); + bool importSuccessful = true; + Action call = () => importSuccessful = importer.Import(failureMechanismSectionsContext, sectionsFilePath); // Assert - var expectedMessage = "Vakkenindeling komt niet overeen met de huidige referentielijn." + Environment.NewLine + + var expectedMessage = "Vakindeling komt niet overeen met de huidige referentielijn." + Environment.NewLine + "Er is geen vakindeling geïmporteerd."; TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1); - Assert.IsFalse(importSuccesful); + Assert.IsFalse(importSuccessful); CollectionAssert.IsEmpty(failureMechanism.Sections); CollectionAssert.IsEmpty(failureMechanismSectionsContext.WrappedData); mocks.VerifyAll(); @@ -540,10 +539,10 @@ Assert.IsFalse(importer.Import(failureMechanismSectionsContext, sectionsFilePath)); // Call - var importSuccesful = importer.Import(failureMechanismSectionsContext, sectionsFilePath); + var importSuccessful = importer.Import(failureMechanismSectionsContext, sectionsFilePath); // Assert - Assert.IsTrue(importSuccesful); + Assert.IsTrue(importSuccessful); FailureMechanismSection[] sections = failureMechanism.Sections.ToArray(); Assert.AreEqual(62, sections.Length); Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/FileImporters/ReferenceLineImporterTest.cs =================================================================== diff -u -rc6a3cd9e25138d35bf0881f3ff6df9dfe1776fd2 -re04155c0cc0efa8bbd13e0a82cb8643711a2dfd6 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/FileImporters/ReferenceLineImporterTest.cs (.../ReferenceLineImporterTest.cs) (revision c6a3cd9e25138d35bf0881f3ff6df9dfe1776fd2) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/FileImporters/ReferenceLineImporterTest.cs (.../ReferenceLineImporterTest.cs) (revision e04155c0cc0efa8bbd13e0a82cb8643711a2dfd6) @@ -30,11 +30,10 @@ var importer = new ReferenceLineImporter(); // Assert - Assert.IsInstanceOf(importer); + Assert.IsInstanceOf>(importer); Assert.AreEqual("Referentielijn", importer.Name); Assert.AreEqual("Algemeen", importer.Category); TestHelper.AssertImagesAreEqual(RingtoetsIntegrationFormsResources.ReferenceLineIcon, importer.Image); - Assert.AreEqual(typeof(ReferenceLineContext), importer.SupportedItemType); Assert.AreEqual("Referentielijn shapefile (*.shp)|*.shp", importer.FileFilter); } Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSoilProfilesImporter.cs =================================================================== diff -u -r925d8a1d7dec6ef95d89b2ff67d78c8d5a49387f -re04155c0cc0efa8bbd13e0a82cb8643711a2dfd6 --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSoilProfilesImporter.cs (.../PipingSoilProfilesImporter.cs) (revision 925d8a1d7dec6ef95d89b2ff67d78c8d5a49387f) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSoilProfilesImporter.cs (.../PipingSoilProfilesImporter.cs) (revision e04155c0cc0efa8bbd13e0a82cb8643711a2dfd6) @@ -39,7 +39,7 @@ /// /// Imports .soil files (SqlLite database files) created with the DSoilModel application. /// - public class PipingSoilProfilesImporter : FileImporterBase + public class PipingSoilProfilesImporter : FileImporterBase> { private readonly ILog log = LogManager.GetLogger(typeof(PipingSoilProfilesImporter)); @@ -67,14 +67,6 @@ } } - public override Type SupportedItemType - { - get - { - return typeof(ICollection); - } - } - public override string FileFilter { get Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSurfaceLinesCsvImporter.cs =================================================================== diff -u -r8ce3b440d8918b0c4756781eb417e202ad631854 -re04155c0cc0efa8bbd13e0a82cb8643711a2dfd6 --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSurfaceLinesCsvImporter.cs (.../PipingSurfaceLinesCsvImporter.cs) (revision 8ce3b440d8918b0c4756781eb417e202ad631854) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSurfaceLinesCsvImporter.cs (.../PipingSurfaceLinesCsvImporter.cs) (revision e04155c0cc0efa8bbd13e0a82cb8643711a2dfd6) @@ -44,7 +44,7 @@ /// Id;X1;Y1;Z1;...(Xn;Yn;Zn) /// Where Xn;Yn;Zn form the n-th 3D point describing the geometry of the surface line. /// - 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);