Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PresentationObjects/ClosingStructuresContext.cs =================================================================== diff -u -r078878de01a4c060d2366b7406fe5236940827ad -rd705284acf98d459d09b5b2afd48ec3a629c9a3f --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PresentationObjects/ClosingStructuresContext.cs (.../ClosingStructuresContext.cs) (revision 078878de01a4c060d2366b7406fe5236940827ad) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PresentationObjects/ClosingStructuresContext.cs (.../ClosingStructuresContext.cs) (revision d705284acf98d459d09b5b2afd48ec3a629c9a3f) @@ -36,22 +36,33 @@ /// Creates an instance of . /// /// The wrapped containing . + /// The failure mechanism which the closing structures belong to. /// The assessment section which the closing structures belong to. /// Thrown when any of the input arguments are null. - public ClosingStructuresContext(ObservableList closingStructures, IAssessmentSection assessmentSection) + public ClosingStructuresContext(ObservableList closingStructures, ClosingStructuresFailureMechanism failureMechanism, IAssessmentSection assessmentSection) : base(closingStructures) { if (assessmentSection == null) { throw new ArgumentNullException("assessmentSection"); } + if (failureMechanism == null) + { + throw new ArgumentNullException("failureMechanism"); + } + ParentFailureMechanism = failureMechanism; AssessmentSection = assessmentSection; } /// /// Gets the assessment section of this instance. /// public IAssessmentSection AssessmentSection { get; private set; } + + /// + /// Gets the failure mechanism of this instance. + /// + public ClosingStructuresFailureMechanism ParentFailureMechanism { get; private set; } } } \ No newline at end of file Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs =================================================================== diff -u -rb5accd775c390fa85f815ef13c3c3e54a6d10ada -rd705284acf98d459d09b5b2afd48ec3a629c9a3f --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs (.../ClosingStructuresPlugin.cs) (revision b5accd775c390fa85f815ef13c3c3e54a6d10ada) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs (.../ClosingStructuresPlugin.cs) (revision d705284acf98d459d09b5b2afd48ec3a629c9a3f) @@ -24,6 +24,7 @@ using System.Drawing; using System.Linq; using System.Windows.Forms; +using Core.Common.Base; using Core.Common.Controls.TreeView; using Core.Common.Gui.ContextMenu; using Core.Common.Gui.Forms.ProgressDialog; @@ -125,6 +126,8 @@ ForeColor = context => context.WrappedData.Any() ? Color.FromKnownColor(KnownColor.ControlText) : Color.FromKnownColor(KnownColor.GrayText), ChildNodeObjects = context => context.WrappedData.Cast().ToArray(), ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl) + .AddDeleteChildrenItem() + .AddSeparator() .AddImportItem() .AddSeparator() .AddExpandAllItem() @@ -137,8 +140,12 @@ Text = structure => structure.Name, Image = structure => RingtoetsCommonFormsResources.StructuresIcon, ContextMenuStrip = (structure, parentData, treeViewControl) => Gui.Get(structure, treeViewControl) + .AddDeleteItem() + .AddSeparator() .AddPropertiesItem() - .Build() + .Build(), + CanRemove = CanRemoveClosingStructure, + OnNodeRemoved = OnClosingStructureRemoved }; yield return new TreeNodeInfo @@ -289,7 +296,7 @@ { new FailureMechanismSectionsContext(failureMechanism, assessmentSection), new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection), - new ClosingStructuresContext(failureMechanism.ClosingStructures, assessmentSection), + new ClosingStructuresContext(failureMechanism.ClosingStructures, failureMechanism, assessmentSection), new CommentContext(failureMechanism) }; } @@ -620,6 +627,41 @@ #endregion + #region ClosingStructure TreeNodeInfo + + private bool CanRemoveClosingStructure(ClosingStructure nodeData, object parentData) + { + return parentData is ClosingStructuresContext; + } + + private void OnClosingStructureRemoved(ClosingStructure nodeData, object parentData) + { + var parentContext = (ClosingStructuresContext) parentData; + var changedObservables = new List(); + StructuresCalculation[] closingStructureCalculations = parentContext.ParentFailureMechanism.Calculations + .Cast>() + .ToArray(); + StructuresCalculation[] calculationWithRemovedClosingStructure = closingStructureCalculations + .Where(c => ReferenceEquals(c.InputParameters.Structure, nodeData)) + .ToArray(); + foreach (StructuresCalculation calculation in calculationWithRemovedClosingStructure) + { + calculation.InputParameters.Structure = null; + StructuresHelper.Delete(parentContext.ParentFailureMechanism.SectionResults, calculation, closingStructureCalculations); + changedObservables.Add(calculation.InputParameters); + } + + parentContext.WrappedData.Remove(nodeData); + changedObservables.Add(parentContext.WrappedData); + + foreach (IObservable observable in changedObservables) + { + observable.NotifyObservers(); + } + } + #endregion + + #endregion } } \ No newline at end of file Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PresentationObjects/ClosingStructuresContextTest.cs =================================================================== diff -u -r078878de01a4c060d2366b7406fe5236940827ad -rd705284acf98d459d09b5b2afd48ec3a629c9a3f --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PresentationObjects/ClosingStructuresContextTest.cs (.../ClosingStructuresContextTest.cs) (revision 078878de01a4c060d2366b7406fe5236940827ad) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PresentationObjects/ClosingStructuresContextTest.cs (.../ClosingStructuresContextTest.cs) (revision d705284acf98d459d09b5b2afd48ec3a629c9a3f) @@ -41,29 +41,48 @@ var assessmentSectionMock = mocks.Stub(); mocks.ReplayAll(); - var closingStructures = new ObservableList(); + var failureMechanism = new ClosingStructuresFailureMechanism(); // Call - var context = new ClosingStructuresContext(closingStructures, assessmentSectionMock); + var context = new ClosingStructuresContext(failureMechanism.ClosingStructures, failureMechanism, assessmentSectionMock); // Assert Assert.IsInstanceOf>>(context); - Assert.AreSame(closingStructures, context.WrappedData); + Assert.AreSame(failureMechanism.ClosingStructures, context.WrappedData); Assert.AreSame(assessmentSectionMock, context.AssessmentSection); mocks.VerifyAll(); } [Test] - public void ParameteredConstructor_AssessmentSectionNull_ThrowsArgumentNullException() + public void ParameteredConstructor_FailureMechanismNull_ThrowsArgumentNullException() { // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + var closingStructures = new ObservableList(); // Call - TestDelegate test = () => new ClosingStructuresContext(closingStructures, null); + TestDelegate test = () => new ClosingStructuresContext(closingStructures, null, assessmentSection); // Assert var exception = Assert.Throws(test); + Assert.AreEqual("failureMechanism", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void ParameteredConstructor_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Setup + var failureMechanism = new ClosingStructuresFailureMechanism(); + + // Call + TestDelegate test = () => new ClosingStructuresContext(failureMechanism.ClosingStructures, failureMechanism, null); + + // Assert + var exception = Assert.Throws(test); Assert.AreEqual("assessmentSection", exception.ParamName); } } Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructureFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -rb5accd775c390fa85f815ef13c3c3e54a6d10ada -rd705284acf98d459d09b5b2afd48ec3a629c9a3f --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructureFailureMechanismContextTreeNodeInfoTest.cs (.../ClosingStructureFailureMechanismContextTreeNodeInfoTest.cs) (revision b5accd775c390fa85f815ef13c3c3e54a6d10ada) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructureFailureMechanismContextTreeNodeInfoTest.cs (.../ClosingStructureFailureMechanismContextTreeNodeInfoTest.cs) (revision d705284acf98d459d09b5b2afd48ec3a629c9a3f) @@ -143,6 +143,7 @@ var closingStructuresContext = (ClosingStructuresContext) inputsFolder.Contents[2]; Assert.AreSame(failureMechanism.ClosingStructures, closingStructuresContext.WrappedData); + Assert.AreSame(failureMechanism, closingStructuresContext.ParentFailureMechanism); Assert.AreSame(assessmentSectionMock, closingStructuresContext.AssessmentSection); var commentContext = (CommentContext) inputsFolder.Contents[3]; Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructureTreeNodeInfoTest.cs =================================================================== diff -u -rf9e4f420b403e6417f5dc2ba6d7beab9424baf89 -rd705284acf98d459d09b5b2afd48ec3a629c9a3f --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructureTreeNodeInfoTest.cs (.../ClosingStructureTreeNodeInfoTest.cs) (revision f9e4f420b403e6417f5dc2ba6d7beab9424baf89) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructureTreeNodeInfoTest.cs (.../ClosingStructureTreeNodeInfoTest.cs) (revision d705284acf98d459d09b5b2afd48ec3a629c9a3f) @@ -21,6 +21,8 @@ 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; @@ -29,7 +31,12 @@ using Rhino.Mocks; using Ringtoets.ClosingStructures.Data; using Ringtoets.ClosingStructures.Data.TestUtil; +using Ringtoets.ClosingStructures.Forms.PresentationObjects; using Ringtoets.ClosingStructures.Plugin; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.Structures; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; namespace Ringtoets.ClosingStructures.Forms.Test.TreeNodeInfos @@ -72,8 +79,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); @@ -112,10 +117,241 @@ } [Test] + public void CanRemove_ParentIsClosingStructuresContext_ReturnTrue() + { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new ClosingStructuresFailureMechanism(); + + var parentData = new ClosingStructuresContext(failureMechanism.ClosingStructures, failureMechanism, assessmentSection); + + // Call + bool canRemove = info.CanRemove(null, parentData); + + // Assert + Assert.IsTrue(canRemove); + } + + [Test] + public void CanRemove_ParentIsNotClosingStructuresContext_ReturnFalse() + { + // Call + bool canRemove = info.CanRemove(null, null); + + // Assert + Assert.IsFalse(canRemove); + } + + [Test] + public void OnNodeRemoved_RemovingProfileFromContainer_ProfileRemovedFromContainer() + { + // Setup + var assessmentSection = mocks.Stub(); + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + mocks.ReplayAll(); + + ClosingStructure nodeData = new TestClosingStructure(); + var failureMechanism = new ClosingStructuresFailureMechanism + { + ClosingStructures = + { + nodeData + } + }; + failureMechanism.ClosingStructures.Attach(observer); + + var parentData = new ClosingStructuresContext(failureMechanism.ClosingStructures, failureMechanism, assessmentSection); + + // Call + info.OnNodeRemoved(nodeData, parentData); + + // Assert + CollectionAssert.DoesNotContain(failureMechanism.ClosingStructures, nodeData); + } + + [Test] + public void OnNodeRemoved_RemovingProfilePartOfCalculation_CalculationProfileCleared() + { + // Setup + 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(); + + ClosingStructure nodeData = new TestClosingStructure("A"); + ClosingStructure otherProfile = new TestClosingStructure("B"); + + var calculation1 = new StructuresCalculation + { + InputParameters = + { + Structure = nodeData + } + }; + calculation1.InputParameters.Attach(calculation1Observer); + var calculation2 = new StructuresCalculation + { + InputParameters = + { + Structure = nodeData + } + }; + calculation2.InputParameters.Attach(calculation2Observer); + var calculation3 = new StructuresCalculation + { + InputParameters = + { + Structure = otherProfile + } + }; + calculation3.InputParameters.Attach(calculation3Observer); + + var calculationGroup = new CalculationGroup("A", true) + { + Children = + { + calculation2 + } + }; + + var failureMechanism = new ClosingStructuresFailureMechanism + { + ClosingStructures = + { + nodeData, + otherProfile + }, + CalculationsGroup = + { + Children = + { + calculation1, + calculationGroup, + calculation3 + } + } + }; + failureMechanism.ClosingStructures.Attach(observer); + + var parentData = new ClosingStructuresContext(failureMechanism.ClosingStructures, failureMechanism, assessmentSection); + + // Call + info.OnNodeRemoved(nodeData, parentData); + + // Assert + CollectionAssert.DoesNotContain(failureMechanism.ClosingStructures, nodeData); + + Assert.IsNull(calculation1.InputParameters.Structure); + Assert.IsNull(calculation2.InputParameters.Structure); + Assert.IsNotNull(calculation3.InputParameters.Structure); + } + + [Test] + public void OnNodeRemoved_RemovingProfilePartOfCalculationOfSectionResult_SectionResultCalculationCleared() + { + // Setup + 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 TestClosingStructure(new Point2D(0, 0)); + var otherProfile1 = new TestClosingStructure(new Point2D(1, 0)); + var otherProfile2 = new TestClosingStructure(new Point2D(5, 0)); + + var calculation1 = new StructuresCalculation + { + InputParameters = + { + Structure = nodeData + } + }; + calculation1.InputParameters.Attach(calculation1Observer); + var calculation2 = new StructuresCalculation + { + InputParameters = + { + Structure = otherProfile1 + } + }; + calculation2.InputParameters.Attach(calculation2Observer); + var calculation3 = new StructuresCalculation + { + InputParameters = + { + Structure = otherProfile2 + } + }; + calculation3.InputParameters.Attach(calculation3Observer); + + var failureMechanism = new ClosingStructuresFailureMechanism + { + ClosingStructures = + { + 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.ClosingStructures.Attach(observer); + failureMechanism.SectionResults.ElementAt(0).Calculation = calculation1; + failureMechanism.SectionResults.ElementAt(1).Calculation = calculation3; + + var parentData = new ClosingStructuresContext(failureMechanism.ClosingStructures, failureMechanism, assessmentSection); + + // Call + info.OnNodeRemoved(nodeData, parentData); + + // Assert + CollectionAssert.DoesNotContain(failureMechanism.ClosingStructures, nodeData); + + Assert.IsNull(calculation1.InputParameters.Structure); + Assert.IsNotNull(calculation2.InputParameters.Structure); + + Assert.AreSame(calculation2, failureMechanism.SectionResults.ElementAt(0).Calculation); + Assert.AreSame(calculation3, failureMechanism.SectionResults.ElementAt(1).Calculation); + } + + [Test] public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods() { // Setup 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/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructuresContextTreeNodeInfoTest.cs =================================================================== diff -u -r3f40e34c76b06d66a6426c7e07fb3a101b4952cb -rd705284acf98d459d09b5b2afd48ec3a629c9a3f --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructuresContextTreeNodeInfoTest.cs (.../ClosingStructuresContextTreeNodeInfoTest.cs) (revision 3f40e34c76b06d66a6426c7e07fb3a101b4952cb) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructuresContextTreeNodeInfoTest.cs (.../ClosingStructuresContextTreeNodeInfoTest.cs) (revision d705284acf98d459d09b5b2afd48ec3a629c9a3f) @@ -21,7 +21,6 @@ using System.Drawing; using System.Linq; -using Core.Common.Base; using Core.Common.Controls.TreeView; using Core.Common.Gui; using Core.Common.Gui.ContextMenu; @@ -88,9 +87,9 @@ var assessmentSection = mocks.Stub(); mocks.ReplayAll(); - var closingStructures = new ObservableList(); + var failureMechanism = new ClosingStructuresFailureMechanism(); - var closingStructuresContext = new ClosingStructuresContext(closingStructures, assessmentSection); + var closingStructuresContext = new ClosingStructuresContext(failureMechanism.ClosingStructures, failureMechanism, assessmentSection); // Call string text = info.Text(closingStructuresContext); @@ -109,9 +108,9 @@ var assessmentSection = mocks.Stub(); mocks.ReplayAll(); - var closingStructures = new ObservableList(); + var failureMechanism = new ClosingStructuresFailureMechanism(); - var closingStructuresContext = new ClosingStructuresContext(closingStructures, assessmentSection); + var closingStructuresContext = new ClosingStructuresContext(failureMechanism.ClosingStructures, failureMechanism, assessmentSection); // Call Image image = info.Image(closingStructuresContext); @@ -129,15 +128,18 @@ var asssessmentSection = mocks.Stub(); mocks.ReplayAll(); - var closingStructures = new ObservableList + var failureMechanism = new ClosingStructuresFailureMechanism { - new TestClosingStructure() + ClosingStructures = + { + new TestClosingStructure() + } }; // Precondition - CollectionAssert.IsNotEmpty(closingStructures); + CollectionAssert.IsNotEmpty(failureMechanism.ClosingStructures); - var closingStructuresContext = new ClosingStructuresContext(closingStructures, asssessmentSection); + var closingStructuresContext = new ClosingStructuresContext(failureMechanism.ClosingStructures, failureMechanism, asssessmentSection); // Call Color color = info.ForeColor(closingStructuresContext); @@ -157,13 +159,16 @@ ClosingStructure closingStructure1 = new TestClosingStructure(); ClosingStructure closingStructure2 = new TestClosingStructure(); - var closingStructures = new ObservableList + var failureMechanism = new ClosingStructuresFailureMechanism { - closingStructure1, - closingStructure2 + ClosingStructures = + { + closingStructure1, + closingStructure2 + } }; - var closingStructuresContext = new ClosingStructuresContext(closingStructures, assessmentSection); + var closingStructuresContext = new ClosingStructuresContext(failureMechanism.ClosingStructures, failureMechanism, assessmentSection); // Call var children = info.ChildNodeObjects(closingStructuresContext); @@ -183,12 +188,12 @@ var asssessmentSection = mocks.Stub(); mocks.ReplayAll(); - var closingStructures = new ObservableList(); + var failureMechanism = new ClosingStructuresFailureMechanism(); // Precondition - CollectionAssert.IsEmpty(closingStructures); + CollectionAssert.IsEmpty(failureMechanism.ClosingStructures); - var closingStructuresContext = new ClosingStructuresContext(closingStructures, asssessmentSection); + var closingStructuresContext = new ClosingStructuresContext(failureMechanism.ClosingStructures, failureMechanism, asssessmentSection); // Call Color color = info.ForeColor(closingStructuresContext); @@ -204,6 +209,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/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/ImportInfos/ClosingStructuresContextImportInfoTest.cs =================================================================== diff -u -r396f21603d742cdfb0e92817e5fd0b4df1e9f851 -rd705284acf98d459d09b5b2afd48ec3a629c9a3f --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/ImportInfos/ClosingStructuresContextImportInfoTest.cs (.../ClosingStructuresContextImportInfoTest.cs) (revision 396f21603d742cdfb0e92817e5fd0b4df1e9f851) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/ImportInfos/ClosingStructuresContextImportInfoTest.cs (.../ClosingStructuresContextImportInfoTest.cs) (revision d705284acf98d459d09b5b2afd48ec3a629c9a3f) @@ -21,7 +21,6 @@ using System.Drawing; using System.Linq; -using Core.Common.Base; using Core.Common.Base.IO; using Core.Common.Gui.Plugin; using Core.Common.TestUtil; @@ -47,9 +46,9 @@ assessmentSectionMock.ReferenceLine = new ReferenceLine(); mocks.ReplayAll(); - var list = new ObservableList(); + var failureMechanism = new ClosingStructuresFailureMechanism(); - var importTarget = new ClosingStructuresContext(list, assessmentSectionMock); + var importTarget = new ClosingStructuresContext(failureMechanism.ClosingStructures, failureMechanism, assessmentSectionMock); using (var plugin = new ClosingStructuresPlugin()) { @@ -137,8 +136,8 @@ assessmentSectionMock.ReferenceLine = new ReferenceLine(); mocks.ReplayAll(); - var list = new ObservableList(); - var context = new ClosingStructuresContext(list, assessmentSectionMock); + var failureMechanism = new ClosingStructuresFailureMechanism(); + var context = new ClosingStructuresContext(failureMechanism.ClosingStructures, failureMechanism, assessmentSectionMock); using (var plugin = new ClosingStructuresPlugin()) { @@ -161,8 +160,8 @@ var assessmentSectionMock = mocks.Stub(); mocks.ReplayAll(); - var list = new ObservableList(); - var context = new ClosingStructuresContext(list, assessmentSectionMock); + var failureMechanism = new ClosingStructuresFailureMechanism(); + var context = new ClosingStructuresContext(failureMechanism.ClosingStructures, failureMechanism, assessmentSectionMock); using (var plugin = new ClosingStructuresPlugin()) { Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs =================================================================== diff -u -r2545a8486f7c2820781ec3871125bdd8121622fd -rd705284acf98d459d09b5b2afd48ec3a629c9a3f --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs (.../HeightStructuresPlugin.cs) (revision 2545a8486f7c2820781ec3871125bdd8121622fd) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs (.../HeightStructuresPlugin.cs) (revision d705284acf98d459d09b5b2afd48ec3a629c9a3f) @@ -239,16 +239,16 @@ { var parentContext = (HeightStructuresContext) parentData; var changedObservables = new List(); - StructuresCalculation[] grassCoverErosionInwardsCalculations = parentContext.ParentFailureMechanism.Calculations - .Cast>() - .ToArray(); - StructuresCalculation[] calculationWithRemovedHeightStructure = grassCoverErosionInwardsCalculations + StructuresCalculation[] heightStructureCalculations = parentContext.ParentFailureMechanism.Calculations + .Cast>() + .ToArray(); + StructuresCalculation[] calculationWithRemovedHeightStructure = heightStructureCalculations .Where(c => ReferenceEquals(c.InputParameters.Structure, nodeData)) .ToArray(); foreach (StructuresCalculation calculation in calculationWithRemovedHeightStructure) { calculation.InputParameters.Structure = null; - StructuresHelper.Delete(parentContext.ParentFailureMechanism.SectionResults, calculation, grassCoverErosionInwardsCalculations); + StructuresHelper.Delete(parentContext.ParentFailureMechanism.SectionResults, calculation, heightStructureCalculations); changedObservables.Add(calculation.InputParameters); } Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructureTreeNodeInfoTest.cs =================================================================== diff -u -r2545a8486f7c2820781ec3871125bdd8121622fd -rd705284acf98d459d09b5b2afd48ec3a629c9a3f --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructureTreeNodeInfoTest.cs (.../HeightStructureTreeNodeInfoTest.cs) (revision 2545a8486f7c2820781ec3871125bdd8121622fd) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructureTreeNodeInfoTest.cs (.../HeightStructureTreeNodeInfoTest.cs) (revision d705284acf98d459d09b5b2afd48ec3a629c9a3f) @@ -277,9 +277,9 @@ calculation3Observer.Expect(o => o.UpdateObserver()).Repeat.Never(); mocks.ReplayAll(); - var nodeData = new TestHeightStructure("A"); - var otherProfile1 = new TestHeightStructure("B"); - var otherProfile2 = new TestHeightStructure("C"); + var nodeData = new TestHeightStructure(new Point2D(1, 0)); + var otherProfile1 = new TestHeightStructure(new Point2D(2, 0)); + var otherProfile2 = new TestHeightStructure(new Point2D(6, 0)); var calculation1 = new StructuresCalculation {