Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/FileImporters/ClosingStructureUpdateDataStrategyTest.cs =================================================================== diff -u -r32ef1a284c06beac64572d830b50f291e390a66d -r185b8ba9167be4379a7355530b8fffd034de4a50 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/FileImporters/ClosingStructureUpdateDataStrategyTest.cs (.../ClosingStructureUpdateDataStrategyTest.cs) (revision 32ef1a284c06beac64572d830b50f291e390a66d) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/FileImporters/ClosingStructureUpdateDataStrategyTest.cs (.../ClosingStructureUpdateDataStrategyTest.cs) (revision 185b8ba9167be4379a7355530b8fffd034de4a50) @@ -725,6 +725,72 @@ Assert.AreSame(calculation, sectionResults[1].Calculation); } + [Test] + public void UpdateStructuresWithImportedData_SectionResultWithStructureImportedStructureWithSameIdRemoved_UpdatesCalculationInput() + { + // Setup + const string sameId = "id"; + var originalMatchingPoint = new Point2D(0, 0); + ClosingStructure removedStructure = new TestClosingStructure(originalMatchingPoint, sameId); + + var calculation = new TestClosingStructuresCalculation + { + InputParameters = + { + Structure = removedStructure + } + }; + var failureMechanism = new ClosingStructuresFailureMechanism + { + CalculationsGroup = + { + Children = + { + calculation + } + } + }; + failureMechanism.ClosingStructures.AddRange(new[] + { + removedStructure + }, sourceFilePath); + + failureMechanism.AddSection(new FailureMechanismSection("Section", new[] + { + originalMatchingPoint, + new Point2D(10, 10) + })); + + StructuresHelper.UpdateCalculationToSectionResultAssignments(failureMechanism.SectionResults, + failureMechanism.Calculations.Cast>()); + + ClosingStructuresFailureMechanismSectionResult[] sectionResults = failureMechanism.SectionResults.ToArray(); + + var strategy = new ClosingStructureUpdateDataStrategy(failureMechanism); + + // Precondition + Assert.AreEqual(1, sectionResults.Length); + Assert.AreSame(calculation, sectionResults[0].Calculation); + + // Call + IEnumerable affectedObjects = strategy.UpdateStructuresWithImportedData( + failureMechanism.ClosingStructures, + Enumerable.Empty(), + sourceFilePath); + + // Assert + CollectionAssert.AreEqual(new IObservable[] + { + failureMechanism.ClosingStructures, + calculation.InputParameters, + sectionResults[0] + }, affectedObjects); + + sectionResults = failureMechanism.SectionResults.ToArray(); + Assert.AreEqual(1, sectionResults.Length); + Assert.IsNull(sectionResults[0].Calculation); + } + private static void AssertClosingStructures(ClosingStructure readStructure, ClosingStructure structure) { Assert.AreEqual(readStructure.Name, structure.Name); Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/FileImporters/HeightStructureUpdateDataStrategyTest.cs =================================================================== diff -u -r32ef1a284c06beac64572d830b50f291e390a66d -r185b8ba9167be4379a7355530b8fffd034de4a50 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/FileImporters/HeightStructureUpdateDataStrategyTest.cs (.../HeightStructureUpdateDataStrategyTest.cs) (revision 32ef1a284c06beac64572d830b50f291e390a66d) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/FileImporters/HeightStructureUpdateDataStrategyTest.cs (.../HeightStructureUpdateDataStrategyTest.cs) (revision 185b8ba9167be4379a7355530b8fffd034de4a50) @@ -672,6 +672,72 @@ Assert.AreSame(calculation, sectionResults[1].Calculation); } + [Test] + public void UpdateStructuresWithImportedData_SectionResultWithStructureImportedStructureWithSameIdRemoved_UpdatesCalculationInput() + { + // Setup + const string sameId = "id"; + var originalMatchingPoint = new Point2D(0, 0); + HeightStructure removedStructure = new TestHeightStructure(originalMatchingPoint, sameId); + + var calculation = new TestHeightStructuresCalculation + { + InputParameters = + { + Structure = removedStructure + } + }; + var failureMechanism = new HeightStructuresFailureMechanism + { + CalculationsGroup = + { + Children = + { + calculation + } + } + }; + failureMechanism.HeightStructures.AddRange(new[] + { + removedStructure + }, sourceFilePath); + + failureMechanism.AddSection(new FailureMechanismSection("Section", new[] + { + originalMatchingPoint, + new Point2D(10, 10) + })); + + StructuresHelper.UpdateCalculationToSectionResultAssignments(failureMechanism.SectionResults, + failureMechanism.Calculations.Cast>()); + + HeightStructuresFailureMechanismSectionResult[] sectionResults = failureMechanism.SectionResults.ToArray(); + + var strategy = new HeightStructureUpdateDataStrategy(failureMechanism); + + // Precondition + Assert.AreEqual(1, sectionResults.Length); + Assert.AreSame(calculation, sectionResults[0].Calculation); + + // Call + IEnumerable affectedObjects = strategy.UpdateStructuresWithImportedData( + failureMechanism.HeightStructures, + Enumerable.Empty(), + sourceFilePath); + + // Assert + CollectionAssert.AreEqual(new IObservable[] + { + failureMechanism.HeightStructures, + calculation.InputParameters, + sectionResults[0] + }, affectedObjects); + + sectionResults = failureMechanism.SectionResults.ToArray(); + Assert.AreEqual(1, sectionResults.Length); + Assert.IsNull(sectionResults[0].Calculation); + } + private static void AssertHeightStructures(HeightStructure readStructure, HeightStructure structure) { Assert.AreEqual(readStructure.Name, structure.Name); Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/FileImporters/StabilityPointStructuresUpdateDataStrategyTest.cs =================================================================== diff -u -r0e100db56270f5f51374771a049b20dec82df128 -r185b8ba9167be4379a7355530b8fffd034de4a50 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/FileImporters/StabilityPointStructuresUpdateDataStrategyTest.cs (.../StabilityPointStructuresUpdateDataStrategyTest.cs) (revision 0e100db56270f5f51374771a049b20dec82df128) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/FileImporters/StabilityPointStructuresUpdateDataStrategyTest.cs (.../StabilityPointStructuresUpdateDataStrategyTest.cs) (revision 185b8ba9167be4379a7355530b8fffd034de4a50) @@ -698,6 +698,72 @@ Assert.AreSame(calculation, sectionResults[1].Calculation); } + [Test] + public void UpdateStructuresWithImportedData_SectionResultWithStructureImportedStructureWithSameIdRemoved_UpdatesCalculationInput() + { + // Setup + const string sameId = "id"; + var originalMatchingPoint = new Point2D(0, 0); + StabilityPointStructure removedStructure = new TestStabilityPointStructure(originalMatchingPoint, sameId); + + var calculation = new TestStabilityPointStructuresCalculation + { + InputParameters = + { + Structure = removedStructure + } + }; + var failureMechanism = new StabilityPointStructuresFailureMechanism + { + CalculationsGroup = + { + Children = + { + calculation + } + } + }; + failureMechanism.StabilityPointStructures.AddRange(new[] + { + removedStructure + }, sourceFilePath); + + failureMechanism.AddSection(new FailureMechanismSection("Section", new[] + { + originalMatchingPoint, + new Point2D(10, 10) + })); + + StructuresHelper.UpdateCalculationToSectionResultAssignments(failureMechanism.SectionResults, + failureMechanism.Calculations.Cast>()); + + StabilityPointStructuresFailureMechanismSectionResult[] sectionResults = failureMechanism.SectionResults.ToArray(); + + var strategy = new StabilityPointStructureUpdateDataStrategy(failureMechanism); + + // Precondition + Assert.AreEqual(1, sectionResults.Length); + Assert.AreSame(calculation, sectionResults[0].Calculation); + + // Call + IEnumerable affectedObjects = strategy.UpdateStructuresWithImportedData( + failureMechanism.StabilityPointStructures, + Enumerable.Empty(), + sourceFilePath); + + // Assert + CollectionAssert.AreEqual(new IObservable[] + { + failureMechanism.StabilityPointStructures, + calculation.InputParameters, + sectionResults[0] + }, affectedObjects); + + sectionResults = failureMechanism.SectionResults.ToArray(); + Assert.AreEqual(1, sectionResults.Length); + Assert.IsNull(sectionResults[0].Calculation); + } + private static void AssertStabilityPointStructure(StabilityPointStructure expectedStabilityPointStructure, StabilityPointStructure actualStabilityPointStructure) {