Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructureFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -rab20c4eb4ca81bd3845d50210d2bdb301177af6a -re8e7ca3dea8b9e1e45ca15f0276469e1197d8fe9 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructureFailureMechanismContextTreeNodeInfoTest.cs (.../ClosingStructureFailureMechanismContextTreeNodeInfoTest.cs) (revision ab20c4eb4ca81bd3845d50210d2bdb301177af6a) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructureFailureMechanismContextTreeNodeInfoTest.cs (.../ClosingStructureFailureMechanismContextTreeNodeInfoTest.cs) (revision e8e7ca3dea8b9e1e45ca15f0276469e1197d8fe9) @@ -27,11 +27,14 @@ 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.ClosingStructures.Data; +using Ringtoets.ClosingStructures.Data.TestUtil; using Ringtoets.ClosingStructures.Forms.PresentationObjects; using Ringtoets.ClosingStructures.Plugin; using Ringtoets.Common.Data; @@ -47,7 +50,7 @@ namespace Ringtoets.ClosingStructures.Forms.Test.TreeNodeInfos { [TestFixture] - public class ClosingStructureFailureMechanismContextTreeNodeInfoTest + public class ClosingStructureFailureMechanismContextTreeNodeInfoTest : NUnitFormTest { private const int contextMenuRelevancyIndexWhenRelevant = 0; private const int contextMenuRelevancyIndexWhenNotRelevant = 0; @@ -71,7 +74,7 @@ } [TearDown] - public void TearDown() + public override void TearDown() { plugin.Dispose(); @@ -583,5 +586,93 @@ } } } + + [Test] + public void ContextMenuStrip_ClickOnCalculateAllItem_ScheduleAllChildCalculations() + { + // Setup + var guiMock = mocksRepository.StrictMock(); + var mainWindowStub = mocksRepository.Stub(); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + var failureMechanism = new ClosingStructuresFailureMechanism(); + + var section = new FailureMechanismSection("A", new[] + { + new Point2D(0, 0), + new Point2D(2, 2) + }); + failureMechanism.AddSection(section); + + failureMechanism.CalculationsGroup.Children.Add(new TestClosingStructuresCalculation + { + Name = "A", + InputParameters = + { + HydraulicBoundaryLocation = new HydraulicBoundaryLocation(-1, "nonExisting", 1, 2), + Structure = new TestClosingStructure() + } + }); + failureMechanism.CalculationsGroup.Children.Add(new TestClosingStructuresCalculation + { + Name = "B", + InputParameters = + { + HydraulicBoundaryLocation = new HydraulicBoundaryLocation(-1, "nonExisting", 1, 2), + Structure = new TestClosingStructure() + } + }); + + string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); + + var hydraulicBoundaryDatabaseStub = mocksRepository.Stub(); + hydraulicBoundaryDatabaseStub.FilePath = validFilePath; + + var assessmentSectionMock = mocksRepository.Stub(); + assessmentSectionMock.HydraulicBoundaryDatabase = hydraulicBoundaryDatabaseStub; + + var failureMechanismContext = new ClosingStructuresFailureMechanismContext(failureMechanism, assessmentSectionMock); + + using (var treeViewControl = new TreeViewControl()) + { + guiMock.Expect(g => g.Get(failureMechanismContext, treeViewControl)).Return(menuBuilder); + guiMock.Expect(g => g.MainWindow).Return(mainWindowStub); + + mocksRepository.ReplayAll(); + + plugin.Gui = guiMock; + + DialogBoxHandler = (name, wnd) => + { + // Expect an activity dialog which is automatically closed + }; + + using (var contextMenu = info.ContextMenuStrip(failureMechanismContext, null, treeViewControl)) + { + // Call + TestHelper.AssertLogMessages(() => contextMenu.Items[contextMenuCalculateAllIndex].PerformClick(), messages => + { + var messageList = messages.ToList(); + + // Assert + Assert.AreEqual(14, messageList.Count); + StringAssert.StartsWith("Validatie van 'A' gestart om: ", messageList[0]); + StringAssert.StartsWith("Validatie van 'A' beëindigd om: ", messageList[1]); + StringAssert.StartsWith("Berekening van 'A' gestart om: ", messageList[2]); + Assert.AreEqual("De berekening voor kunstwerk sluiten 'A' is niet gelukt.", messageList[3]); + StringAssert.StartsWith("Betrouwbaarheid sluiting kunstwerk berekeningsverslag. Klik op details voor meer informatie.", messageList[4]); + StringAssert.StartsWith("Berekening van 'A' beëindigd om: ", messageList[5]); + StringAssert.StartsWith("Validatie van 'B' gestart om: ", messageList[6]); + StringAssert.StartsWith("Validatie van 'B' beëindigd om: ", messageList[7]); + StringAssert.StartsWith("Berekening van 'B' gestart om: ", messageList[8]); + Assert.AreEqual("De berekening voor kunstwerk sluiten 'B' is niet gelukt.", messageList[9]); + StringAssert.StartsWith("Betrouwbaarheid sluiting kunstwerk berekeningsverslag. Klik op details voor meer informatie.", messageList[10]); + StringAssert.StartsWith("Berekening van 'B' beëindigd om: ", messageList[11]); + Assert.AreEqual("Uitvoeren van 'A' is mislukt.", messageList[12]); + Assert.AreEqual("Uitvoeren van 'B' is mislukt.", messageList[13]); + }); + } + } + } } } \ No newline at end of file