Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/FileImporters/HeightStructureUpdateDataStrategyTest.cs =================================================================== diff -u -rb96176ebd8a361085b738455d0882b2ab8e26ac3 -rbc752890b4f52991a673a59c089db400be0e6fc3 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/FileImporters/HeightStructureUpdateDataStrategyTest.cs (.../HeightStructureUpdateDataStrategyTest.cs) (revision b96176ebd8a361085b738455d0882b2ab8e26ac3) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/FileImporters/HeightStructureUpdateDataStrategyTest.cs (.../HeightStructureUpdateDataStrategyTest.cs) (revision bc752890b4f52991a673a59c089db400be0e6fc3) @@ -442,7 +442,7 @@ HeightStructure readAffectedStructure = new TestHeightStructure(affectedId, "New name"); HeightStructure readUnaffectedStructure = new TestHeightStructure(unaffectedId, unaffectedStructureName); - + // Call IEnumerable affectedObjects = strategy.UpdateStructuresWithImportedData(targetDataCollection, new[] @@ -460,7 +460,7 @@ HeightStructure inputParametersUnaffectedStructure = unaffectedCalculation.InputParameters.Structure; Assert.AreSame(unaffectedStructure, inputParametersUnaffectedStructure); AssertHeightStructures(readUnaffectedStructure, inputParametersUnaffectedStructure); - + CollectionAssert.AreEquivalent(new IObservable[] { affectedCalculation, @@ -470,6 +470,58 @@ } [Test] + public void UpdateStructuresWithImportedData_CalculationWithSameReference_OnlyReturnsDistinctCalculation() + { + // Setup + const string affectedId = "affectedId"; + var affectedStructure = new TestHeightStructure(affectedId, "Old name"); + var affectedCalculation = new TestHeightStructuresCalculation + { + InputParameters = + { + Structure = affectedStructure + }, + Output = new TestStructuresOutput() + }; + + var failureMechanism = new HeightStructuresFailureMechanism + { + CalculationsGroup = + { + Children = + { + affectedCalculation, + affectedCalculation + } + } + }; + + StructureCollection structures = failureMechanism.HeightStructures; + structures.AddRange(new[] + { + affectedStructure + }, sourceFilePath); + + var structureToUpdateFrom = new TestHeightStructure(affectedId, "New name"); + + var strategy = new HeightStructureUpdateDataStrategy(failureMechanism); + + // Call + IEnumerable affectedObjects = strategy.UpdateStructuresWithImportedData(structures, + new[] + { + structureToUpdateFrom + }, sourceFilePath); + // Assert + CollectionAssert.AreEquivalent(new IObservable[] + { + structures, + affectedCalculation, + affectedCalculation.InputParameters + }, affectedObjects); + } + + [Test] public void UpdateStructuresWithImportedData_SectionResultWithStructureImportedStructureWithSameId_UpdatesCalculation() { // Setup