Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/FileImporters/ClosingStructureUpdateDataStrategy.cs
===================================================================
diff -u -re3ec5f4669022733a11c4c3070747331bf36056f -r72c1ce6bda4b00156c3f07cf69cb0377825dcb5e
--- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/FileImporters/ClosingStructureUpdateDataStrategy.cs (.../ClosingStructureUpdateDataStrategy.cs) (revision e3ec5f4669022733a11c4c3070747331bf36056f)
+++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/FileImporters/ClosingStructureUpdateDataStrategy.cs (.../ClosingStructureUpdateDataStrategy.cs) (revision 72c1ce6bda4b00156c3f07cf69cb0377825dcb5e)
@@ -27,6 +27,7 @@
using Ringtoets.Common.Data;
using Ringtoets.Common.Data.Structures;
using Ringtoets.Common.Data.UpdateDataStrategies;
+using Ringtoets.Common.Forms;
using Ringtoets.Common.IO.Structures;
using Ringtoets.Common.Service;
using Ringtoets.Common.Utils;
@@ -64,22 +65,6 @@
FailureMechanism.SectionResults);
}
- ///
- /// Class for comparing by only the id.
- ///
- private class StructureIdEqualityComparer : IEqualityComparer
- {
- public bool Equals(ClosingStructure x, ClosingStructure y)
- {
- return x.Id.Equals(y.Id);
- }
-
- public int GetHashCode(ClosingStructure obj)
- {
- return obj.Id.GetHashCode();
- }
- }
-
#region Updating Data Functions
protected override IEnumerable UpdateObjectAndDependentData(ClosingStructure objectToUpdate,
@@ -94,11 +79,8 @@
{
var affectedObjects = new List();
- foreach (StructuresCalculation affectedCalculation in GetAffectedCalculationsWithClosingStructure(structure))
- {
- affectedObjects.Add(affectedCalculation.InputParameters);
- affectedObjects.AddRange(RingtoetsCommonDataSynchronizationService.ClearCalculationOutput(affectedCalculation));
- }
+ affectedObjects.AddRange(GetAffectedCalculationsWithClosingStructure(structure)
+ .Select(affectedCalculation => affectedCalculation.InputParameters));
affectedObjects.AddRange(StructuresHelper.UpdateCalculationToSectionResultAssignments(
FailureMechanism.SectionResults,
Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/FileImporters/ClosingStructureUpdateDataStrategyTest.cs
===================================================================
diff -u -r922d8c8ebb07e20fb0fe567d65f7d2df2bd224c1 -r72c1ce6bda4b00156c3f07cf69cb0377825dcb5e
--- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/FileImporters/ClosingStructureUpdateDataStrategyTest.cs (.../ClosingStructureUpdateDataStrategyTest.cs) (revision 922d8c8ebb07e20fb0fe567d65f7d2df2bd224c1)
+++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/FileImporters/ClosingStructureUpdateDataStrategyTest.cs (.../ClosingStructureUpdateDataStrategyTest.cs) (revision 72c1ce6bda4b00156c3f07cf69cb0377825dcb5e)
@@ -261,7 +261,7 @@
}
[Test]
- public void UpdateStructuresWithImportedData_CalculationWithStructureImportedStructureWithSameId_UpdatesCalculation()
+ public void UpdateStructuresWithImportedData_CalculationWithStructureImportedStructureWithSameId_UpdatesCalculationInput()
{
// Setup
const string sameId = "sameId";
@@ -302,19 +302,18 @@
sourceFilePath);
// Assert
- Assert.IsFalse(calculation.HasOutput);
+ Assert.IsTrue(calculation.HasOutput);
AssertClosingStructures(readStructure, structure);
CollectionAssert.AreEqual(new IObservable[]
{
failureMechanism.ClosingStructures,
structure,
- calculation.InputParameters,
- calculation
+ calculation.InputParameters
}, affectedObjects);
}
[Test]
- public void UpdateStructuresWithImportedData_MultipleCalculationWithAssignedStructure_OnlyUpdatesCalculationWithUpdatedStructure()
+ public void UpdateStructuresWithImportedData_MultipleCalculationWithAssignedStructure_OnlyUpdatesCalculationInputWithUpdatedStructure()
{
// Setup
const string affectedId = "affectedId";
@@ -372,7 +371,7 @@
readUnaffectedStructure
}, sourceFilePath);
// Assert
- Assert.IsFalse(affectedCalculation.HasOutput);
+ Assert.IsTrue(affectedCalculation.HasOutput);
ClosingStructure inputParametersAffectedStructure = affectedCalculation.InputParameters.Structure;
Assert.AreSame(affectedStructure, inputParametersAffectedStructure);
AssertClosingStructures(affectedStructure, inputParametersAffectedStructure);
@@ -385,14 +384,13 @@
CollectionAssert.AreEquivalent(new IObservable[]
{
affectedStructure,
- affectedCalculation,
affectedCalculation.InputParameters,
targetDataCollection
}, affectedObjects);
}
[Test]
- public void UpdateStructuresWithImportedData_CalculationWithSameReference_OnlyReturnsDistinctCalculation()
+ public void UpdateStructuresWithImportedData_CalculationWithSameReference_OnlyReturnsDistinctCalculationInput()
{
// Setup
const string affectedId = "affectedId";
@@ -439,13 +437,12 @@
{
structures,
affectedStructure,
- affectedCalculation,
affectedCalculation.InputParameters
}, affectedObjects);
}
[Test]
- public void UpdateStructuresWithImportedData_SectionResultWithStructureImportedStructureWithSameId_UpdatesCalculation()
+ public void UpdateStructuresWithImportedData_SectionResultWithStructureImportedStructureWithSameId_UpdatesCalculationInput()
{
// Setup
const string sameId = "sameId";
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj
===================================================================
diff -u -rada94ef2b6943fb9a2d8e59256871205a7d4c4ee -r72c1ce6bda4b00156c3f07cf69cb0377825dcb5e
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision ada94ef2b6943fb9a2d8e59256871205a7d4c4ee)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision 72c1ce6bda4b00156c3f07cf69cb0377825dcb5e)
@@ -116,6 +116,7 @@
Form
+
Form
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/StructureIdEqualityComparer.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.Forms/StructureIdEqualityComparer.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/StructureIdEqualityComparer.cs (revision 72c1ce6bda4b00156c3f07cf69cb0377825dcb5e)
@@ -0,0 +1,42 @@
+// Copyright (C) Stichting Deltares 2017. 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.Collections.Generic;
+using Ringtoets.Common.Data;
+
+namespace Ringtoets.Common.Forms
+{
+ ///
+ /// Class for comparing by the id only.
+ ///
+ public class StructureIdEqualityComparer : IEqualityComparer
+ {
+ public bool Equals(StructureBase x, StructureBase y)
+ {
+ return x.Id.Equals(y.Id);
+ }
+
+ public int GetHashCode(StructureBase obj)
+ {
+ return obj.Id.GetHashCode();
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj
===================================================================
diff -u -rb7c78a363e31e9911179086d4aa73561deb6b4d4 -r72c1ce6bda4b00156c3f07cf69cb0377825dcb5e
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision b7c78a363e31e9911179086d4aa73561deb6b4d4)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision 72c1ce6bda4b00156c3f07cf69cb0377825dcb5e)
@@ -105,6 +105,7 @@
+
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/StructureIdEqualityComparerTest.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/StructureIdEqualityComparerTest.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/StructureIdEqualityComparerTest.cs (revision 72c1ce6bda4b00156c3f07cf69cb0377825dcb5e)
@@ -0,0 +1,130 @@
+// Copyright (C) Stichting Deltares 2017. 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.Collections.Generic;
+using Core.Common.Base.Data;
+using Core.Common.Base.Geometry;
+using NUnit.Framework;
+using Ringtoets.Common.Data.TestUtil;
+
+namespace Ringtoets.Common.Forms.Test
+{
+ [TestFixture]
+ public class StructureIdEqualityComparerTest
+ {
+ private static IEnumerable SameIdDifferentProperties
+ {
+ get
+ {
+ var reference = new TestStructure();
+ yield return new TestCaseData(new TestStructure(reference.Id,
+ new Point2D(1, 1)));
+ yield return new TestCaseData(new TestStructure(reference.Id,
+ "different name"));
+ yield return new TestCaseData(new TestStructure(reference.Id,
+ reference.Name,
+ reference.Location,
+ RoundedDouble.NaN));
+ }
+ }
+
+ [Test]
+ public void Equals_SameInstance_ReturnTrue()
+ {
+ // Setup
+ var comparer = new StructureIdEqualityComparer();
+ var structure = new TestStructure();
+
+ // Call
+ bool areEqual = comparer.Equals(structure, structure);
+
+ // Assert
+ Assert.IsTrue(areEqual);
+ }
+
+ [Test]
+ public void Equals_OtherEqualInstance_ReturnTrue()
+ {
+ // Setup
+ var comparer = new StructureIdEqualityComparer();
+ var firstStructure = new TestStructure();
+ var secondStructure = new TestStructure();
+
+ // Call
+ bool firstEqualsSecond = comparer.Equals(firstStructure, secondStructure);
+ bool secondEqualsFirst = comparer.Equals(secondStructure, firstStructure);
+
+ // Assert
+ Assert.IsTrue(firstEqualsSecond);
+ Assert.IsTrue(secondEqualsFirst);
+ }
+
+ [Test]
+ [TestCaseSource(nameof(SameIdDifferentProperties))]
+ public void Equals_SameId_ReturnTrue(TestStructure secondStructure)
+ {
+ // Setup
+ var comparer = new StructureIdEqualityComparer();
+ var firstStructure = new TestStructure();
+
+ // Call
+ bool firstEqualsSecond = comparer.Equals(firstStructure, secondStructure);
+ bool secondEqualsFirst = comparer.Equals(secondStructure, firstStructure);
+
+ // Assert
+ Assert.IsTrue(firstEqualsSecond);
+ Assert.IsTrue(secondEqualsFirst);
+ }
+
+ [Test]
+ public void Equals_UnequalInstance_ReturnFalse()
+ {
+ // Setup
+ var comparer = new StructureIdEqualityComparer();
+ var firstStructure = new TestStructure("id");
+ var secondStructure = new TestStructure("other id");
+
+ // Call
+ bool firstEqualsSecond = comparer.Equals(firstStructure, secondStructure);
+ bool secondEqualsFirst = comparer.Equals(secondStructure, firstStructure);
+
+ // Assert
+ Assert.IsFalse(firstEqualsSecond);
+ Assert.IsFalse(secondEqualsFirst);
+ }
+
+ [Test]
+ public void GetHashCode_EqualStructures_ReturnsSameHashCode()
+ {
+ // Setup
+ var comparer = new StructureIdEqualityComparer();
+ var structureOne = new TestStructure();
+ var structureTwo = new TestStructure();
+
+ // Call
+ int hashCodeOne = comparer.GetHashCode(structureOne);
+ int hashCodeTwo = comparer.GetHashCode(structureTwo);
+
+ // Assert
+ Assert.AreEqual(hashCodeOne, hashCodeTwo);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/FileImporters/HeightStructureUpdateDataStrategy.cs
===================================================================
diff -u -rdf53f0268b7c15f000796a38436b2c40069b9b07 -r72c1ce6bda4b00156c3f07cf69cb0377825dcb5e
--- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/FileImporters/HeightStructureUpdateDataStrategy.cs (.../HeightStructureUpdateDataStrategy.cs) (revision df53f0268b7c15f000796a38436b2c40069b9b07)
+++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/FileImporters/HeightStructureUpdateDataStrategy.cs (.../HeightStructureUpdateDataStrategy.cs) (revision 72c1ce6bda4b00156c3f07cf69cb0377825dcb5e)
@@ -26,6 +26,7 @@
using Ringtoets.Common.Data;
using Ringtoets.Common.Data.Structures;
using Ringtoets.Common.Data.UpdateDataStrategies;
+using Ringtoets.Common.Forms;
using Ringtoets.Common.IO.Structures;
using Ringtoets.Common.Service;
using Ringtoets.Common.Utils;
Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/Ringtoets.HeightStructures.Plugin.csproj
===================================================================
diff -u -rdf53f0268b7c15f000796a38436b2c40069b9b07 -r72c1ce6bda4b00156c3f07cf69cb0377825dcb5e
--- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/Ringtoets.HeightStructures.Plugin.csproj (.../Ringtoets.HeightStructures.Plugin.csproj) (revision df53f0268b7c15f000796a38436b2c40069b9b07)
+++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/Ringtoets.HeightStructures.Plugin.csproj (.../Ringtoets.HeightStructures.Plugin.csproj) (revision 72c1ce6bda4b00156c3f07cf69cb0377825dcb5e)
@@ -45,7 +45,6 @@
-
Fisheye: Tag 72c1ce6bda4b00156c3f07cf69cb0377825dcb5e refers to a dead (removed) revision in file `Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/StructureIdEqualityComparer.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/Ringtoets.HeightStructures.Plugin.Test.csproj
===================================================================
diff -u -rdf53f0268b7c15f000796a38436b2c40069b9b07 -r72c1ce6bda4b00156c3f07cf69cb0377825dcb5e
--- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/Ringtoets.HeightStructures.Plugin.Test.csproj (.../Ringtoets.HeightStructures.Plugin.Test.csproj) (revision df53f0268b7c15f000796a38436b2c40069b9b07)
+++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/Ringtoets.HeightStructures.Plugin.Test.csproj (.../Ringtoets.HeightStructures.Plugin.Test.csproj) (revision 72c1ce6bda4b00156c3f07cf69cb0377825dcb5e)
@@ -67,7 +67,6 @@
-
Fisheye: Tag 72c1ce6bda4b00156c3f07cf69cb0377825dcb5e refers to a dead (removed) revision in file `Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/StructureIdEqualityComparerTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?