Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/FileImporters/GrassCoverErosionInwardsDikeProfileUpdateDataStrategy.cs =================================================================== diff -u -r56ac4eb28f5fcc5b20117474e9e4030399d6806a -red375e3879ae44a0f9b276102e9a9acf171592c5 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/FileImporters/GrassCoverErosionInwardsDikeProfileUpdateDataStrategy.cs (.../GrassCoverErosionInwardsDikeProfileUpdateDataStrategy.cs) (revision 56ac4eb28f5fcc5b20117474e9e4030399d6806a) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/FileImporters/GrassCoverErosionInwardsDikeProfileUpdateDataStrategy.cs (.../GrassCoverErosionInwardsDikeProfileUpdateDataStrategy.cs) (revision ed375e3879ae44a0f9b276102e9a9acf171592c5) @@ -31,6 +31,7 @@ using Ringtoets.GrassCoverErosionInwards.Data; using Ringtoets.GrassCoverErosionInwards.Plugin.Properties; using Ringtoets.GrassCoverErosionInwards.Service; +using Ringtoets.GrassCoverErosionInwards.Utils; namespace Ringtoets.GrassCoverErosionInwards.Plugin.FileImporters { @@ -82,7 +83,7 @@ protected override IEnumerable RemoveObjectAndDependentData(DikeProfile removedObject) { return GrassCoverErosionInwardsDataSynchronizationService.RemoveDikeProfile(FailureMechanism, - removedObject); + removedObject); } private IEnumerable UpdateDikeDependentData(DikeProfile objectToUpdate) @@ -97,6 +98,10 @@ { affectedObjects.Add(calculation.InputParameters); affectedObjects.AddRange(RingtoetsCommonDataSynchronizationService.ClearCalculationOutput(calculation)); + + GrassCoverErosionInwardsHelper.UpdateCalculationToSectionResultAssignments( + FailureMechanism.SectionResults, + FailureMechanism.Calculations.Cast()); } return affectedObjects; } Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/FileImporters/GrassCoverErosionInwardsDikeProfileUpdateDataStrategyTest.cs =================================================================== diff -u -r56ac4eb28f5fcc5b20117474e9e4030399d6806a -red375e3879ae44a0f9b276102e9a9acf171592c5 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/FileImporters/GrassCoverErosionInwardsDikeProfileUpdateDataStrategyTest.cs (.../GrassCoverErosionInwardsDikeProfileUpdateDataStrategyTest.cs) (revision 56ac4eb28f5fcc5b20117474e9e4030399d6806a) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/FileImporters/GrassCoverErosionInwardsDikeProfileUpdateDataStrategyTest.cs (.../GrassCoverErosionInwardsDikeProfileUpdateDataStrategyTest.cs) (revision ed375e3879ae44a0f9b276102e9a9acf171592c5) @@ -29,12 +29,14 @@ using NUnit.Framework; using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Data.UpdateDataStrategies; using Ringtoets.Common.IO.FileImporters; using Ringtoets.GrassCoverErosionInwards.Data; using Ringtoets.GrassCoverErosionInwards.Data.TestUtil; using Ringtoets.GrassCoverErosionInwards.Plugin.FileImporters; +using Ringtoets.GrassCoverErosionInwards.Utils; namespace Ringtoets.GrassCoverErosionInwards.Plugin.Test.FileImporters { @@ -567,6 +569,78 @@ }, affectedObjects); } + [Test] + public void UpdateDikeProfilesWithImportedData_CalculationWithDikeProfileUpdatedToOtherSegment_UpdatesSectionResults() + { + // Setup + const string dikeProfileId = "ID of updated profile"; + + var originalMatchingPoint = new Point2D(0, 0); + var affectedProfile = new TestDikeProfile(originalMatchingPoint, dikeProfileId); + var affectedCalculation = new GrassCoverErosionInwardsCalculation + { + InputParameters = + { + DikeProfile = affectedProfile + } + }; + + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(affectedCalculation); + + var intersectionPoint = new Point2D(10, 10); + failureMechanism.AddSection(new FailureMechanismSection("OldSection", new[] + { + originalMatchingPoint, + intersectionPoint + })); + var updatedMatchingPoint = new Point2D(20, 20); + failureMechanism.AddSection(new FailureMechanismSection("NewSection", new[] + { + intersectionPoint, + updatedMatchingPoint + })); + GrassCoverErosionInwardsHelper.UpdateCalculationToSectionResultAssignments( + failureMechanism.SectionResults, + failureMechanism.Calculations + .Cast()); + + DikeProfileCollection dikeProfiles = failureMechanism.DikeProfiles; + dikeProfiles.AddRange(new[] + { + affectedProfile + }, sourceFilePath); + + // Precondition + GrassCoverErosionInwardsFailureMechanismSectionResult[] sectionResults = failureMechanism.SectionResults.ToArray(); + Assert.AreEqual(2, sectionResults.Length); + Assert.AreSame(affectedCalculation, sectionResults[0].Calculation); + Assert.IsNull(sectionResults[1].Calculation); + + DikeProfile profileToUpdateFrom = new TestDikeProfile(updatedMatchingPoint, dikeProfileId); + + var strategy = new GrassCoverErosionInwardsDikeProfileUpdateDataStrategy(failureMechanism); + + // Call + IEnumerable affectedObjects = strategy.UpdateDikeProfilesWithImportedData(dikeProfiles, + new[] + { + profileToUpdateFrom + }, sourceFilePath); + // Assert + CollectionAssert.AreEquivalent(new IObservable[] + { + dikeProfiles, + affectedCalculation.InputParameters, + affectedProfile + }, affectedObjects); + + sectionResults = failureMechanism.SectionResults.ToArray(); + Assert.AreEqual(2, sectionResults.Length); + Assert.IsNull(sectionResults[0].Calculation); + Assert.AreSame(affectedCalculation, sectionResults[1].Calculation); + } + /// /// Makes a deep clone of the and modifies /// all its parameters, except the ID. Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj =================================================================== diff -u -r56ac4eb28f5fcc5b20117474e9e4030399d6806a -red375e3879ae44a0f9b276102e9a9acf171592c5 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj) (revision 56ac4eb28f5fcc5b20117474e9e4030399d6806a) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj) (revision ed375e3879ae44a0f9b276102e9a9acf171592c5) @@ -170,6 +170,10 @@ {20955E2A-8CEB-46B0-ADC4-A97D4C6BBDF5} Ringtoets.GrassCoverErosionInwards.Plugin + + {99573570-EE00-4264-8147-26A1B25DB23F} + Ringtoets.GrassCoverErosionInwards.Utils + {BF753DB5-973B-4ADF-B0F6-9437325C3466} Ringtoets.GrassCoverErosionInwards.Data.TestUtil