Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -rb6f4e414fc874653cc6ad84b80f330b28e69b823 -rfda32224be20ced8ee871a3ab495f11e55d48835 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs) (revision fda32224be20ced8ee871a3ab495f11e55d48835) @@ -816,6 +816,39 @@ Assert.IsNull(sectionResult.Calculation); } + [Test] + public void OnNodeRemoved_CalculationInGroupAssignedToSection_CalculationDetachedFromSection() + { + // Setup + var group = new CalculationGroup(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + var elementToBeRemoved = new GrassCoverErosionInwardsCalculation(); + var assessmentSectionStub = mocks.Stub(); + var calculationContext = new GrassCoverErosionInwardsCalculationContext(elementToBeRemoved, + failureMechanism, + assessmentSectionStub); + var groupContext = new GrassCoverErosionInwardsCalculationGroupContext(group, + failureMechanism, + assessmentSectionStub); + + mocks.ReplayAll(); + + group.Children.Add(elementToBeRemoved); + + failureMechanism.AddSection(new FailureMechanismSection("section", new[] + { + new Point2D(0, 0) + })); + + failureMechanism.SectionResults.First().Calculation = elementToBeRemoved; + + // Call + info.OnNodeRemoved(calculationContext, groupContext); + + // Assert + Assert.IsNull(failureMechanism.SectionResults.First().Calculation); + } + public override void TearDown() { plugin.Dispose(); Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -rb6f4e414fc874653cc6ad84b80f330b28e69b823 -rfda32224be20ced8ee871a3ab495f11e55d48835 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs) (revision fda32224be20ced8ee871a3ab495f11e55d48835) @@ -1157,6 +1157,41 @@ CollectionAssert.DoesNotContain(parentGroup.Children, group); } + [Test] + public void OnNodeRemoved_CalculationInGroupAssignedToSection_CalculationDetachedFromSection() + { + // Setup + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + var assessmentSectionStub = mocks.Stub(); + var group = new CalculationGroup(); + var parentGroup = new CalculationGroup(); + var nodeData = new GrassCoverErosionInwardsCalculationGroupContext(group, + failureMechanism, + assessmentSectionStub); + var parentNodeData = new GrassCoverErosionInwardsCalculationGroupContext(parentGroup, + failureMechanism, + assessmentSectionStub); + + mocks.ReplayAll(); + + parentGroup.Children.Add(group); + + failureMechanism.AddSection(new FailureMechanismSection("section", new[] + { + new Point2D(0, 0) + })); + + var calculation = new GrassCoverErosionInwardsCalculation(); + group.Children.Add(calculation); + failureMechanism.SectionResults.First().Calculation = calculation; + + // Call + info.OnNodeRemoved(nodeData, parentNodeData); + + // Assert + Assert.IsNull(failureMechanism.SectionResults.First().Calculation); + } + public override void TearDown() { plugin.Dispose(); Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -rf989a06ad41e4081dd1d155fafa263e94b070816 -rfda32224be20ced8ee871a3ab495f11e55d48835 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresCalculationContextTreeNodeInfoTest.cs (.../HeightStructuresCalculationContextTreeNodeInfoTest.cs) (revision f989a06ad41e4081dd1d155fafa263e94b070816) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresCalculationContextTreeNodeInfoTest.cs (.../HeightStructuresCalculationContextTreeNodeInfoTest.cs) (revision fda32224be20ced8ee871a3ab495f11e55d48835) @@ -759,6 +759,39 @@ CollectionAssert.DoesNotContain(group.Children, elementToBeRemoved); } + [Test] + public void OnNodeRemoved_CalculationInGroupAssignedToSection_CalculationDetachedFromSection() + { + // Setup + var group = new CalculationGroup(); + var failureMechanism = new HeightStructuresFailureMechanism(); + var elementToBeRemoved = new HeightStructuresCalculation(); + var assessmentSectionStub = mocks.Stub(); + var calculationContext = new HeightStructuresCalculationContext(elementToBeRemoved, + failureMechanism, + assessmentSectionStub); + var groupContext = new HeightStructuresCalculationGroupContext(group, + failureMechanism, + assessmentSectionStub); + + mocks.ReplayAll(); + + group.Children.Add(elementToBeRemoved); + + failureMechanism.AddSection(new FailureMechanismSection("section", new[] + { + new Point2D(0, 0) + })); + + failureMechanism.SectionResults.First().Calculation = elementToBeRemoved; + + // Call + info.OnNodeRemoved(calculationContext, groupContext); + + // Assert + Assert.IsNull(failureMechanism.SectionResults.First().Calculation); + } + public override void TearDown() { plugin.Dispose(); Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -rf989a06ad41e4081dd1d155fafa263e94b070816 -rfda32224be20ced8ee871a3ab495f11e55d48835 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision f989a06ad41e4081dd1d155fafa263e94b070816) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision fda32224be20ced8ee871a3ab495f11e55d48835) @@ -44,7 +44,6 @@ using Ringtoets.HeightStructures.Forms.PresentationObjects; using Ringtoets.HeightStructures.Plugin; using Ringtoets.HydraRing.Data; - using CoreCommonGuiResources = Core.Common.Gui.Properties.Resources; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; using RingtoetsCommonServiceResources = Ringtoets.Common.Service.Properties.Resources; @@ -1260,6 +1259,41 @@ } [Test] + public void OnNodeRemoved_CalculationInGroupAssignedToSection_CalculationDetachedFromSection() + { + // Setup + var failureMechanism = new HeightStructuresFailureMechanism(); + var assessmentSectionStub = mocks.Stub(); + var group = new CalculationGroup(); + var parentGroup = new CalculationGroup(); + var nodeData = new HeightStructuresCalculationGroupContext(group, + failureMechanism, + assessmentSectionStub); + var parentNodeData = new HeightStructuresCalculationGroupContext(parentGroup, + failureMechanism, + assessmentSectionStub); + + mocks.ReplayAll(); + + parentGroup.Children.Add(group); + + failureMechanism.AddSection(new FailureMechanismSection("section", new[] + { + new Point2D(0, 0) + })); + + var calculation = new HeightStructuresCalculation(); + group.Children.Add(calculation); + failureMechanism.SectionResults.First().Calculation = calculation; + + // Call + info.OnNodeRemoved(nodeData, parentNodeData); + + // Assert + Assert.IsNull(failureMechanism.SectionResults.First().Calculation); + } + + [Test] public void OnNodeRemoved_NestedCalculationGroupContainingCalculations_RemoveGroupAndCalculationsAndNotifyObservers() { // Setup