Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/FileImporters/HeightStructureUpdateDataStrategyTest.cs =================================================================== diff -u -r064653222d1d4df89ac7c644f2227f2fe0aa2070 -rb96176ebd8a361085b738455d0882b2ab8e26ac3 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/FileImporters/HeightStructureUpdateDataStrategyTest.cs (.../HeightStructureUpdateDataStrategyTest.cs) (revision 064653222d1d4df89ac7c644f2227f2fe0aa2070) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/FileImporters/HeightStructureUpdateDataStrategyTest.cs (.../HeightStructureUpdateDataStrategyTest.cs) (revision b96176ebd8a361085b738455d0882b2ab8e26ac3) @@ -393,6 +393,83 @@ } [Test] + public void UpdateStructuresWithImportedData_MultipleCalculationWithAssignedStructure_OnlyUpdatesCalculationWithUpdatedStructure() + { + // Setup + const string affectedId = "affectedId"; + const string unaffectedId = "unaffectedId"; + const string unaffectedStructureName = "unaffectedStructure"; + var affectedStructure = new TestHeightStructure(affectedId, "Old name"); + var unaffectedStructure = new TestHeightStructure(unaffectedId, unaffectedStructureName); + + var affectedCalculation = new TestHeightStructuresCalculation + { + InputParameters = + { + Structure = affectedStructure + }, + Output = new TestStructuresOutput() + }; + + var unaffectedCalculation = new TestHeightStructuresCalculation + { + InputParameters = + { + Structure = unaffectedStructure + }, + Output = new TestStructuresOutput() + }; + + var failureMechanism = new HeightStructuresFailureMechanism + { + CalculationsGroup = + { + Children = + { + affectedCalculation, + unaffectedCalculation + } + } + }; + StructureCollection targetDataCollection = failureMechanism.HeightStructures; + targetDataCollection.AddRange(new[] + { + affectedStructure, + unaffectedStructure + }, sourceFilePath); + + var strategy = new HeightStructureUpdateDataStrategy(failureMechanism); + + HeightStructure readAffectedStructure = new TestHeightStructure(affectedId, "New name"); + HeightStructure readUnaffectedStructure = new TestHeightStructure(unaffectedId, unaffectedStructureName); + + // Call + IEnumerable affectedObjects = strategy.UpdateStructuresWithImportedData(targetDataCollection, + new[] + { + readAffectedStructure, + readUnaffectedStructure + }, sourceFilePath); + // Assert + Assert.IsFalse(affectedCalculation.HasOutput); + HeightStructure inputParametersAffectedStructure = affectedCalculation.InputParameters.Structure; + Assert.AreSame(affectedStructure, inputParametersAffectedStructure); + AssertHeightStructures(affectedStructure, inputParametersAffectedStructure); + + Assert.IsTrue(unaffectedCalculation.HasOutput); + HeightStructure inputParametersUnaffectedStructure = unaffectedCalculation.InputParameters.Structure; + Assert.AreSame(unaffectedStructure, inputParametersUnaffectedStructure); + AssertHeightStructures(readUnaffectedStructure, inputParametersUnaffectedStructure); + + CollectionAssert.AreEquivalent(new IObservable[] + { + affectedCalculation, + affectedCalculation.InputParameters, + targetDataCollection + }, affectedObjects); + } + + [Test] public void UpdateStructuresWithImportedData_SectionResultWithStructureImportedStructureWithSameId_UpdatesCalculation() { // Setup