Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs =================================================================== diff -u -r02d0e67121f748ae6d69ab9f68643d2f5e62f800 -rb5accd775c390fa85f815ef13c3c3e54a6d10ada --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs (.../ClosingStructuresPlugin.cs) (revision 02d0e67121f748ae6d69ab9f68643d2f5e62f800) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs (.../ClosingStructuresPlugin.cs) (revision b5accd775c390fa85f815ef13c3c3e54a6d10ada) @@ -288,7 +288,7 @@ return new ArrayList { new FailureMechanismSectionsContext(failureMechanism, assessmentSection), - new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, assessmentSection), + new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection), new ClosingStructuresContext(failureMechanism.ClosingStructures, assessmentSection), new CommentContext(failureMechanism) }; Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructureFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -r64eede81657b51fb755944fd3939ceefb839e591 -rb5accd775c390fa85f815ef13c3c3e54a6d10ada --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructureFailureMechanismContextTreeNodeInfoTest.cs (.../ClosingStructureFailureMechanismContextTreeNodeInfoTest.cs) (revision 64eede81657b51fb755944fd3939ceefb839e591) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructureFailureMechanismContextTreeNodeInfoTest.cs (.../ClosingStructureFailureMechanismContextTreeNodeInfoTest.cs) (revision b5accd775c390fa85f815ef13c3c3e54a6d10ada) @@ -138,6 +138,7 @@ var profilesContext = (ForeshoreProfilesContext) inputsFolder.Contents[1]; Assert.AreSame(failureMechanism.ForeshoreProfiles, profilesContext.WrappedData); + Assert.AreSame(failureMechanism, profilesContext.ParentFailureMechanism); Assert.AreSame(assessmentSectionMock, profilesContext.ParentAssessmentSection); var closingStructuresContext = (ClosingStructuresContext) inputsFolder.Contents[2]; Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/ForeshoreProfilesContext.cs =================================================================== diff -u -r8805f03189f521994b42a519bbca7561bf12eb68 -rb5accd775c390fa85f815ef13c3c3e54a6d10ada --- Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/ForeshoreProfilesContext.cs (.../ForeshoreProfilesContext.cs) (revision 8805f03189f521994b42a519bbca7561bf12eb68) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/ForeshoreProfilesContext.cs (.../ForeshoreProfilesContext.cs) (revision b5accd775c390fa85f815ef13c3c3e54a6d10ada) @@ -24,6 +24,7 @@ using Core.Common.Controls.PresentationObjects; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.Common.Data.FailureMechanism; namespace Ringtoets.Common.Forms.PresentationObjects { @@ -37,22 +38,32 @@ /// Initializes a new instance of the class. /// /// The observable list of objects. + /// The parent failure mechanism /// The parent assessment section. - /// Thrown when either - /// or is null. - public ForeshoreProfilesContext(ObservableList foreshoreProfiles, IAssessmentSection parentAssessmentSection) + /// Thrown when any input argument is null. + public ForeshoreProfilesContext(ObservableList foreshoreProfiles, IFailureMechanism parentFailureMechanism, IAssessmentSection parentAssessmentSection) : base(foreshoreProfiles) { if (parentAssessmentSection == null) { throw new ArgumentNullException("parentAssessmentSection"); } + if (parentFailureMechanism == null) + { + throw new ArgumentNullException("parentFailureMechanism"); + } ParentAssessmentSection = parentAssessmentSection; + ParentFailureMechanism = parentFailureMechanism; } /// /// Gets the parent assessment section. /// public IAssessmentSection ParentAssessmentSection { get; private set; } + + /// + /// Gets the parent failure mechanism. + /// + public IFailureMechanism ParentFailureMechanism { get; private set; } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/ForeshoreProfilesContextTest.cs =================================================================== diff -u -r275811c8e133cba03f636224f40a9536a733fb1f -rb5accd775c390fa85f815ef13c3c3e54a6d10ada --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/ForeshoreProfilesContextTest.cs (.../ForeshoreProfilesContextTest.cs) (revision 275811c8e133cba03f636224f40a9536a733fb1f) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/ForeshoreProfilesContextTest.cs (.../ForeshoreProfilesContextTest.cs) (revision b5accd775c390fa85f815ef13c3c3e54a6d10ada) @@ -26,6 +26,7 @@ using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Forms.PresentationObjects; namespace Ringtoets.Common.Forms.Test.PresentationObjects @@ -39,16 +40,18 @@ // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub(); + var failureMechanism = mocks.Stub(); mocks.ReplayAll(); var foreshoresList = new ObservableList(); // Call - var context = new ForeshoreProfilesContext(foreshoresList, assessmentSection); + var context = new ForeshoreProfilesContext(foreshoresList, failureMechanism, assessmentSection); // Assert Assert.IsInstanceOf>>(context); Assert.AreSame(foreshoresList, context.WrappedData); + Assert.AreSame(failureMechanism, context.ParentFailureMechanism); Assert.AreSame(assessmentSection, context.ParentAssessmentSection); mocks.VerifyAll(); } @@ -59,10 +62,11 @@ // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub(); + var failureMechanism = mocks.Stub(); mocks.ReplayAll(); // Call - TestDelegate call = () => new ForeshoreProfilesContext(null, assessmentSection); + TestDelegate call = () => new ForeshoreProfilesContext(null, failureMechanism, assessmentSection); // Assert string paramName = Assert.Throws(call).ParamName; @@ -71,14 +75,37 @@ } [Test] + public void Constructor_FailureMechanismIsNull_ThrowArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var failureMechanism = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => new ForeshoreProfilesContext(new ObservableList(), failureMechanism, null); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("parentAssessmentSection", paramName); + mocks.VerifyAll(); + } + + [Test] public void Constructor_AssessmentSectionIsNull_ThrowArgumentNullException() { + // Setup + var mocks = new MockRepository(); + var failureMechanism = mocks.Stub(); + mocks.ReplayAll(); + // Call - TestDelegate call = () => new ForeshoreProfilesContext(new ObservableList(), null); + TestDelegate call = () => new ForeshoreProfilesContext(new ObservableList(), failureMechanism, null); // Assert string paramName = Assert.Throws(call).ParamName; Assert.AreEqual("parentAssessmentSection", paramName); + mocks.VerifyAll(); } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/ForeshoreProfilesImporterTest.cs =================================================================== diff -u -r49c5da81f49a23dd6e66526d264a08bf510e6963 -rb5accd775c390fa85f815ef13c3c3e54a6d10ada --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/ForeshoreProfilesImporterTest.cs (.../ForeshoreProfilesImporterTest.cs) (revision 49c5da81f49a23dd6e66526d264a08bf510e6963) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/ForeshoreProfilesImporterTest.cs (.../ForeshoreProfilesImporterTest.cs) (revision b5accd775c390fa85f815ef13c3c3e54a6d10ada) @@ -31,6 +31,7 @@ using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.IO.FileImporters; @@ -242,12 +243,13 @@ ReferenceLine referenceLine = CreateMatchingReferenceLine(); var assessmentSection = mockRepository.Stub(); assessmentSection.ReferenceLine = referenceLine; + var failureMechanism = mockRepository.Stub(); mockRepository.ReplayAll(); var foreshoreProfiles = new ObservableList(); var foreshoreProfilesImporter = new ForeshoreProfilesImporter(foreshoreProfiles, referenceLine, filePath); - var targetContext = new ForeshoreProfilesContext(foreshoreProfiles, assessmentSection); + var targetContext = new ForeshoreProfilesContext(foreshoreProfiles, failureMechanism, assessmentSection); targetContext.Attach(observer); // Call @@ -274,14 +276,15 @@ ReferenceLine referenceLine = CreateMatchingReferenceLine(); var assessmentSection = mockRepository.Stub(); assessmentSection.ReferenceLine = referenceLine; + var failureMechanism = mockRepository.Stub(); mockRepository.ReplayAll(); var progressChangeNotifications = new List(); var foreshoreProfiles = new ObservableList(); var foreshoreProfilesImporter = new ForeshoreProfilesImporter(foreshoreProfiles, referenceLine, filePath); foreshoreProfilesImporter.SetProgressChanged((description, step, steps) => progressChangeNotifications.Add(new ProgressNotification(description, step, steps))); - var targetContext = new ForeshoreProfilesContext(foreshoreProfiles, assessmentSection); + var targetContext = new ForeshoreProfilesContext(foreshoreProfiles, failureMechanism, assessmentSection); targetContext.Attach(observer); // Call Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -r64eede81657b51fb755944fd3939ceefb839e591 -rb5accd775c390fa85f815ef13c3c3e54a6d10ada --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsFailureMechanismContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsFailureMechanismContextTreeNodeInfoTest.cs) (revision 64eede81657b51fb755944fd3939ceefb839e591) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsFailureMechanismContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsFailureMechanismContextTreeNodeInfoTest.cs) (revision b5accd775c390fa85f815ef13c3c3e54a6d10ada) @@ -126,6 +126,7 @@ var dikeProfilesContext = (DikeProfilesContext) inputsFolder.Contents[1]; Assert.AreSame(failureMechanism.DikeProfiles, dikeProfilesContext.WrappedData); + Assert.AreSame(failureMechanism, dikeProfilesContext.ParentFailureMechanism); Assert.AreSame(assessmentSectionMock, dikeProfilesContext.ParentAssessmentSection); var commentContext = (CommentContext) inputsFolder.Contents[2]; Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs =================================================================== diff -u -r02d0e67121f748ae6d69ab9f68643d2f5e62f800 -rb5accd775c390fa85f815ef13c3c3e54a6d10ada --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision 02d0e67121f748ae6d69ab9f68643d2f5e62f800) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision b5accd775c390fa85f815ef13c3c3e54a6d10ada) @@ -388,7 +388,7 @@ return new ArrayList { new FailureMechanismSectionsContext(failureMechanism, assessmentSection), - new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, assessmentSection), + new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection), new CommentContext(failureMechanism) }; } Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/GrassCoverErosionOutwardsFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -r2973c5f790a5131e427bd5f73e2a620044199639 -rb5accd775c390fa85f815ef13c3c3e54a6d10ada --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/GrassCoverErosionOutwardsFailureMechanismContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsFailureMechanismContextTreeNodeInfoTest.cs) (revision 2973c5f790a5131e427bd5f73e2a620044199639) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/GrassCoverErosionOutwardsFailureMechanismContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsFailureMechanismContextTreeNodeInfoTest.cs) (revision b5accd775c390fa85f815ef13c3c3e54a6d10ada) @@ -196,6 +196,7 @@ var foreshoreProfilesContext = (ForeshoreProfilesContext) inputsFolder.Contents[1]; Assert.AreSame(failureMechanism.ForeshoreProfiles, foreshoreProfilesContext.WrappedData); + Assert.AreSame(failureMechanism, foreshoreProfilesContext.ParentFailureMechanism); Assert.AreSame(assessmentSection, foreshoreProfilesContext.ParentAssessmentSection); var commentContext = (CommentContext) inputsFolder.Contents[2]; Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs =================================================================== diff -u -r02d0e67121f748ae6d69ab9f68643d2f5e62f800 -rb5accd775c390fa85f815ef13c3c3e54a6d10ada --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs (.../HeightStructuresPlugin.cs) (revision 02d0e67121f748ae6d69ab9f68643d2f5e62f800) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs (.../HeightStructuresPlugin.cs) (revision b5accd775c390fa85f815ef13c3c3e54a6d10ada) @@ -294,7 +294,7 @@ return new ArrayList { new FailureMechanismSectionsContext(failureMechanism, assessmentSection), - new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, assessmentSection), + new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection), new HeightStructuresContext(failureMechanism.HeightStructures, assessmentSection), new CommentContext(failureMechanism) }; Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -r64eede81657b51fb755944fd3939ceefb839e591 -rb5accd775c390fa85f815ef13c3c3e54a6d10ada --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision 64eede81657b51fb755944fd3939ceefb839e591) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision b5accd775c390fa85f815ef13c3c3e54a6d10ada) @@ -128,6 +128,7 @@ var profilesContext = (ForeshoreProfilesContext) inputsFolder.Contents[1]; Assert.AreSame(failureMechanism.ForeshoreProfiles, profilesContext.WrappedData); + Assert.AreSame(failureMechanism, profilesContext.ParentFailureMechanism); Assert.AreSame(assessmentSectionMock, profilesContext.ParentAssessmentSection); var heightStructuresContext = (HeightStructuresContext) inputsFolder.Contents[2]; Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Ringtoets.Integration.Plugin.csproj =================================================================== diff -u -raaad7a7ca8557c045aa8d6d4031be9133d2f34a6 -rb5accd775c390fa85f815ef13c3c3e54a6d10ada --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Ringtoets.Integration.Plugin.csproj (.../Ringtoets.Integration.Plugin.csproj) (revision aaad7a7ca8557c045aa8d6d4031be9133d2f34a6) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Ringtoets.Integration.Plugin.csproj (.../Ringtoets.Integration.Plugin.csproj) (revision b5accd775c390fa85f815ef13c3c3e54a6d10ada) @@ -115,6 +115,11 @@ {99573570-ee00-4264-8147-26a1b25db23f} Ringtoets.GrassCoverErosionInwards.Utils + + {87c2c553-c0bc-40bf-b1ea-b83bff357f27} + Ringtoets.Revetment.Data + False + {3D4B9740-8348-4434-8D77-B611FC6EE57F} Ringtoets.StabilityPointStructures.Data Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs =================================================================== diff -u -raaad7a7ca8557c045aa8d6d4031be9133d2f34a6 -rb5accd775c390fa85f815ef13c3c3e54a6d10ada --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision aaad7a7ca8557c045aa8d6d4031be9133d2f34a6) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision b5accd775c390fa85f815ef13c3c3e54a6d10ada) @@ -589,6 +589,8 @@ .Cast() .ToArray(), ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl) + .AddDeleteChildrenItem() + .AddSeparator() .AddImportItem() .AddSeparator() .AddCollapseAllItem() @@ -614,8 +616,12 @@ Text = foreshoreProfile => foreshoreProfile.Name, Image = context => RingtoetsIntegrationPluginResources.Foreshore, ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl) + .AddDeleteItem() + .AddSeparator() .AddPropertiesItem() - .Build() + .Build(), + CanRemove = CanRemoveForeshoreProfile, + OnNodeRemoved = OnForeshoreProfileRemoved }; yield return RingtoetsTreeNodeInfoFactory.CreateEmptyProbabilityAssessmentOutputTreeNodeInfo( @@ -841,6 +847,116 @@ } } + #region ForeshoreProfile TreeNodeInfo + + private bool CanRemoveForeshoreProfile(ForeshoreProfile nodeData, object parentNodeData) + { + var parentContext = (ForeshoreProfilesContext) parentNodeData; + IFailureMechanism failureMechanism = parentContext.ParentFailureMechanism; + return failureMechanism is StabilityStoneCoverFailureMechanism || + failureMechanism is WaveImpactAsphaltCoverFailureMechanism || + failureMechanism is GrassCoverErosionOutwardsFailureMechanism /*|| + failureMechanism is HeightStructuresFailureMechanism || + failureMechanism is ClosingStructuresFailureMechanism || + failureMechanism is StabilityPointStructuresFailureMechanism*/; + } + + private void OnForeshoreProfileRemoved(ForeshoreProfile nodeData, object parentNodeData) + { + var parentContext = (ForeshoreProfilesContext) parentNodeData; + IFailureMechanism failureMechanism = parentContext.ParentFailureMechanism; + + var stabilityStoneCoverFailureMechanism = failureMechanism as StabilityStoneCoverFailureMechanism; + if (stabilityStoneCoverFailureMechanism != null) + { + OnStabilityStoneCoverForeshoreProfileRemoved(nodeData, parentContext.WrappedData, stabilityStoneCoverFailureMechanism); + } + var waveImpactAsphaltCoverFailureMechanism = failureMechanism as WaveImpactAsphaltCoverFailureMechanism; + if (waveImpactAsphaltCoverFailureMechanism != null) + { + OnWaveImpactAsphaltCoverForeshoreProfileRemoved(nodeData, parentContext.WrappedData, waveImpactAsphaltCoverFailureMechanism); + } + var grassCoverErosionOutwardsFailureMechanism = failureMechanism as GrassCoverErosionOutwardsFailureMechanism; + if (grassCoverErosionOutwardsFailureMechanism != null) + { + OnGrassCoverErosionOutwardsForeshoreProfileRemoved(nodeData, parentContext.WrappedData, grassCoverErosionOutwardsFailureMechanism); + } + } + + private static void OnStabilityStoneCoverForeshoreProfileRemoved(ForeshoreProfile nodeData, ObservableList foreshoreProfiles, StabilityStoneCoverFailureMechanism failureMechanism) + { + var changedObservables = new List(); + StabilityStoneCoverWaveConditionsCalculation[] calculations = failureMechanism.Calculations + .Cast() + .ToArray(); + StabilityStoneCoverWaveConditionsCalculation[] calculationWithRemovedForeshoreProfile = calculations + .Where(c => ReferenceEquals(c.InputParameters.ForeshoreProfile, nodeData)) + .ToArray(); + foreach (StabilityStoneCoverWaveConditionsCalculation calculation in calculationWithRemovedForeshoreProfile) + { + calculation.InputParameters.ForeshoreProfile = null; + changedObservables.Add(calculation.InputParameters); + } + + foreshoreProfiles.Remove(nodeData); + changedObservables.Add(foreshoreProfiles); + + foreach (IObservable observable in changedObservables) + { + observable.NotifyObservers(); + } + } + + private static void OnWaveImpactAsphaltCoverForeshoreProfileRemoved(ForeshoreProfile nodeData, ObservableList foreshoreProfiles, WaveImpactAsphaltCoverFailureMechanism failureMechanism) + { + var changedObservables = new List(); + WaveImpactAsphaltCoverWaveConditionsCalculation[] calculations = failureMechanism.Calculations + .Cast() + .ToArray(); + WaveImpactAsphaltCoverWaveConditionsCalculation[] calculationWithRemovedForeshoreProfile = calculations + .Where(c => ReferenceEquals(c.InputParameters.ForeshoreProfile, nodeData)) + .ToArray(); + foreach (WaveImpactAsphaltCoverWaveConditionsCalculation calculation in calculationWithRemovedForeshoreProfile) + { + calculation.InputParameters.ForeshoreProfile = null; + changedObservables.Add(calculation.InputParameters); + } + + foreshoreProfiles.Remove(nodeData); + changedObservables.Add(foreshoreProfiles); + + foreach (IObservable observable in changedObservables) + { + observable.NotifyObservers(); + } + } + + private static void OnGrassCoverErosionOutwardsForeshoreProfileRemoved(ForeshoreProfile nodeData, ObservableList foreshoreProfiles, GrassCoverErosionOutwardsFailureMechanism failureMechanism) + { + var changedObservables = new List(); + GrassCoverErosionOutwardsWaveConditionsCalculation[] calculations = failureMechanism.Calculations + .Cast() + .ToArray(); + GrassCoverErosionOutwardsWaveConditionsCalculation[] calculationWithRemovedForeshoreProfile = calculations + .Where(c => ReferenceEquals(c.InputParameters.ForeshoreProfile, nodeData)) + .ToArray(); + foreach (GrassCoverErosionOutwardsWaveConditionsCalculation calculation in calculationWithRemovedForeshoreProfile) + { + calculation.InputParameters.ForeshoreProfile = null; + changedObservables.Add(calculation.InputParameters); + } + + foreshoreProfiles.Remove(nodeData); + changedObservables.Add(foreshoreProfiles); + + foreach (IObservable observable in changedObservables) + { + observable.NotifyObservers(); + } + } + + #endregion + #region DikeProfile TreeNodeInfo private bool CanRemoveDikeProfile(DikeProfile nodeData, object parentData) Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/ForeshoreProfilesContextTest.cs =================================================================== diff -u -rff8a088931e6af2e46f6f4f09b633bcdd0b84ecd -rb5accd775c390fa85f815ef13c3c3e54a6d10ada --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/ForeshoreProfilesContextTest.cs (.../ForeshoreProfilesContextTest.cs) (revision ff8a088931e6af2e46f6f4f09b633bcdd0b84ecd) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/ForeshoreProfilesContextTest.cs (.../ForeshoreProfilesContextTest.cs) (revision b5accd775c390fa85f815ef13c3c3e54a6d10ada) @@ -25,6 +25,7 @@ using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Forms.PresentationObjects; namespace Ringtoets.Integration.Forms.Test.PresentationObjects @@ -38,10 +39,11 @@ // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub(); + var failureMechanism = mocks.Stub(); mocks.ReplayAll(); // Call - TestDelegate call = () => new ForeshoreProfilesContext(null, assessmentSection); + TestDelegate call = () => new ForeshoreProfilesContext(null, failureMechanism, assessmentSection); // Assert string paramName = Assert.Throws(call).ParamName; @@ -50,17 +52,41 @@ } [Test] + public void Constructor_ParentFailureMechanismNull_ThrowArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var foreshores = new ObservableList(); + + // Call + TestDelegate call = () => new ForeshoreProfilesContext(foreshores, null, assessmentSection); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("parentFailureMechanism", paramName); + mocks.VerifyAll(); + } + + [Test] public void Constructor_ParentAssessmentSectionNull_ThrowArgumentNullException() { // Setup + var mocks = new MockRepository(); + var failureMechanism = mocks.Stub(); + mocks.ReplayAll(); + var foreshores = new ObservableList(); // Call - TestDelegate call = () => new ForeshoreProfilesContext(foreshores, null); + TestDelegate call = () => new ForeshoreProfilesContext(foreshores, failureMechanism, null); // Assert string paramName = Assert.Throws(call).ParamName; Assert.AreEqual("parentAssessmentSection", paramName); + mocks.VerifyAll(); } [Test] @@ -69,15 +95,17 @@ // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub(); + var failureMechanism = mocks.Stub(); mocks.ReplayAll(); var foreshores = new ObservableList(); // Call - var context = new ForeshoreProfilesContext(foreshores, assessmentSection); + var context = new ForeshoreProfilesContext(foreshores, failureMechanism, assessmentSection); // Assert Assert.AreSame(foreshores, context.WrappedData); + Assert.AreSame(failureMechanism, context.ParentFailureMechanism); Assert.AreSame(assessmentSection, context.ParentAssessmentSection); } } Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/ForeshoreProfilesContextTreeNodeInfoTest.cs =================================================================== diff -u -r8d97f1f5da3f6e6954160d0e0076ce04349ed738 -rb5accd775c390fa85f815ef13c3c3e54a6d10ada --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/ForeshoreProfilesContextTreeNodeInfoTest.cs (.../ForeshoreProfilesContextTreeNodeInfoTest.cs) (revision 8d97f1f5da3f6e6954160d0e0076ce04349ed738) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/ForeshoreProfilesContextTreeNodeInfoTest.cs (.../ForeshoreProfilesContextTreeNodeInfoTest.cs) (revision b5accd775c390fa85f815ef13c3c3e54a6d10ada) @@ -31,6 +31,7 @@ using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Integration.Plugin; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; @@ -101,10 +102,11 @@ // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub(); + var failureMechanism = mocks.Stub(); mocks.ReplayAll(); var emptyCollection = new ObservableList(); - var context = new ForeshoreProfilesContext(emptyCollection, assessmentSection); + var context = new ForeshoreProfilesContext(emptyCollection, failureMechanism, assessmentSection); // Call Color color = info.ForeColor(context); @@ -120,13 +122,14 @@ // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub(); + var failureMechanism = mocks.Stub(); mocks.ReplayAll(); var emptyCollection = new ObservableList { new ForeshoreProfile(new Point2D(0, 0), new Point2D[0], null, new ForeshoreProfile.ConstructionProperties()) }; - var context = new ForeshoreProfilesContext(emptyCollection, assessmentSection); + var context = new ForeshoreProfilesContext(emptyCollection, failureMechanism, assessmentSection); // Call Color color = info.ForeColor(context); @@ -142,6 +145,7 @@ // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub(); + var failureMechanism = mocks.Stub(); mocks.ReplayAll(); var profile1 = new ForeshoreProfile(new Point2D(0, 0), new Point2D[0], null, new ForeshoreProfile.ConstructionProperties()); @@ -153,7 +157,7 @@ profile2, profile3, }; - var context = new ForeshoreProfilesContext(emptyCollection, assessmentSection); + var context = new ForeshoreProfilesContext(emptyCollection, failureMechanism, assessmentSection); // Call object[] children = info.ChildNodeObjects(context); @@ -177,11 +181,14 @@ using (var treeViewControl = new TreeViewControl()) { var assessmentSection = mocks.Stub(); + var failureMechanism = mocks.Stub(); var emptyCollection = new ObservableList(); - var context = new ForeshoreProfilesContext(emptyCollection, assessmentSection); + var context = new ForeshoreProfilesContext(emptyCollection, failureMechanism, assessmentSection); var contextMenuBuilder = mocks.Stub(); + contextMenuBuilder.Expect(b => b.AddDeleteChildrenItem()).Return(contextMenuBuilder); + contextMenuBuilder.Expect(b => b.AddSeparator()).Return(contextMenuBuilder); contextMenuBuilder.Expect(b => b.AddImportItem()).Return(contextMenuBuilder); contextMenuBuilder.Expect(b => b.AddSeparator()).Return(contextMenuBuilder); contextMenuBuilder.Expect(b => b.AddCollapseAllItem()).Return(contextMenuBuilder); Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/ForeshoreTreeNodeInfoTest.cs =================================================================== diff -u -r2973c5f790a5131e427bd5f73e2a620044199639 -rb5accd775c390fa85f815ef13c3c3e54a6d10ada --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/ForeshoreTreeNodeInfoTest.cs (.../ForeshoreTreeNodeInfoTest.cs) (revision 2973c5f790a5131e427bd5f73e2a620044199639) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/ForeshoreTreeNodeInfoTest.cs (.../ForeshoreTreeNodeInfoTest.cs) (revision b5accd775c390fa85f815ef13c3c3e54a6d10ada) @@ -22,16 +22,24 @@ using System.Collections.Generic; using System.Drawing; using System.Linq; +using Core.Common.Base; using Core.Common.Base.Geometry; using Core.Common.Controls.TreeView; using Core.Common.Gui; using Core.Common.Gui.ContextMenu; using Core.Common.TestUtil; using NUnit.Framework; using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Forms.PresentationObjects; +using Ringtoets.GrassCoverErosionOutwards.Data; using Ringtoets.Integration.Plugin; using Ringtoets.Integration.Plugin.Properties; +using Ringtoets.StabilityStoneCover.Data; +using Ringtoets.WaveImpactAsphaltCover.Data; namespace Ringtoets.Integration.Forms.Test.TreeNodeInfos { @@ -67,8 +75,6 @@ Assert.IsNull(info.EnsureVisibleOnCreate); Assert.IsNull(info.CanRename); Assert.IsNull(info.OnNodeRenamed); - Assert.IsNull(info.CanRemove); - Assert.IsNull(info.OnNodeRemoved); Assert.IsNull(info.CanCheck); Assert.IsNull(info.IsChecked); Assert.IsNull(info.OnNodeChecked); @@ -121,11 +127,436 @@ } [Test] + public void CanRemove_ParentFailureMechanismIsStabilityStoneCover_ReturnTrue() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new StabilityStoneCoverFailureMechanism(); + + var parentData = new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection); + + // Call + bool canRemove = info.CanRemove(null, parentData); + + // Assert + Assert.IsTrue(canRemove); + mocks.VerifyAll(); + } + + [Test] + public void CanRemove_ParentFailureMechanismIsWaveImpactAsphaltCover_ReturnTrue() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + + var parentData = new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection); + + // Call + bool canRemove = info.CanRemove(null, parentData); + + // Assert + Assert.IsTrue(canRemove); + mocks.VerifyAll(); + } + + [Test] + public void CanRemove_ParentFailureMechanismIsGrassCoverErosionOutwards_ReturnTrue() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + + var parentData = new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection); + + // Call + bool canRemove = info.CanRemove(null, parentData); + + // Assert + Assert.IsTrue(canRemove); + mocks.VerifyAll(); + } + + [Test] + public void CanRemove_UnsupportedFailureMechanism_ReturnFalse() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var failureMechanism = mocks.Stub(); + mocks.ReplayAll(); + + var list = new ObservableList(); + + var parentData = new ForeshoreProfilesContext(list, failureMechanism, assessmentSection); + + // Call + bool canRemove = info.CanRemove(null, parentData); + + // Assert + Assert.IsFalse(canRemove); + mocks.VerifyAll(); + } + + [Test] + public void OnNodeRemoved_ForeshoreProfileOfStabilityStoneCover_ForeshoreProfileRemovedFromFailureMechanism() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var observer = mocks.Stub(); + observer.Expect(o => o.UpdateObserver()); + mocks.ReplayAll(); + + var nodeData = new ForeshoreProfile(new Point2D(0,0), new Point2D[0], null, new ForeshoreProfile.ConstructionProperties()); + + var failureMechanism = new StabilityStoneCoverFailureMechanism + { + ForeshoreProfiles = + { + nodeData + } + }; + failureMechanism.ForeshoreProfiles.Attach(observer); + + var parentData = new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection); + + // Call + info.OnNodeRemoved(nodeData, parentData); + + // Assert + CollectionAssert.DoesNotContain(failureMechanism.ForeshoreProfiles, nodeData); + mocks.VerifyAll(); + } + + [Test] + public void OnNodeRemoved_ForeshoreProfileOfStabilityStoneCoverWaveConditionsCalculation_CalculationForeshoreProfileCleared() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var observer = mocks.Stub(); + observer.Expect(o => o.UpdateObserver()); + var calculation1Observer = mocks.StrictMock(); + calculation1Observer.Expect(o => o.UpdateObserver()); + var calculation2Observer = mocks.StrictMock(); + calculation2Observer.Expect(o => o.UpdateObserver()); + var calculation3Observer = mocks.StrictMock(); + calculation3Observer.Expect(o => o.UpdateObserver()).Repeat.Never(); + mocks.ReplayAll(); + + var nodeData = new ForeshoreProfile(new Point2D(0, 0), new Point2D[0], null, new ForeshoreProfile.ConstructionProperties()); + var otherProfile = new ForeshoreProfile(new Point2D(1, 1), new Point2D[0], null, new ForeshoreProfile.ConstructionProperties()); + + var calculation1 = new StabilityStoneCoverWaveConditionsCalculation + { + InputParameters = + { + ForeshoreProfile = nodeData + } + }; + calculation1.InputParameters.Attach(calculation1Observer); + var calculation2 = new StabilityStoneCoverWaveConditionsCalculation + { + InputParameters = + { + ForeshoreProfile = nodeData + } + }; + calculation2.InputParameters.Attach(calculation2Observer); + var calculation3 = new StabilityStoneCoverWaveConditionsCalculation + { + InputParameters = + { + ForeshoreProfile = otherProfile + } + }; + calculation3.InputParameters.Attach(calculation3Observer); + + var failureMechanism = new StabilityStoneCoverFailureMechanism + { + ForeshoreProfiles = + { + nodeData, + otherProfile + }, + WaveConditionsCalculationGroup = + { + Children = + { + calculation1, + new CalculationGroup("A", true) + { + Children = + { + calculation2 + } + }, + calculation3 + } + } + }; + failureMechanism.ForeshoreProfiles.Attach(observer); + + var parentData = new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection); + + // Call + info.OnNodeRemoved(nodeData, parentData); + + // Assert + CollectionAssert.DoesNotContain(failureMechanism.ForeshoreProfiles, nodeData); + + Assert.IsNull(calculation1.InputParameters.ForeshoreProfile); + Assert.IsNull(calculation2.InputParameters.ForeshoreProfile); + Assert.AreSame(otherProfile, calculation3.InputParameters.ForeshoreProfile); + mocks.VerifyAll(); + } + + [Test] + public void OnNodeRemoved_ForeshoreProfileOfWaveImpactAsphaltCover_ForeshoreProfileRemovedFromFailureMechanism() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var observer = mocks.Stub(); + observer.Expect(o => o.UpdateObserver()); + mocks.ReplayAll(); + + var nodeData = new ForeshoreProfile(new Point2D(0, 0), new Point2D[0], null, new ForeshoreProfile.ConstructionProperties()); + + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism + { + ForeshoreProfiles = + { + nodeData + } + }; + failureMechanism.ForeshoreProfiles.Attach(observer); + + var parentData = new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection); + + // Call + info.OnNodeRemoved(nodeData, parentData); + + // Assert + CollectionAssert.DoesNotContain(failureMechanism.ForeshoreProfiles, nodeData); + mocks.VerifyAll(); + } + + [Test] + public void OnNodeRemoved_ForeshoreProfileOfWaveImpactAsphaltCoverWaveConditionsCalculation_CalculationForeshoreProfileCleared() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var observer = mocks.Stub(); + observer.Expect(o => o.UpdateObserver()); + var calculation1Observer = mocks.StrictMock(); + calculation1Observer.Expect(o => o.UpdateObserver()); + var calculation2Observer = mocks.StrictMock(); + calculation2Observer.Expect(o => o.UpdateObserver()); + var calculation3Observer = mocks.StrictMock(); + calculation3Observer.Expect(o => o.UpdateObserver()).Repeat.Never(); + mocks.ReplayAll(); + + var nodeData = new ForeshoreProfile(new Point2D(0, 0), new Point2D[0], null, new ForeshoreProfile.ConstructionProperties()); + var otherProfile = new ForeshoreProfile(new Point2D(1, 1), new Point2D[0], null, new ForeshoreProfile.ConstructionProperties()); + + var calculation1 = new WaveImpactAsphaltCoverWaveConditionsCalculation + { + InputParameters = + { + ForeshoreProfile = nodeData + } + }; + calculation1.InputParameters.Attach(calculation1Observer); + var calculation2 = new WaveImpactAsphaltCoverWaveConditionsCalculation + { + InputParameters = + { + ForeshoreProfile = nodeData + } + }; + calculation2.InputParameters.Attach(calculation2Observer); + var calculation3 = new WaveImpactAsphaltCoverWaveConditionsCalculation + { + InputParameters = + { + ForeshoreProfile = otherProfile + } + }; + calculation3.InputParameters.Attach(calculation3Observer); + + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism + { + ForeshoreProfiles = + { + nodeData, + otherProfile + }, + WaveConditionsCalculationGroup = + { + Children = + { + calculation1, + new CalculationGroup("A", true) + { + Children = + { + calculation2 + } + }, + calculation3 + } + } + }; + failureMechanism.ForeshoreProfiles.Attach(observer); + + var parentData = new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection); + + // Call + info.OnNodeRemoved(nodeData, parentData); + + // Assert + CollectionAssert.DoesNotContain(failureMechanism.ForeshoreProfiles, nodeData); + + Assert.IsNull(calculation1.InputParameters.ForeshoreProfile); + Assert.IsNull(calculation2.InputParameters.ForeshoreProfile); + Assert.AreSame(otherProfile, calculation3.InputParameters.ForeshoreProfile); + mocks.VerifyAll(); + } + + [Test] + public void OnNodeRemoved_ForeshoreProfileOfGrassCoverErosionOutwards_ForeshoreProfileRemovedFromFailureMechanism() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var observer = mocks.Stub(); + observer.Expect(o => o.UpdateObserver()); + mocks.ReplayAll(); + + var nodeData = new ForeshoreProfile(new Point2D(0, 0), new Point2D[0], null, new ForeshoreProfile.ConstructionProperties()); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism + { + ForeshoreProfiles = + { + nodeData + } + }; + failureMechanism.ForeshoreProfiles.Attach(observer); + + var parentData = new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection); + + // Call + info.OnNodeRemoved(nodeData, parentData); + + // Assert + CollectionAssert.DoesNotContain(failureMechanism.ForeshoreProfiles, nodeData); + mocks.VerifyAll(); + } + + [Test] + public void OnNodeRemoved_ForeshoreProfileOfGrassCoverErosionOutwardsWaveConditionsCalculation_CalculationForeshoreProfileCleared() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var observer = mocks.Stub(); + observer.Expect(o => o.UpdateObserver()); + var calculation1Observer = mocks.StrictMock(); + calculation1Observer.Expect(o => o.UpdateObserver()); + var calculation2Observer = mocks.StrictMock(); + calculation2Observer.Expect(o => o.UpdateObserver()); + var calculation3Observer = mocks.StrictMock(); + calculation3Observer.Expect(o => o.UpdateObserver()).Repeat.Never(); + mocks.ReplayAll(); + + var nodeData = new ForeshoreProfile(new Point2D(0, 0), new Point2D[0], null, new ForeshoreProfile.ConstructionProperties()); + var otherProfile = new ForeshoreProfile(new Point2D(1, 1), new Point2D[0], null, new ForeshoreProfile.ConstructionProperties()); + + var calculation1 = new GrassCoverErosionOutwardsWaveConditionsCalculation + { + InputParameters = + { + ForeshoreProfile = nodeData + } + }; + calculation1.InputParameters.Attach(calculation1Observer); + var calculation2 = new GrassCoverErosionOutwardsWaveConditionsCalculation + { + InputParameters = + { + ForeshoreProfile = nodeData + } + }; + calculation2.InputParameters.Attach(calculation2Observer); + var calculation3 = new GrassCoverErosionOutwardsWaveConditionsCalculation + { + InputParameters = + { + ForeshoreProfile = otherProfile + } + }; + calculation3.InputParameters.Attach(calculation3Observer); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism + { + ForeshoreProfiles = + { + nodeData, + otherProfile + }, + WaveConditionsCalculationGroup = + { + Children = + { + calculation1, + new CalculationGroup("A", true) + { + Children = + { + calculation2 + } + }, + calculation3 + } + } + }; + failureMechanism.ForeshoreProfiles.Attach(observer); + + var parentData = new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection); + + // Call + info.OnNodeRemoved(nodeData, parentData); + + // Assert + CollectionAssert.DoesNotContain(failureMechanism.ForeshoreProfiles, nodeData); + + Assert.IsNull(calculation1.InputParameters.ForeshoreProfile); + Assert.IsNull(calculation2.InputParameters.ForeshoreProfile); + Assert.AreSame(otherProfile, calculation3.InputParameters.ForeshoreProfile); + mocks.VerifyAll(); + } + + [Test] public void ContextMenuStrip_Always_CallsBuilder() { // Setup var mocks = new MockRepository(); var menuBuilderMock = mocks.StrictMock(); + menuBuilderMock.Expect(mb => mb.AddDeleteItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.Build()).Return(null); Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ImportInfos/ForeshoreProfilesContextImportInfoTest.cs =================================================================== diff -u -rf27092df1f897798c4a0b24f6fc91f49c9f294ce -rb5accd775c390fa85f815ef13c3c3e54a6d10ada --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ImportInfos/ForeshoreProfilesContextImportInfoTest.cs (.../ForeshoreProfilesContextImportInfoTest.cs) (revision f27092df1f897798c4a0b24f6fc91f49c9f294ce) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ImportInfos/ForeshoreProfilesContextImportInfoTest.cs (.../ForeshoreProfilesContextImportInfoTest.cs) (revision b5accd775c390fa85f815ef13c3c3e54a6d10ada) @@ -29,6 +29,7 @@ using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.IO.FileImporters; using Ringtoets.Integration.Plugin.Properties; @@ -45,11 +46,12 @@ ReferenceLine referenceLine = mocks.Stub(); var assessmentSection = mocks.Stub(); assessmentSection.ReferenceLine = referenceLine; + var failureMechanism = mocks.Stub(); mocks.ReplayAll(); var list = new ObservableList(); - var importTarget = new ForeshoreProfilesContext(list, assessmentSection); + var importTarget = new ForeshoreProfilesContext(list, failureMechanism, assessmentSection); using (var plugin = new RingtoetsPlugin()) { @@ -119,11 +121,12 @@ var mocks = new MockRepository(); var assessmentSection = mocks.Stub(); assessmentSection.ReferenceLine = new ReferenceLine(); + var failureMechanism = mocks.Stub(); mocks.ReplayAll(); var list = new ObservableList(); - var context = new ForeshoreProfilesContext(list, assessmentSection); + var context = new ForeshoreProfilesContext(list, failureMechanism, assessmentSection); using (var plugin = new RingtoetsPlugin()) { @@ -145,11 +148,12 @@ var mocks = new MockRepository(); var assessmentSection = mocks.Stub(); assessmentSection.ReferenceLine = null; + var failureMechanism = mocks.Stub(); mocks.ReplayAll(); var list = new ObservableList(); - var context = new ForeshoreProfilesContext(list, assessmentSection); + var context = new ForeshoreProfilesContext(list, failureMechanism, assessmentSection); using (var plugin = new RingtoetsPlugin()) { Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -r8723c31042f8aa4174e6d51a42f20d3665ec2da0 -rb5accd775c390fa85f815ef13c3c3e54a6d10ada --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingFailureMechanismContextTreeNodeInfoTest.cs (.../PipingFailureMechanismContextTreeNodeInfoTest.cs) (revision 8723c31042f8aa4174e6d51a42f20d3665ec2da0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingFailureMechanismContextTreeNodeInfoTest.cs (.../PipingFailureMechanismContextTreeNodeInfoTest.cs) (revision b5accd775c390fa85f815ef13c3c3e54a6d10ada) @@ -155,10 +155,12 @@ var surfaceLinesContext = (RingtoetsPipingSurfaceLinesContext) inputsFolder.Contents[1]; Assert.AreSame(pipingFailureMechanism.SurfaceLines, surfaceLinesContext.WrappedData); + Assert.AreSame(pipingFailureMechanism, surfaceLinesContext.FailureMechanism); Assert.AreSame(assessmentSection, surfaceLinesContext.AssessmentSection); var stochasticSoilModelContext = (StochasticSoilModelsContext) inputsFolder.Contents[2]; Assert.AreSame(pipingFailureMechanism, stochasticSoilModelContext.FailureMechanism); + Assert.AreSame(pipingFailureMechanism, stochasticSoilModelContext.FailureMechanism); Assert.AreSame(assessmentSection, stochasticSoilModelContext.AssessmentSection); var commentContext = (CommentContext) inputsFolder.Contents[3]; Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/StabilityPointStructuresPlugin.cs =================================================================== diff -u -r02d0e67121f748ae6d69ab9f68643d2f5e62f800 -rb5accd775c390fa85f815ef13c3c3e54a6d10ada --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/StabilityPointStructuresPlugin.cs (.../StabilityPointStructuresPlugin.cs) (revision 02d0e67121f748ae6d69ab9f68643d2f5e62f800) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/StabilityPointStructuresPlugin.cs (.../StabilityPointStructuresPlugin.cs) (revision b5accd775c390fa85f815ef13c3c3e54a6d10ada) @@ -312,7 +312,7 @@ return new object[] { new FailureMechanismSectionsContext(failureMechanism, assessmentSection), - new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, assessmentSection), + new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection), new StabilityPointStructuresContext(failureMechanism.StabilityPointStructures, assessmentSection), new CommentContext(failureMechanism) }; Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -r64eede81657b51fb755944fd3939ceefb839e591 -rb5accd775c390fa85f815ef13c3c3e54a6d10ada --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../StabilityPointStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision 64eede81657b51fb755944fd3939ceefb839e591) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../StabilityPointStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision b5accd775c390fa85f815ef13c3c3e54a6d10ada) @@ -129,6 +129,7 @@ var profilesContext = (ForeshoreProfilesContext) inputsFolder.Contents[1]; Assert.AreSame(failureMechanism.ForeshoreProfiles, profilesContext.WrappedData); + Assert.AreSame(failureMechanism, profilesContext.ParentFailureMechanism); Assert.AreSame(assessmentSectionMock, profilesContext.ParentAssessmentSection); var stabilityPointStructuresContext = (StabilityPointStructuresContext) inputsFolder.Contents[2]; Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/StabilityStoneCoverPlugin.cs =================================================================== diff -u -r02d0e67121f748ae6d69ab9f68643d2f5e62f800 -rb5accd775c390fa85f815ef13c3c3e54a6d10ada --- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/StabilityStoneCoverPlugin.cs (.../StabilityStoneCoverPlugin.cs) (revision 02d0e67121f748ae6d69ab9f68643d2f5e62f800) +++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/StabilityStoneCoverPlugin.cs (.../StabilityStoneCoverPlugin.cs) (revision b5accd775c390fa85f815ef13c3c3e54a6d10ada) @@ -214,7 +214,7 @@ return new ArrayList { new FailureMechanismSectionsContext(failureMechanism, assessmentSection), - new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, assessmentSection), + new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection), new CommentContext(failureMechanism) }; } Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -r0d98073e4ba2bdc6b69b7f875508488d1fa0148a -rb5accd775c390fa85f815ef13c3c3e54a6d10ada --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverFailureMechanismContextTreeNodeInfoTest.cs (.../StabilityStoneCoverFailureMechanismContextTreeNodeInfoTest.cs) (revision 0d98073e4ba2bdc6b69b7f875508488d1fa0148a) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverFailureMechanismContextTreeNodeInfoTest.cs (.../StabilityStoneCoverFailureMechanismContextTreeNodeInfoTest.cs) (revision b5accd775c390fa85f815ef13c3c3e54a6d10ada) @@ -196,6 +196,7 @@ var profilesContext = (ForeshoreProfilesContext) inputsFolder.Contents[1]; Assert.AreSame(failureMechanism.ForeshoreProfiles, profilesContext.WrappedData); + Assert.AreSame(failureMechanism, profilesContext.ParentFailureMechanism); Assert.AreSame(assessmentSection, profilesContext.ParentAssessmentSection); var commentContext = (CommentContext) inputsFolder.Contents[2]; Index: Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Plugin/WaveImpactAsphaltCoverPlugin.cs =================================================================== diff -u -r02d0e67121f748ae6d69ab9f68643d2f5e62f800 -rb5accd775c390fa85f815ef13c3c3e54a6d10ada --- Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Plugin/WaveImpactAsphaltCoverPlugin.cs (.../WaveImpactAsphaltCoverPlugin.cs) (revision 02d0e67121f748ae6d69ab9f68643d2f5e62f800) +++ Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Plugin/WaveImpactAsphaltCoverPlugin.cs (.../WaveImpactAsphaltCoverPlugin.cs) (revision b5accd775c390fa85f815ef13c3c3e54a6d10ada) @@ -217,7 +217,7 @@ return new ArrayList { new FailureMechanismSectionsContext(failureMechanism, assessmentSection), - new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, assessmentSection), + new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection), new CommentContext(failureMechanism) }; } Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -r2973c5f790a5131e427bd5f73e2a620044199639 -rb5accd775c390fa85f815ef13c3c3e54a6d10ada --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverFailureMechanismContextTreeNodeInfoTest.cs (.../WaveImpactAsphaltCoverFailureMechanismContextTreeNodeInfoTest.cs) (revision 2973c5f790a5131e427bd5f73e2a620044199639) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverFailureMechanismContextTreeNodeInfoTest.cs (.../WaveImpactAsphaltCoverFailureMechanismContextTreeNodeInfoTest.cs) (revision b5accd775c390fa85f815ef13c3c3e54a6d10ada) @@ -210,6 +210,7 @@ var foreshoreProfilesContext = (ForeshoreProfilesContext) inputsFolder.Contents[1]; Assert.AreSame(failureMechanism.ForeshoreProfiles, foreshoreProfilesContext.WrappedData); + Assert.AreSame(failureMechanism, foreshoreProfilesContext.ParentFailureMechanism); Assert.AreSame(assessmentSection, foreshoreProfilesContext.ParentAssessmentSection); var commentContext = (CommentContext) inputsFolder.Contents[2];