Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -rc046d22cfc010414d21bda8cc15806530e315ca3 -r1279dcba187f56c0ba96dfdb962067304e333475 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs (.../PipingCalculationGroupContextTreeNodeInfoTest.cs) (revision c046d22cfc010414d21bda8cc15806530e315ca3) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs (.../PipingCalculationGroupContextTreeNodeInfoTest.cs) (revision 1279dcba187f56c0ba96dfdb962067304e333475) @@ -1129,6 +1129,12 @@ plugin.Gui = gui; + // Precondition + foreach (var failureMechanismSectionResult in pipingFailureMechanism.SectionResults) + { + CollectionAssert.IsEmpty(failureMechanismSectionResult.CalculationScenarios); + } + DialogBoxHandler = (name, wnd) => { var selectionDialog = new FormTester(name).TheObject as PipingSurfaceLineSelectionDialog; @@ -1161,6 +1167,117 @@ } [Test] + public void GivenPipingCalculationsViewGenerateScenariosButtonClicked_WhenCancelButtonClickedAndDialogClosed_ThenSectionResultScenariosNotUpdated() + { + // Given + var gui = mocks.StrictMock(); + var treeViewControl = mocks.StrictMock(); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + var group = new PipingCalculationGroup(); + + var pipingFailureMechanism = new PipingFailureMechanism(); + var assessmentSectionMock = mocks.StrictMock(); + + var mainWindow = mocks.Stub(); + var parentData = new PipingFailureMechanismContext(pipingFailureMechanism, assessmentSectionMock); + + var surfaceLine1 = new RingtoetsPipingSurfaceLine + { + Name = "Surface line 1", + ReferenceLineIntersectionWorldPoint = new Point2D(0.0, 0.0) + }; + + surfaceLine1.SetGeometry(new[] + { + new Point3D(0.0, 5.0, 0.0), + new Point3D(0.0, 0.0, 1.0), + new Point3D(0.0, -5.0, 0.0) + }); + + var surfaceLine2 = new RingtoetsPipingSurfaceLine + { + Name = "Surface line 2", + ReferenceLineIntersectionWorldPoint = new Point2D(5.0, 0.0) + }; + + surfaceLine2.SetGeometry(new[] + { + new Point3D(5.0, 5.0, 0.0), + new Point3D(5.0, 0.0, 1.0), + new Point3D(5.0, -5.0, 0.0) + }); + + var surfaceLines = new[] + { + surfaceLine1, + surfaceLine2 + }; + pipingFailureMechanism.AddSection(new FailureMechanismSection("Section 1", new List + { + new Point2D(0.0, 0.0), + new Point2D(5.0, 0.0) + })); + + pipingFailureMechanism.AddSection(new FailureMechanismSection("Section 2", new List + { + new Point2D(5.0, 0.0), + new Point2D(10.0, 0.0) + })); + + var nodeData = new PipingCalculationGroupContext(group, + surfaceLines, + new[] + { + new TestStochasticSoilModel + { + Geometry = + { + new Point2D(0.0, 0.0), new Point2D(5.0, 0.0) + }, + } + }, + pipingFailureMechanism, + assessmentSectionMock); + + gui.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Expect(g => g.MainWindow).Return(mainWindow); + + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Precondition + foreach (var failureMechanismSectionResult in pipingFailureMechanism.SectionResults) + { + CollectionAssert.IsEmpty(failureMechanismSectionResult.CalculationScenarios); + } + + DialogBoxHandler = (name, wnd) => + { + var selectionDialog = new FormTester(name).TheObject as PipingSurfaceLineSelectionDialog; + var grid = new ControlTester("SurfaceLineDataGrid", selectionDialog).TheObject as DataGridView; + + grid.Rows[0].Cells[0].Value = true; + + new ButtonTester("CustomCancelButton", selectionDialog).Click(); + }; + + var contextMenu = info.ContextMenuStrip(nodeData, parentData, treeViewControl); + + // When + contextMenu.Items[contextMenuAddGenerateCalculationsIndex].PerformClick(); + + // Then + foreach (var failureMechanismSectionResult in pipingFailureMechanism.SectionResults) + { + CollectionAssert.IsEmpty(failureMechanismSectionResult.CalculationScenarios); + } + + mocks.VerifyAll(); + } + + [Test] public void CanRenameNode_ParentIsPipingFailureMechanismContext_ReturnFalse() { // Setup