Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r22e74c93c1d64ba15968ffd29bfdd6e1e79b84e3 -r4f2904ef28c50aef5b755ff4b6ef74c976995f7f --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision 22e74c93c1d64ba15968ffd29bfdd6e1e79b84e3) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision 4f2904ef28c50aef5b755ff4b6ef74c976995f7f) @@ -28,8 +28,10 @@ using Core.Common.Gui; using Core.Common.Gui.Commands; using Core.Common.Gui.ContextMenu; +using Core.Common.Gui.Forms.MainWindow; using Core.Common.Gui.TestUtil.ContextMenu; using Core.Common.TestUtil; +using NUnit.Extensions.Forms; using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; @@ -41,13 +43,14 @@ using Ringtoets.HeightStructures.Plugin; using Ringtoets.HeightStructures.Plugin.Properties; using Ringtoets.HydraRing.Data; +using Ringtoets.Integration.Data; using CoreCommonGuiResources = Core.Common.Gui.Properties.Resources; using RingtoetsFormsResources = Ringtoets.Common.Forms.Properties.Resources; namespace Ringtoets.HeightStructures.Forms.Test.TreeNodeInfos { [TestFixture] - public class HeightStructuresCalculationGroupContextTreeNodeInfoTest + public class HeightStructuresCalculationGroupContextTreeNodeInfoTest : NUnitFormTest { private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HydraRing.IO, "HydraulicBoundaryLocationReader"); @@ -547,6 +550,79 @@ } [Test] + public void ContextMenuStrip_ClickOnCalculateAllItem_ScheduleAllChildCalculations() + { + // Setup + var mainWindowStub = mocks.Stub(); + var treeViewControlMock = mocks.StrictMock(); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + var failureMechanism = new HeightStructuresFailureMechanism(); + + failureMechanism.AddSection(new FailureMechanismSection("A", new[] + { + new Point2D(0, 0) + })); + + failureMechanism.CalculationsGroup.Children.Add(new HeightStructuresCalculation(new GeneralHeightStructuresInput(), new NormProbabilityInput()) + { + Name = "A", + InputParameters = + { + HydraulicBoundaryLocation = new HydraulicBoundaryLocation(-1, "nonExisting", 1, 2) + } + }); + + failureMechanism.CalculationsGroup.Children.Add(new HeightStructuresCalculation(new GeneralHeightStructuresInput(), new NormProbabilityInput()) + { + Name = "B", + InputParameters = + { + HydraulicBoundaryLocation = new HydraulicBoundaryLocation(-1, "nonExisting", 1, 2) + } + }); + + string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); + + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + var hydraulicBoundaryDatabaseStub = mocks.Stub(); + hydraulicBoundaryDatabaseStub.FilePath = validFilePath; + assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabaseStub; + + var groupContext = new HeightStructuresCalculationGroupContext(failureMechanism.CalculationsGroup, + failureMechanism, + assessmentSection); + + guiMock.Expect(g => g.Get(groupContext, treeViewControlMock)).Return(menuBuilder); + guiMock.Expect(g => g.MainWindow).Return(mainWindowStub); + + mocks.ReplayAll(); + + plugin.Gui = guiMock; + var contextMenu = info.ContextMenuStrip(groupContext, null, treeViewControlMock); + + DialogBoxHandler = (name, wnd) => + { + // Expect an activity dialog which is automatically closed + }; + + // Call + TestHelper.AssertLogMessages(() => contextMenu.Items[contextMenuCalculateAllIndexRootGroup].PerformClick(), messages => + { + var messageList = messages.ToList(); + + // Assert + Assert.AreEqual(4, messageList.Count); + Assert.AreEqual("Er is een fout opgetreden tijdens de berekening.", messageList[0]); + Assert.AreEqual("Uitvoeren van 'A' is mislukt.", messageList[1]); + Assert.AreEqual("Er is een fout opgetreden tijdens de berekening.", messageList[2]); + Assert.AreEqual("Uitvoeren van 'B' is mislukt.", messageList[3]); + }); + + mocks.VerifyAll(); + } + + [Test] public void ContextMenuStrip_ClickOnAddGroupItem_AddGroupToCalculationGroupAndNotifyObservers() { // Setup