Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructuresCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -rb390c81c577202ae453281e2c1c6f983fabab240 -r029ff0ad40fcb7568d712e8be786a57a949a0b8c --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../ClosingStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision b390c81c577202ae453281e2c1c6f983fabab240) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../ClosingStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision 029ff0ad40fcb7568d712e8be786a57a949a0b8c) @@ -21,6 +21,7 @@ using System.Linq; using System.Windows.Forms; +using Core.Common.Base; using Core.Common.Controls.TreeView; using Core.Common.Gui; using Core.Common.Gui.Commands; @@ -326,5 +327,73 @@ } } } + + [Test] + public void OnNodeRemoved_NestedCalculationGroup_RemoveGroupAndNotifyObservers() + { + // Setup + var observerMock = mocks.StrictMock(); + var failureMechanism = new ClosingStructuresFailureMechanism(); + var assessmentSectionMock = mocks.Stub(); + var group = new CalculationGroup(); + var parentGroup = new CalculationGroup(); + var nodeData = new ClosingStructuresCalculationGroupContext(group, + failureMechanism, + assessmentSectionMock); + var parentNodeData = new ClosingStructuresCalculationGroupContext(parentGroup, + failureMechanism, + assessmentSectionMock); + + observerMock.Expect(o => o.UpdateObserver()); + + mocks.ReplayAll(); + + parentGroup.Children.Add(group); + parentNodeData.Attach(observerMock); + + // Precondition + Assert.IsTrue(info.CanRemove(nodeData, parentNodeData)); + + // Call + info.OnNodeRemoved(nodeData, parentNodeData); + + // Assert + CollectionAssert.DoesNotContain(parentGroup.Children, group); + } + + [Test] + public void OnNodeRemoved_NestedCalculationGroupContainingCalculations_RemoveGroupAndCalculationsAndNotifyObservers() + { + // Setup + var observerMock = mocks.StrictMock(); + var assessmentSectionMock = mocks.Stub(); + var failureMechanism = new ClosingStructuresFailureMechanism(); + var group = new CalculationGroup(); + var parentGroup = new CalculationGroup(); + var nodeData = new ClosingStructuresCalculationGroupContext(group, + failureMechanism, + assessmentSectionMock); + var parentNodeData = new ClosingStructuresCalculationGroupContext(parentGroup, + failureMechanism, + assessmentSectionMock); + var calculation = new ClosingStructuresCalculation(); + + observerMock.Expect(o => o.UpdateObserver()); + + mocks.ReplayAll(); + + group.Children.Add(calculation); + parentGroup.Children.Add(group); + parentNodeData.Attach(observerMock); + + // Precondition + Assert.IsTrue(info.CanRemove(nodeData, parentNodeData)); + + // Call + info.OnNodeRemoved(nodeData, parentNodeData); + + // Assert + CollectionAssert.DoesNotContain(parentGroup.Children, group); + } } } \ No newline at end of file