Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PresentationObjects/DikeProfilesContext.cs =================================================================== diff -u -r8805f03189f521994b42a519bbca7561bf12eb68 -raaad7a7ca8557c045aa8d6d4031be9133d2f34a6 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PresentationObjects/DikeProfilesContext.cs (.../DikeProfilesContext.cs) (revision 8805f03189f521994b42a519bbca7561bf12eb68) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PresentationObjects/DikeProfilesContext.cs (.../DikeProfilesContext.cs) (revision aaad7a7ca8557c045aa8d6d4031be9133d2f34a6) @@ -24,6 +24,7 @@ using Core.Common.Controls.PresentationObjects; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.GrassCoverErosionInwards.Data; namespace Ringtoets.GrassCoverErosionInwards.Forms.PresentationObjects { @@ -37,21 +38,31 @@ /// Initializes a new instance of the class. /// /// The observable list of dike profiles. + /// The parent failure mechanism. /// The parent assessment section. - /// Thrown when either - /// or is null. - public DikeProfilesContext(ObservableList dikeProfilesList, IAssessmentSection parentAssessmentSection) : base(dikeProfilesList) + /// Thrown when any input argument is null. + public DikeProfilesContext(ObservableList dikeProfilesList, GrassCoverErosionInwardsFailureMechanism parentFailureMechanism, IAssessmentSection parentAssessmentSection) : base(dikeProfilesList) { 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 GrassCoverErosionInwardsFailureMechanism ParentFailureMechanism { get; private set; } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs =================================================================== diff -u -rb66269d1c3435557b993a5daa333612017f6ccfd -raaad7a7ca8557c045aa8d6d4031be9133d2f34a6 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs (.../GrassCoverErosionInwardsPlugin.cs) (revision b66269d1c3435557b993a5daa333612017f6ccfd) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs (.../GrassCoverErosionInwardsPlugin.cs) (revision aaad7a7ca8557c045aa8d6d4031be9133d2f34a6) @@ -118,6 +118,8 @@ .Cast() .ToArray(), ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl) + .AddDeleteChildrenItem() + .AddSeparator() .AddImportItem() .AddSeparator() .AddCollapseAllItem() @@ -332,7 +334,7 @@ return new ArrayList { new FailureMechanismSectionsContext(failureMechanism, assessmentSection), - new DikeProfilesContext(failureMechanism.DikeProfiles, assessmentSection), + new DikeProfilesContext(failureMechanism.DikeProfiles, failureMechanism, assessmentSection), new CommentContext(failureMechanism) }; } Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PresentationObjects/DikeProfilesContextTest.cs =================================================================== diff -u -r30b8231f92b90ea4b05e98e3d0285368f6dfe2e4 -raaad7a7ca8557c045aa8d6d4031be9133d2f34a6 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PresentationObjects/DikeProfilesContextTest.cs (.../DikeProfilesContextTest.cs) (revision 30b8231f92b90ea4b05e98e3d0285368f6dfe2e4) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PresentationObjects/DikeProfilesContextTest.cs (.../DikeProfilesContextTest.cs) (revision aaad7a7ca8557c045aa8d6d4031be9133d2f34a6) @@ -26,6 +26,7 @@ using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.GrassCoverErosionInwards.Data; using Ringtoets.GrassCoverErosionInwards.Forms.PresentationObjects; namespace Ringtoets.GrassCoverErosionInwards.Forms.Test.PresentationObjects @@ -41,14 +42,14 @@ var assessmentSection = mocks.Stub(); mocks.ReplayAll(); - var dikeProfilesList = new ObservableList(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); // Call - var context = new DikeProfilesContext(dikeProfilesList, assessmentSection); + var context = new DikeProfilesContext(failureMechanism.DikeProfiles, failureMechanism, assessmentSection); // Assert Assert.IsInstanceOf>>(context); - Assert.AreSame(dikeProfilesList, context.WrappedData); + Assert.AreSame(failureMechanism.DikeProfiles, context.WrappedData); Assert.AreSame(assessmentSection, context.ParentAssessmentSection); mocks.VerifyAll(); } @@ -61,8 +62,10 @@ var assessmentSection = mocks.Stub(); mocks.ReplayAll(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + // Call - TestDelegate call = () => new DikeProfilesContext(null, assessmentSection); + TestDelegate call = () => new DikeProfilesContext(null, failureMechanism, assessmentSection); // Assert string paramName = Assert.Throws(call).ParamName; @@ -71,10 +74,32 @@ } [Test] + public void Constructor_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var dikeProfiles = new ObservableList(); + + // Call + TestDelegate call = () => new DikeProfilesContext(dikeProfiles, null, assessmentSection); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("parentFailureMechanism", paramName); + mocks.VerifyAll(); + } + + [Test] public void Constructor_AssessmentSectionIsNull_ThrowArgumentNullException() { + // Setup + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + // Call - TestDelegate call = () => new DikeProfilesContext(new ObservableList(), null); + TestDelegate call = () => new DikeProfilesContext(failureMechanism.DikeProfiles, failureMechanism, null); // Assert string paramName = Assert.Throws(call).ParamName; Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/DikeProfilesContextTreeNodeInfoTest.cs =================================================================== diff -u -r30b8231f92b90ea4b05e98e3d0285368f6dfe2e4 -raaad7a7ca8557c045aa8d6d4031be9133d2f34a6 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/DikeProfilesContextTreeNodeInfoTest.cs (.../DikeProfilesContextTreeNodeInfoTest.cs) (revision 30b8231f92b90ea4b05e98e3d0285368f6dfe2e4) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/DikeProfilesContextTreeNodeInfoTest.cs (.../DikeProfilesContextTreeNodeInfoTest.cs) (revision aaad7a7ca8557c045aa8d6d4031be9133d2f34a6) @@ -21,7 +21,6 @@ using System.Drawing; using System.Linq; -using Core.Common.Base; using Core.Common.Base.Geometry; using Core.Common.Controls.TreeView; using Core.Common.Gui; @@ -31,6 +30,7 @@ using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.GrassCoverErosionInwards.Data; using Ringtoets.GrassCoverErosionInwards.Forms.PresentationObjects; using Ringtoets.GrassCoverErosionInwards.Plugin; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; @@ -88,9 +88,9 @@ var assessmentSection = mocks.Stub(); mocks.ReplayAll(); - var dikeProfiles = new ObservableList(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var dikeProfilesContext = new DikeProfilesContext(dikeProfiles, assessmentSection); + var dikeProfilesContext = new DikeProfilesContext(failureMechanism.DikeProfiles, failureMechanism, assessmentSection); // Call string text = info.Text(dikeProfilesContext); @@ -109,9 +109,9 @@ var assessmentSection = mocks.Stub(); mocks.ReplayAll(); - var dikeProfiles = new ObservableList(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var dikeProfilesContext = new DikeProfilesContext(dikeProfiles, assessmentSection); + var dikeProfilesContext = new DikeProfilesContext(failureMechanism.DikeProfiles, failureMechanism, assessmentSection); // Call Image image = info.Image(dikeProfilesContext); @@ -129,12 +129,12 @@ var asssessmentSection = mocks.Stub(); mocks.ReplayAll(); - var dikeProfiles = new ObservableList(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); // Precondition - CollectionAssert.IsEmpty(dikeProfiles); + CollectionAssert.IsEmpty(failureMechanism.DikeProfiles); - var context = new DikeProfilesContext(dikeProfiles, asssessmentSection); + var context = new DikeProfilesContext(failureMechanism.DikeProfiles, failureMechanism, asssessmentSection); // Call Color color = info.ForeColor(context); @@ -152,15 +152,18 @@ var asssessmentSection = mocks.Stub(); mocks.ReplayAll(); - var dikeProfiles = new ObservableList + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism { - CreateDikeProfile() + DikeProfiles = + { + CreateDikeProfile() + } }; // Precondition - CollectionAssert.IsNotEmpty(dikeProfiles); + CollectionAssert.IsNotEmpty(failureMechanism.DikeProfiles); - var context = new DikeProfilesContext(dikeProfiles, asssessmentSection); + var context = new DikeProfilesContext(failureMechanism.DikeProfiles, failureMechanism, asssessmentSection); // Call Color color = info.ForeColor(context); @@ -180,13 +183,16 @@ DikeProfile dikeProfile1 = CreateDikeProfile(); DikeProfile dikeProfile2 = CreateDikeProfile(); - var dikeProfiles = new ObservableList + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism { - dikeProfile1, - dikeProfile2 + DikeProfiles = + { + dikeProfile1, + dikeProfile2 + } }; - var dikeProfilesContext = new DikeProfilesContext(dikeProfiles, assessmentSection); + var dikeProfilesContext = new DikeProfilesContext(failureMechanism.DikeProfiles, failureMechanism, assessmentSection); // Call var children = info.ChildNodeObjects(dikeProfilesContext); @@ -204,6 +210,8 @@ // Setup var mocks = new MockRepository(); var menuBuilderMock = mocks.StrictMock(); + menuBuilderMock.Expect(mb => mb.AddDeleteChildrenItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddImportItem()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilderMock); Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Ringtoets.Integration.Plugin.csproj =================================================================== diff -u -rbc4c4000ca4a850b49a88156ca2b919ea690494b -raaad7a7ca8557c045aa8d6d4031be9133d2f34a6 --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Ringtoets.Integration.Plugin.csproj (.../Ringtoets.Integration.Plugin.csproj) (revision bc4c4000ca4a850b49a88156ca2b919ea690494b) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Ringtoets.Integration.Plugin.csproj (.../Ringtoets.Integration.Plugin.csproj) (revision aaad7a7ca8557c045aa8d6d4031be9133d2f34a6) @@ -111,6 +111,10 @@ Ringtoets.ClosingStructures.Forms False + + {99573570-ee00-4264-8147-26a1b25db23f} + Ringtoets.GrassCoverErosionInwards.Utils + {3D4B9740-8348-4434-8D77-B611FC6EE57F} Ringtoets.StabilityPointStructures.Data Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs =================================================================== diff -u -rf08fd5cc1482a6c706bdb04d46b6482d489b7c5b -raaad7a7ca8557c045aa8d6d4031be9133d2f34a6 --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision f08fd5cc1482a6c706bdb04d46b6482d489b7c5b) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision aaad7a7ca8557c045aa8d6d4031be9133d2f34a6) @@ -26,6 +26,7 @@ using System.Drawing; using System.Linq; using System.Windows.Forms; +using Core.Common.Base; using Core.Common.Base.Data; using Core.Common.Controls.TreeView; using Core.Common.Controls.Views; @@ -56,6 +57,7 @@ using Ringtoets.Common.IO.ReferenceLines; using Ringtoets.GrassCoverErosionInwards.Data; using Ringtoets.GrassCoverErosionInwards.Forms.PresentationObjects; +using Ringtoets.GrassCoverErosionInwards.Utils; using Ringtoets.GrassCoverErosionOutwards.Data; using Ringtoets.GrassCoverErosionOutwards.Forms.PresentationObjects; using Ringtoets.HeightStructures.Data; @@ -599,8 +601,12 @@ Text = dikeProfile => dikeProfile.Name, Image = context => RingtoetsCommonFormsResources.DikeProfile, ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl) + .AddDeleteItem() + .AddSeparator() .AddPropertiesItem() - .Build() + .Build(), + CanRemove = CanRemoveDikeProfile, + OnNodeRemoved = OnDikeProfileRemoved }; yield return new TreeNodeInfo @@ -835,6 +841,41 @@ } } + #region DikeProfile TreeNodeInfo + + private bool CanRemoveDikeProfile(DikeProfile nodeData, object parentData) + { + return parentData is DikeProfilesContext; + } + + private void OnDikeProfileRemoved(DikeProfile nodeData, object parentData) + { + var parentContext = (DikeProfilesContext) parentData; + var changedObservables = new List(); + GrassCoverErosionInwardsCalculation[] grassCoverErosionInwardsCalculations = parentContext.ParentFailureMechanism.Calculations + .Cast() + .ToArray(); + GrassCoverErosionInwardsCalculation[] calculationWithRemovedDikeProfile = grassCoverErosionInwardsCalculations + .Where(c => ReferenceEquals(c.InputParameters.DikeProfile, nodeData)) + .ToArray(); + foreach (GrassCoverErosionInwardsCalculation calculation in calculationWithRemovedDikeProfile) + { + calculation.InputParameters.DikeProfile = null; + GrassCoverErosionInwardsHelper.Delete(parentContext.ParentFailureMechanism.SectionResults, calculation, grassCoverErosionInwardsCalculations); + changedObservables.Add(calculation.InputParameters); + } + + parentContext.WrappedData.Remove(nodeData); + changedObservables.Add(parentContext.WrappedData); + + foreach (IObservable observable in changedObservables) + { + observable.NotifyObservers(); + } + } + + #endregion + #region Comment ViewInfo private static bool CloseCommentViewForData(CommentView commentView, object o) Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/DikeProfileTreeNodeInfoTest.cs =================================================================== diff -u -r5b132f482c79bbf041e6f8ebc20bd79b3f5037e8 -raaad7a7ca8557c045aa8d6d4031be9133d2f34a6 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/DikeProfileTreeNodeInfoTest.cs (.../DikeProfileTreeNodeInfoTest.cs) (revision 5b132f482c79bbf041e6f8ebc20bd79b3f5037e8) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/DikeProfileTreeNodeInfoTest.cs (.../DikeProfileTreeNodeInfoTest.cs) (revision aaad7a7ca8557c045aa8d6d4031be9133d2f34a6) @@ -21,14 +21,20 @@ 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.GrassCoverErosionInwards.Data; +using Ringtoets.GrassCoverErosionInwards.Forms.PresentationObjects; using Ringtoets.Integration.Plugin; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; @@ -66,8 +72,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); @@ -106,11 +110,250 @@ } [Test] + public void CanRemove_ParentIsDikeProfilesContext_ReturnTrue() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + + var parentData = new DikeProfilesContext(failureMechanism.DikeProfiles, failureMechanism, assessmentSection); + + // Call + bool canRemove = info.CanRemove(null, parentData); + + // Assert + Assert.IsTrue(canRemove); + mocks.VerifyAll(); + } + + [Test] + public void CanRemove_ParentIsNotDikeProfilesContext_ReturnFalse() + { + // Call + bool canRemove = info.CanRemove(null, null); + + // Assert + Assert.IsFalse(canRemove); + } + + [Test] + public void OnNodeRemoved_RemovingProfileFromContainer_ProfileRemovedFromContainer() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + mocks.ReplayAll(); + + var nodeData = new DikeProfile(new Point2D(0,0), new RoughnessPoint[0], new Point2D[0], null, new DikeProfile.ConstructionProperties()); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism + { + DikeProfiles = + { + nodeData + } + }; + failureMechanism.DikeProfiles.Attach(observer); + + var parentData = new DikeProfilesContext(failureMechanism.DikeProfiles, failureMechanism, assessmentSection); + + // Call + info.OnNodeRemoved(nodeData, parentData); + + // Assert + CollectionAssert.DoesNotContain(failureMechanism.DikeProfiles, nodeData); + mocks.VerifyAll(); + } + + [Test] + public void OnNodeRemoved_RemovingProfilePartOfCalculation_CalculationProfileCleared() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var observer = mocks.StrictMock(); + 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 DikeProfile(new Point2D(0, 0), new RoughnessPoint[0], new Point2D[0], null, new DikeProfile.ConstructionProperties()); + var otherProfile = new DikeProfile(new Point2D(1, 1), new RoughnessPoint[0], new Point2D[0], null, new DikeProfile.ConstructionProperties()); + + var calculation1 = new GrassCoverErosionInwardsCalculation + { + InputParameters = + { + DikeProfile = nodeData + } + }; + calculation1.InputParameters.Attach(calculation1Observer); + var calculation2 = new GrassCoverErosionInwardsCalculation + { + InputParameters = + { + DikeProfile = nodeData + } + }; + calculation2.InputParameters.Attach(calculation2Observer); + var calculation3 = new GrassCoverErosionInwardsCalculation + { + InputParameters = + { + DikeProfile = otherProfile + } + }; + calculation3.InputParameters.Attach(calculation3Observer); + + var calculationGroup = new CalculationGroup("A", true) + { + Children = + { + calculation2 + } + }; + + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism + { + DikeProfiles = + { + nodeData, + otherProfile + }, + CalculationsGroup = + { + Children = + { + calculation1, + calculationGroup, + calculation3 + } + } + }; + failureMechanism.DikeProfiles.Attach(observer); + + var parentData = new DikeProfilesContext(failureMechanism.DikeProfiles, failureMechanism, assessmentSection); + + // Call + info.OnNodeRemoved(nodeData, parentData); + + // Assert + CollectionAssert.DoesNotContain(failureMechanism.DikeProfiles, nodeData); + + Assert.IsNull(calculation1.InputParameters.DikeProfile); + Assert.IsNull(calculation2.InputParameters.DikeProfile); + Assert.IsNotNull(calculation3.InputParameters.DikeProfile); + mocks.VerifyAll(); + } + + [Test] + public void OnNodeRemoved_RemovingProfilePartOfCalculationOfSectionResult_SectionResultCalculationCleared() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + var calculation1Observer = mocks.StrictMock(); + calculation1Observer.Expect(o => o.UpdateObserver()); + var calculation2Observer = mocks.StrictMock(); + calculation2Observer.Expect(o => o.UpdateObserver()).Repeat.Never(); + var calculation3Observer = mocks.StrictMock(); + calculation3Observer.Expect(o => o.UpdateObserver()).Repeat.Never(); + mocks.ReplayAll(); + + var nodeData = new DikeProfile(new Point2D(1, 0), new RoughnessPoint[0], new Point2D[0], null, new DikeProfile.ConstructionProperties()); + var otherProfile1 = new DikeProfile(new Point2D(2, 0), new RoughnessPoint[0], new Point2D[0], null, new DikeProfile.ConstructionProperties()); + var otherProfile2 = new DikeProfile(new Point2D(7, 0), new RoughnessPoint[0], new Point2D[0], null, new DikeProfile.ConstructionProperties()); + + var calculation1 = new GrassCoverErosionInwardsCalculation + { + InputParameters = + { + DikeProfile = nodeData + } + }; + calculation1.InputParameters.Attach(calculation1Observer); + var calculation2 = new GrassCoverErosionInwardsCalculation + { + InputParameters = + { + DikeProfile = otherProfile1 + } + }; + calculation2.InputParameters.Attach(calculation2Observer); + var calculation3 = new GrassCoverErosionInwardsCalculation + { + InputParameters = + { + DikeProfile = otherProfile2 + } + }; + calculation3.InputParameters.Attach(calculation3Observer); + + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism + { + DikeProfiles = + { + nodeData, + otherProfile1, + otherProfile2 + }, + CalculationsGroup = + { + Children = + { + calculation1, + calculation2 + } + } + }; + failureMechanism.AddSection(new FailureMechanismSection("A", new [] + { + new Point2D(0, 0), + new Point2D(4, 0) + })); + failureMechanism.AddSection(new FailureMechanismSection("B", new[] + { + new Point2D(4, 0), + new Point2D(9, 0) + })); + failureMechanism.DikeProfiles.Attach(observer); + failureMechanism.SectionResults.ElementAt(0).Calculation = calculation1; + failureMechanism.SectionResults.ElementAt(1).Calculation = calculation3; + + var parentData = new DikeProfilesContext(failureMechanism.DikeProfiles, failureMechanism, assessmentSection); + + // Call + info.OnNodeRemoved(nodeData, parentData); + + // Assert + CollectionAssert.DoesNotContain(failureMechanism.DikeProfiles, nodeData); + + Assert.IsNull(calculation1.InputParameters.DikeProfile); + Assert.IsNotNull(calculation2.InputParameters.DikeProfile); + + Assert.AreSame(calculation2, failureMechanism.SectionResults.ElementAt(0).Calculation); + Assert.AreSame(calculation3, failureMechanism.SectionResults.ElementAt(1).Calculation); + 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/DikeProfilesContextImportInfoTest.cs =================================================================== diff -u -rf27092df1f897798c4a0b24f6fc91f49c9f294ce -raaad7a7ca8557c045aa8d6d4031be9133d2f34a6 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ImportInfos/DikeProfilesContextImportInfoTest.cs (.../DikeProfilesContextImportInfoTest.cs) (revision f27092df1f897798c4a0b24f6fc91f49c9f294ce) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ImportInfos/DikeProfilesContextImportInfoTest.cs (.../DikeProfilesContextImportInfoTest.cs) (revision aaad7a7ca8557c045aa8d6d4031be9133d2f34a6) @@ -30,6 +30,7 @@ using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.IO.FileImporters; +using Ringtoets.GrassCoverErosionInwards.Data; using Ringtoets.GrassCoverErosionInwards.Forms.PresentationObjects; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; @@ -48,9 +49,9 @@ assessmentSection.ReferenceLine = referenceLine; mocks.ReplayAll(); - var list = new ObservableList(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var importTarget = new DikeProfilesContext(list, assessmentSection); + var importTarget = new DikeProfilesContext(failureMechanism.DikeProfiles, failureMechanism, assessmentSection); using (var plugin = new RingtoetsPlugin()) { @@ -122,9 +123,9 @@ assessmentSection.ReferenceLine = new ReferenceLine(); mocks.ReplayAll(); - var list = new ObservableList(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var context = new DikeProfilesContext(list, assessmentSection); + var context = new DikeProfilesContext(failureMechanism.DikeProfiles, failureMechanism, assessmentSection); using (var plugin = new RingtoetsPlugin()) { @@ -148,9 +149,9 @@ assessmentSection.ReferenceLine = null; mocks.ReplayAll(); - var list = new ObservableList(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var context = new DikeProfilesContext(list, assessmentSection); + var context = new DikeProfilesContext(failureMechanism.DikeProfiles, failureMechanism, assessmentSection); using (var plugin = new RingtoetsPlugin()) { Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj =================================================================== diff -u -rf27092df1f897798c4a0b24f6fc91f49c9f294ce -raaad7a7ca8557c045aa8d6d4031be9133d2f34a6 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision f27092df1f897798c4a0b24f6fc91f49c9f294ce) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision aaad7a7ca8557c045aa8d6d4031be9133d2f34a6) @@ -135,6 +135,10 @@ {d951d6da-fe83-4920-9fdb-63bf96480b54} Ringtoets.Common.Service + + {90de728e-48ef-4665-ab38-3d88e41d9f4d} + Ringtoets.GrassCoverErosionInwards.Data + {C540E627-B95B-4CC0-A1B6-A0BDF74936C7} Ringtoets.GrassCoverErosionInwards.Forms