Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs =================================================================== diff -u -ra7f920661887773056c051edc7872d27f724c840 -rcb3a673ff68d4d740090cba57a013876d26b1fc3 --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs (.../ClosingStructuresPlugin.cs) (revision a7f920661887773056c051edc7872d27f724c840) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs (.../ClosingStructuresPlugin.cs) (revision cb3a673ff68d4d740090cba57a013876d26b1fc3) @@ -152,9 +152,8 @@ ChildNodeObjects = context => context.WrappedData.Cast().ToArray(), ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl) .AddImportItem() + .AddUpdateItem() .AddSeparator() - .AddDeleteChildrenItem() - .AddSeparator() .AddCollapseAllItem() .AddExpandAllItem() .AddSeparator() @@ -167,12 +166,8 @@ Text = structure => structure.Name, Image = structure => RingtoetsCommonFormsResources.StructuresIcon, ContextMenuStrip = (structure, parentData, treeViewControl) => Gui.Get(structure, treeViewControl) - .AddDeleteItem() - .AddSeparator() .AddPropertiesItem() - .Build(), - CanRemove = CanRemoveClosingStructure, - OnNodeRemoved = OnClosingStructureRemoved + .Build() }; yield return new TreeNodeInfo @@ -712,26 +707,6 @@ #endregion - #region ClosingStructure TreeNodeInfo - - private static bool CanRemoveClosingStructure(ClosingStructure nodeData, object parentData) - { - return parentData is ClosingStructuresContext; - } - - private static void OnClosingStructureRemoved(ClosingStructure nodeData, object parentData) - { - var parentContext = (ClosingStructuresContext) parentData; - IEnumerable changedObservables = ClosingStructuresDataSynchronizationService.RemoveStructure(parentContext.FailureMechanism, - nodeData); - foreach (IObservable observable in changedObservables) - { - observable.NotifyObservers(); - } - } - #endregion - - #endregion } } \ No newline at end of file Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/TreeNodeInfos/ClosingStructureTreeNodeInfoTest.cs =================================================================== diff -u -r5f6b3f80bb6747f12157149f7689a8fc7d3552a5 -rcb3a673ff68d4d740090cba57a013876d26b1fc3 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/TreeNodeInfos/ClosingStructureTreeNodeInfoTest.cs (.../ClosingStructureTreeNodeInfoTest.cs) (revision 5f6b3f80bb6747f12157149f7689a8fc7d3552a5) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/TreeNodeInfos/ClosingStructureTreeNodeInfoTest.cs (.../ClosingStructureTreeNodeInfoTest.cs) (revision cb3a673ff68d4d740090cba57a013876d26b1fc3) @@ -77,8 +77,8 @@ Assert.IsNull(info.ChildNodeObjects); Assert.IsNull(info.CanRename); Assert.IsNull(info.OnNodeRenamed); - Assert.IsNotNull(info.CanRemove); - Assert.IsNotNull(info.OnNodeRemoved); + Assert.IsNull(info.CanRemove); + Assert.IsNull(info.OnNodeRemoved); Assert.IsNull(info.CanCheck); Assert.IsNull(info.IsChecked); Assert.IsNull(info.OnNodeChecked); @@ -117,133 +117,12 @@ } [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_RemovingProfilePartOfCalculationOfSectionResult_ProfileRemovedFromFailureMechanismAndCalculationProfileClearedAndSectionResultCalculationCleared() - { - // 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), "first"); - var otherStructure1 = new TestClosingStructure(new Point2D(1, 0), "second"); - var otherStructure2 = new TestClosingStructure(new Point2D(5, 0), "thrid"); - - var calculation1 = new StructuresCalculation - { - InputParameters = - { - Structure = nodeData - } - }; - calculation1.InputParameters.Attach(calculation1Observer); - var calculation2 = new StructuresCalculation - { - InputParameters = - { - Structure = otherStructure1 - } - }; - calculation2.InputParameters.Attach(calculation2Observer); - var calculation3 = new StructuresCalculation - { - InputParameters = - { - Structure = otherStructure2 - } - }; - calculation3.InputParameters.Attach(calculation3Observer); - - var failureMechanism = new ClosingStructuresFailureMechanism - { - CalculationsGroup = - { - Children = - { - calculation1, - calculation2, - calculation3 - } - } - }; - failureMechanism.ClosingStructures.AddRange(new[] - { - nodeData, - otherStructure1, - otherStructure2 - }, "some path"); - 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(); using (mocks.Ordered()) { - 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.Plugin.Test/TreeNodeInfos/ClosingStructuresContextTreeNodeInfoTest.cs =================================================================== diff -u -ra7f920661887773056c051edc7872d27f724c840 -rcb3a673ff68d4d740090cba57a013876d26b1fc3 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/TreeNodeInfos/ClosingStructuresContextTreeNodeInfoTest.cs (.../ClosingStructuresContextTreeNodeInfoTest.cs) (revision a7f920661887773056c051edc7872d27f724c840) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/TreeNodeInfos/ClosingStructuresContextTreeNodeInfoTest.cs (.../ClosingStructuresContextTreeNodeInfoTest.cs) (revision cb3a673ff68d4d740090cba57a013876d26b1fc3) @@ -208,9 +208,8 @@ using (mocks.Ordered()) { menuBuilderMock.Expect(mb => mb.AddImportItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddUpdateItem()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock); - menuBuilderMock.Expect(mb => mb.AddDeleteChildrenItem()).Return(menuBuilderMock); - menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);