Index: Core/Plugins/test/Core.Plugins.Map.Test/UITypeEditors/SelectableMetaDataAttributeTest.cs
===================================================================
diff -u -r8905298103eb01ce13dd5c1a2f267f879d4fda3e -r583456a0f5395189a54a8cedf4e4a7b40945d990
--- Core/Plugins/test/Core.Plugins.Map.Test/UITypeEditors/SelectableMetaDataAttributeTest.cs (.../SelectableMetaDataAttributeTest.cs) (revision 8905298103eb01ce13dd5c1a2f267f879d4fda3e)
+++ Core/Plugins/test/Core.Plugins.Map.Test/UITypeEditors/SelectableMetaDataAttributeTest.cs (.../SelectableMetaDataAttributeTest.cs) (revision 583456a0f5395189a54a8cedf4e4a7b40945d990)
@@ -147,24 +147,6 @@
}
[Test]
- public void GetHashCode_NotEqualObjects_ReturnDifferentHashCode()
- {
- // Setup
- var selectableAttribute1 = new SelectableMetaDataAttribute("Test");
- var selectableAttribute2 = new SelectableMetaDataAttribute("Test2");
-
- // Pre-condition
- Assert.IsFalse(selectableAttribute1.Equals(selectableAttribute2));
-
- // Call
- int hashCode1 = selectableAttribute1.GetHashCode();
- int hashCode2 = selectableAttribute2.GetHashCode();
-
- // Assert
- Assert.AreNotEqual(hashCode1, hashCode2);
- }
-
- [Test]
public void ToString_Always_ReturnMetaDataAttribute()
{
// Setup
Index: Ringtoets/Common/src/Ringtoets.Common.IO/IConfirmDataChangeHandler.cs
===================================================================
diff -u -r26da131fa5dbcf95f9a16de6f81eb4acc8d1be14 -r583456a0f5395189a54a8cedf4e4a7b40945d990
--- Ringtoets/Common/src/Ringtoets.Common.IO/IConfirmDataChangeHandler.cs (.../IConfirmDataChangeHandler.cs) (revision 26da131fa5dbcf95f9a16de6f81eb4acc8d1be14)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/IConfirmDataChangeHandler.cs (.../IConfirmDataChangeHandler.cs) (revision 583456a0f5395189a54a8cedf4e4a7b40945d990)
@@ -30,13 +30,13 @@
/// Verifies whether the change to the data has side-effects;
/// and therefore a confirmation is required.
///
- /// True if confirmation is required, False otherwise.
+ /// true if confirmation is required, false otherwise.
bool RequireConfirmation();
///
/// Inquires for a confirmation on whether changing the data should be continued.
///
- /// True if confirmation is given; False otherwise.
+ /// true if confirmation is given; false otherwise.
/// Should only be called when returns true.
///
bool InquireConfirmation();
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/SelectableHydraulicBoundaryLocationTest.cs
===================================================================
diff -u -re9a40c653a63e31757bf87930745200f9c22cb2e -r583456a0f5395189a54a8cedf4e4a7b40945d990
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/SelectableHydraulicBoundaryLocationTest.cs (.../SelectableHydraulicBoundaryLocationTest.cs) (revision e9a40c653a63e31757bf87930745200f9c22cb2e)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/SelectableHydraulicBoundaryLocationTest.cs (.../SelectableHydraulicBoundaryLocationTest.cs) (revision 583456a0f5395189a54a8cedf4e4a7b40945d990)
@@ -211,28 +211,6 @@
}
[Test]
- [TestCaseSource(nameof(EqualityReferencePoints))]
- public void GetHashCode_NotEqualObjects_ReturnsDifferenHashCode(Point2D referencePoint1,
- Point2D referencePoint2)
- {
- // Setup
- var inputItem1 = new SelectableHydraulicBoundaryLocation(new HydraulicBoundaryLocation(1, "Name", 0, 1),
- referencePoint1);
- var inputItem2 = new SelectableHydraulicBoundaryLocation(new HydraulicBoundaryLocation(2, "Name", 0, 1),
- referencePoint2);
-
- // Pre-condition
- Assert.AreNotEqual(inputItem1, inputItem2);
-
- // Call
- int hashCodeItem1 = inputItem1.GetHashCode();
- int hashCodeItem2 = inputItem2.GetHashCode();
-
- // Assert
- Assert.AreNotEqual(hashCodeItem1, hashCodeItem2);
- }
-
- [Test]
[TestCaseSource(nameof(StringRepresentations))]
public void ToString_DifferentReferencePoints_ReturnsExpectedString(HydraulicBoundaryLocation location,
Point2D referencePoint, string expectedString)
@@ -289,9 +267,9 @@
var distance = location.Location.GetEuclideanDistanceTo(referencePoint);
- return distance/1000 < 1
+ return distance / 1000 < 1
? string.Format("{0} ({1:f0} m)", location.Name, distance)
- : string.Format("{0} ({1:f1} km)", location.Name, distance/1000);
+ : string.Format("{0} ({1:f1} km)", location.Name, distance / 1000);
}
}
}
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/RingtoetsPipingSurfaceLineUpdateDataStrategy.cs
===================================================================
diff -u
--- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/RingtoetsPipingSurfaceLineUpdateDataStrategy.cs (revision 0)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/RingtoetsPipingSurfaceLineUpdateDataStrategy.cs (revision 583456a0f5395189a54a8cedf4e4a7b40945d990)
@@ -0,0 +1,167 @@
+// 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.Collections.Generic;
+using System.Linq;
+using Core.Common.Base;
+using Ringtoets.Common.Data.UpdateDataStrategies;
+using Ringtoets.Common.Service;
+using Ringtoets.Piping.Data;
+using Ringtoets.Piping.Forms;
+using Ringtoets.Piping.IO.Exceptions;
+using Ringtoets.Piping.IO.Importers;
+using Ringtoets.Piping.Plugin.Properties;
+using Ringtoets.Piping.Primitives;
+using Ringtoets.Piping.Service;
+
+namespace Ringtoets.Piping.Plugin.FileImporter
+{
+ ///
+ /// An for updating surface lines based on imported data.
+ ///
+ public class RingtoetsPipingSurfaceLineUpdateDataStrategy : UpdateDataStrategyBase,
+ ISurfaceLineUpdateDataStrategy
+ {
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The failure mechanism in which the surface lines are updated.
+ /// Thrown when is null.
+ public RingtoetsPipingSurfaceLineUpdateDataStrategy(PipingFailureMechanism failureMechanism)
+ : base(failureMechanism, new RingtoetsPipingSurfaceLineNameEqualityComparer()) {}
+
+ public IEnumerable UpdateSurfaceLinesWithImportedData(RingtoetsPipingSurfaceLineCollection targetCollection,
+ IEnumerable readRingtoetsPipingSurfaceLines,
+ string sourceFilePath)
+ {
+ try
+ {
+ return UpdateTargetCollectionData(targetCollection, readRingtoetsPipingSurfaceLines, sourceFilePath);
+ }
+ catch (ArgumentNullException)
+ {
+ throw;
+ }
+ catch (ArgumentException e)
+ {
+ throw new RingtoetsPipingSurfaceLineUpdateException(e.Message, e);
+ }
+ catch (InvalidOperationException e)
+ {
+ string message = Resources.RingtoetsPipingSurfaceLineUpdateDataStrategy_UpdateSurfaceLinesWithImportedData_Update_of_RingtoetsPipingSurfaceLine_has_failed;
+ throw new RingtoetsPipingSurfaceLineUpdateException(message, e);
+ }
+ }
+
+ ///
+ /// Class for comparing by only the name.
+ ///
+ private class RingtoetsPipingSurfaceLineNameEqualityComparer : IEqualityComparer
+ {
+ public bool Equals(RingtoetsPipingSurfaceLine x, RingtoetsPipingSurfaceLine y)
+ {
+ return x.Name == y.Name;
+ }
+
+ public int GetHashCode(RingtoetsPipingSurfaceLine obj)
+ {
+ return obj.Name.GetHashCode();
+ }
+ }
+
+ #region Updating Data Functions
+
+ protected override IEnumerable UpdateObjectAndDependentData(RingtoetsPipingSurfaceLine surfaceLineToUpdate,
+ RingtoetsPipingSurfaceLine matchingSurfaceLine)
+ {
+ var affectedObjects = new List();
+
+ if (!surfaceLineToUpdate.Equals(matchingSurfaceLine))
+ {
+ surfaceLineToUpdate.Update(matchingSurfaceLine);
+
+ affectedObjects.AddRange(UpdateSurfaceLineDependentData(surfaceLineToUpdate));
+ affectedObjects.AddRange(UpdateStochasticSoilModel(surfaceLineToUpdate));
+ }
+
+ return affectedObjects;
+ }
+
+ private IEnumerable UpdateSurfaceLineDependentData(RingtoetsPipingSurfaceLine surfaceLine)
+ {
+ IEnumerable affectedCalculations = GetAffectedCalculationWithSurfaceLine(surfaceLine);
+
+ var affectedObjects = new List
+ {
+ surfaceLine
+ };
+ foreach (PipingCalculation affectedCalculation in affectedCalculations)
+ {
+ affectedObjects.AddRange(RingtoetsCommonDataSynchronizationService.ClearCalculationOutput(affectedCalculation));
+ }
+ return affectedObjects;
+ }
+
+ private IEnumerable UpdateStochasticSoilModel(RingtoetsPipingSurfaceLine updatedSurfaceLine)
+ {
+ IEnumerable calculationsToUpdate = GetAffectedCalculationWithSurfaceLine(updatedSurfaceLine);
+
+ var affectedObjects = new List();
+ foreach (PipingCalculation calculation in calculationsToUpdate)
+ {
+ IEnumerable matchingSoilModels = GetAvailableStochasticSoilModels(updatedSurfaceLine);
+
+ PipingInput calculationInput = calculation.InputParameters;
+ PipingInputService.SetMatchingStochasticSoilModel(calculationInput, matchingSoilModels);
+ affectedObjects.Add(calculationInput);
+ }
+
+ return affectedObjects;
+ }
+
+ private IEnumerable GetAffectedCalculationWithSurfaceLine(RingtoetsPipingSurfaceLine surfaceLine)
+ {
+ IEnumerable affectedCalculations =
+ failureMechanism.Calculations
+ .Cast()
+ .Where(calc => ReferenceEquals(calc.InputParameters.SurfaceLine, surfaceLine));
+ return affectedCalculations;
+ }
+
+ private IEnumerable GetAvailableStochasticSoilModels(RingtoetsPipingSurfaceLine surfaceLine)
+ {
+ return PipingCalculationConfigurationHelper.GetStochasticSoilModelsForSurfaceLine(surfaceLine,
+ failureMechanism.StochasticSoilModels);
+ }
+
+ #endregion
+
+ #region Removing Data Functions
+
+ protected override IEnumerable RemoveObjectAndDependentData(RingtoetsPipingSurfaceLine removedSurfaceLine)
+ {
+ return PipingDataSynchronizationService.RemoveSurfaceLine(failureMechanism, removedSurfaceLine);
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Fisheye: Tag 583456a0f5395189a54a8cedf4e4a7b40945d990 refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/RingtoetsPipingSurfaceLineUpdateStrategy.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Ringtoets.Piping.Plugin.csproj
===================================================================
diff -u -r26da131fa5dbcf95f9a16de6f81eb4acc8d1be14 -r583456a0f5395189a54a8cedf4e4a7b40945d990
--- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Ringtoets.Piping.Plugin.csproj (.../Ringtoets.Piping.Plugin.csproj) (revision 26da131fa5dbcf95f9a16de6f81eb4acc8d1be14)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Ringtoets.Piping.Plugin.csproj (.../Ringtoets.Piping.Plugin.csproj) (revision 583456a0f5395189a54a8cedf4e4a7b40945d990)
@@ -61,7 +61,7 @@
-
+
Index: Ringtoets/Piping/src/Ringtoets.Piping.Primitives/RingtoetsPipingSurfaceLine.cs
===================================================================
diff -u -re9a40c653a63e31757bf87930745200f9c22cb2e -r583456a0f5395189a54a8cedf4e4a7b40945d990
--- Ringtoets/Piping/src/Ringtoets.Piping.Primitives/RingtoetsPipingSurfaceLine.cs (.../RingtoetsPipingSurfaceLine.cs) (revision e9a40c653a63e31757bf87930745200f9c22cb2e)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Primitives/RingtoetsPipingSurfaceLine.cs (.../RingtoetsPipingSurfaceLine.cs) (revision 583456a0f5395189a54a8cedf4e4a7b40945d990)
@@ -415,14 +415,12 @@
return false;
}
- int i = 0;
- foreach (Point3D point in Points)
+ for (var index = 0; index < Points.Length; index++)
{
- if (!point.Equals(otherPoints[i]))
+ if (!Points[index].Equals(otherPoints[index]))
{
return false;
}
- i++;
}
return true;
}
Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/RingtoetsPipingSurfaceLineTest.cs
===================================================================
diff -u -r26da131fa5dbcf95f9a16de6f81eb4acc8d1be14 -r583456a0f5395189a54a8cedf4e4a7b40945d990
--- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/RingtoetsPipingSurfaceLineTest.cs (.../RingtoetsPipingSurfaceLineTest.cs) (revision 26da131fa5dbcf95f9a16de6f81eb4acc8d1be14)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/RingtoetsPipingSurfaceLineTest.cs (.../RingtoetsPipingSurfaceLineTest.cs) (revision 583456a0f5395189a54a8cedf4e4a7b40945d990)
@@ -990,36 +990,6 @@
Assert.AreEqual(hashCodeOne, hashCodeTwo);
}
- [Test]
- public void GetHashCode_DifferentSurfaceLines_ReturnDifferentHashCode()
- {
- // Setup
- var surfaceLineOne = new RingtoetsPipingSurfaceLine
- {
- Name = "Name A"
- };
- surfaceLineOne.SetGeometry(new[]
- {
- new Point3D(1, 2, 3)
- });
-
- var surfaceLineTwo = new RingtoetsPipingSurfaceLine
- {
- Name = "Name A"
- };
- surfaceLineTwo.SetGeometry(new[]
- {
- new Point3D(3, 4, 5)
- });
-
- // Call
- int hashCodeOne = surfaceLineOne.GetHashCode();
- int hashCodeTwo = surfaceLineTwo.GetHashCode();
-
- // Assert
- Assert.AreNotEqual(hashCodeOne, hashCodeTwo);
- }
-
private static void CreateTestGeometry(Point3D testPoint, RingtoetsPipingSurfaceLine surfaceLine)
{
var random = new Random(21);
Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/StochasticSoilProfileTest.cs
===================================================================
diff -u -r7172df944db7fd2d59d68a7a8def96110a44ed9b -r583456a0f5395189a54a8cedf4e4a7b40945d990
--- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/StochasticSoilProfileTest.cs (.../StochasticSoilProfileTest.cs) (revision 7172df944db7fd2d59d68a7a8def96110a44ed9b)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/StochasticSoilProfileTest.cs (.../StochasticSoilProfileTest.cs) (revision 583456a0f5395189a54a8cedf4e4a7b40945d990)
@@ -196,6 +196,21 @@
}
[Test]
+ public void GetHashCode_EqualStochasticSoilProfile_ReturnSameHashCode()
+ {
+ // Setup
+ var stochasticSoilProfileA = new StochasticSoilProfile(0.2, SoilProfileType.SoilProfile1D, 234);
+ var stochasticSoilProfileB = new StochasticSoilProfile(0.2, SoilProfileType.SoilProfile1D, 234);
+
+ // Call
+ int hashCodeOne = stochasticSoilProfileA.GetHashCode();
+ int hashCodeTwo = stochasticSoilProfileB.GetHashCode();
+
+ // Assert
+ Assert.AreEqual(hashCodeOne, hashCodeTwo);
+ }
+
+ [Test]
public void ToString_WithNullName_ReturnsStringEmpty()
{
// Setup
Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ImportInfos/RingtoetsPipingSurfaceLinesContextImportInfoTest.cs
===================================================================
diff -u -r110999cffbcac705d99ff96033e9eabb0e0b5e12 -r583456a0f5395189a54a8cedf4e4a7b40945d990
--- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ImportInfos/RingtoetsPipingSurfaceLinesContextImportInfoTest.cs (.../RingtoetsPipingSurfaceLinesContextImportInfoTest.cs) (revision 110999cffbcac705d99ff96033e9eabb0e0b5e12)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ImportInfos/RingtoetsPipingSurfaceLinesContextImportInfoTest.cs (.../RingtoetsPipingSurfaceLinesContextImportInfoTest.cs) (revision 583456a0f5395189a54a8cedf4e4a7b40945d990)
@@ -169,7 +169,7 @@
}
[Test]
- public void CreateFileImporter_Always_ReturnFileImporter()
+ public void CreateFileImporter_ValidInput_ReturnFileImporter()
{
// Setup
var mocks = new MockRepository();
Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/UpdateInfos/RingtoetsPipingSurfaceLinesContextUpdateInfoTest.cs
===================================================================
diff -u -r110999cffbcac705d99ff96033e9eabb0e0b5e12 -r583456a0f5395189a54a8cedf4e4a7b40945d990
--- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/UpdateInfos/RingtoetsPipingSurfaceLinesContextUpdateInfoTest.cs (.../RingtoetsPipingSurfaceLinesContextUpdateInfoTest.cs) (revision 110999cffbcac705d99ff96033e9eabb0e0b5e12)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/UpdateInfos/RingtoetsPipingSurfaceLinesContextUpdateInfoTest.cs (.../RingtoetsPipingSurfaceLinesContextUpdateInfoTest.cs) (revision 583456a0f5395189a54a8cedf4e4a7b40945d990)
@@ -198,7 +198,7 @@
}
[Test]
- public void CreateFileImporter_Always_ReturnFileImporter()
+ public void CreateFileImporter_ValidInput_ReturnFileImporter()
{
// Setup
var mocks = new MockRepository();