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 Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/StabilityPointStructuresPlugin.cs =================================================================== diff -u -rabcfb413c3e2024036761c3b05156c98cc2a8e44 -re8e7ca3dea8b9e1e45ca15f0276469e1197d8fe9 --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/StabilityPointStructuresPlugin.cs (.../StabilityPointStructuresPlugin.cs) (revision abcfb413c3e2024036761c3b05156c98cc2a8e44) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/StabilityPointStructuresPlugin.cs (.../StabilityPointStructuresPlugin.cs) (revision e8e7ca3dea8b9e1e45ca15f0276469e1197d8fe9) @@ -258,22 +258,18 @@ private static void ValidateAll(IEnumerable> calculations, IAssessmentSection assessmentSection) {} - private static void ValidateAll(StabilityPointStructuresFailureMechanismContext context) + private void CalculateAll(StabilityPointStructuresFailureMechanism failureMechanism, + IEnumerable> calculations, + IAssessmentSection assessmentSection) { - ValidateAll(context.WrappedData.Calculations.OfType>(), - context.Parent); + ActivityProgressDialogRunner.Run(Gui.MainWindow, + calculations.Select(calc => new StabilityPointStructuresCalculationActivity( + calc, + assessmentSection.HydraulicBoundaryDatabase.FilePath, + failureMechanism, + assessmentSection)).ToArray()); } - private static void ValidateAll(StabilityPointStructuresCalculationGroupContext context) - { - ValidateAll(context.WrappedData.GetCalculations().OfType>(), - context.AssessmentSection); - } - - private static void CalculateAll(StabilityPointStructuresFailureMechanismContext context) {} - - private static void CalculateAll(CalculationGroup group, StabilityPointStructuresCalculationGroupContext context) {} - #endregion #region TreeNodeInfo @@ -370,6 +366,18 @@ return ValidateAllDataAvailableAndGetErrorMessage(context.Parent, context.WrappedData); } + private static void ValidateAll(StabilityPointStructuresFailureMechanismContext context) + { + ValidateAll(context.WrappedData.Calculations.OfType>(), + context.Parent); + } + + private void CalculateAll(StabilityPointStructuresFailureMechanismContext context) + { + CalculateAll(context.WrappedData, context.WrappedData.Calculations.OfType>(), context.Parent); + } + + #endregion #region StabilityPointStructuresCalculationGroupContext TreeNodeInfo @@ -531,6 +539,17 @@ return ValidateAllDataAvailableAndGetErrorMessage(context.AssessmentSection, context.FailureMechanism); } + private static void ValidateAll(StabilityPointStructuresCalculationGroupContext context) + { + ValidateAll(context.WrappedData.GetCalculations().OfType>(), + context.AssessmentSection); + } + + private void CalculateAll(CalculationGroup group, StabilityPointStructuresCalculationGroupContext context) + { + CalculateAll(context.FailureMechanism, group.GetCalculations().OfType>(), context.AssessmentSection); + } + #endregion #region StabilityPointStructuresCalculationContext TreeNodeInfo Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r2678ee310030f02f415f1799c61635081d754165 -re8e7ca3dea8b9e1e45ca15f0276469e1197d8fe9 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision 2678ee310030f02f415f1799c61635081d754165) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision e8e7ca3dea8b9e1e45ca15f0276469e1197d8fe9) @@ -705,6 +705,94 @@ } [Test] + public void ContextMenuStrip_ClickOnCalculateAllItem_ScheduleAllChildCalculations() + { + // Setup + var mainWindowStub = mocks.Stub(); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + + failureMechanism.AddSection(new FailureMechanismSection("A", new[] + { + new Point2D(0, 0), + new Point2D(2, 2) + })); + + failureMechanism.CalculationsGroup.Children.Add(new TestStabilityPointStructuresCalculation + { + Name = "A", + InputParameters = + { + HydraulicBoundaryLocation = new HydraulicBoundaryLocation(-1, "nonExisting", 1, 2), + } + }); + + failureMechanism.CalculationsGroup.Children.Add(new TestStabilityPointStructuresCalculation + { + Name = "B", + InputParameters = + { + HydraulicBoundaryLocation = new HydraulicBoundaryLocation(-1, "nonExisting", 1, 2), + } + }); + + string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); + + var hydraulicBoundaryDatabaseStub = mocks.Stub(); + hydraulicBoundaryDatabaseStub.FilePath = validFilePath; + + var assessmentSectionStub = mocks.Stub(); + var groupContext = new StabilityPointStructuresCalculationGroupContext(failureMechanism.CalculationsGroup, + failureMechanism, + assessmentSectionStub); + + using (var treeViewControl = new TreeViewControl()) + { + guiMock.Expect(g => g.Get(groupContext, treeViewControl)).Return(menuBuilder); + guiMock.Expect(g => g.MainWindow).Return(mainWindowStub); + guiMock.Stub(cmp => cmp.ViewCommands).Return(mocks.Stub()); + + mocks.ReplayAll(); + + assessmentSectionStub.HydraulicBoundaryDatabase = hydraulicBoundaryDatabaseStub; + + plugin.Gui = guiMock; + + DialogBoxHandler = (name, wnd) => + { + // Expect an activity dialog which is automatically closed + }; + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(groupContext, null, treeViewControl)) + { + // Call + TestHelper.AssertLogMessages(() => contextMenu.Items[contextMenuCalculateAllIndexRootGroup].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 puntconstructies 'A' is niet gelukt.", messageList[3]); + StringAssert.StartsWith("Puntconstructies 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 puntconstructies 'B' is niet gelukt.", messageList[9]); + StringAssert.StartsWith("Puntconstructies 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]); + }); + } + } + } + + [Test] public void GivenCalculationsViewGenerateScenariosButtonClicked_WhenStabilityPointStructureSelectedAndDialogClosed_ThenCalculationsAddedWithStabilityPointStructureAssigned() { // Given Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -r9463e81bcdb5801a11cbc391c73961438f697551 -re8e7ca3dea8b9e1e45ca15f0276469e1197d8fe9 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../StabilityPointStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision 9463e81bcdb5801a11cbc391c73961438f697551) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../StabilityPointStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision e8e7ca3dea8b9e1e45ca15f0276469e1197d8fe9) @@ -27,8 +27,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; @@ -38,14 +40,15 @@ using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.HydraRing.Data; using Ringtoets.StabilityPointStructures.Data; +using Ringtoets.StabilityPointStructures.Data.TestUtil; using Ringtoets.StabilityPointStructures.Forms.PresentationObjects; using Ringtoets.StabilityPointStructures.Plugin; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; namespace Ringtoets.StabilityPointStructures.Forms.Test.TreeNodeInfos { [TestFixture] - public class StabilityPointStructuresFailureMechanismContextTreeNodeInfoTest + public class StabilityPointStructuresFailureMechanismContextTreeNodeInfoTest : NUnitFormTest { private const int contextMenuRelevancyIndexWhenRelevant = 0; private const int contextMenuRelevancyIndexWhenNotRelevant = 0; @@ -606,6 +609,96 @@ } } + [Test] + public void ContextMenuStrip_ClickOnCalculateAllItem_ScheduleAllChildCalculations() + { + // Setup + var guiMock = mocksRepository.StrictMock(); + var mainWindowStub = mocksRepository.Stub(); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + + var section = new FailureMechanismSection("A", new[] + { + new Point2D(0, 0), + new Point2D(2, 2) + }); + failureMechanism.AddSection(section); + + failureMechanism.CalculationsGroup.Children.Add(new TestStabilityPointStructuresCalculation + { + Name = "A", + InputParameters = + { + HydraulicBoundaryLocation = new HydraulicBoundaryLocation(-1, "nonExisting", 1, 2), + Structure = new TestStabilityPointStructure() + } + }); + failureMechanism.CalculationsGroup.Children.Add(new TestStabilityPointStructuresCalculation + { + Name = "B", + InputParameters = + { + HydraulicBoundaryLocation = new HydraulicBoundaryLocation(-1, "nonExisting", 1, 2), + Structure = new TestStabilityPointStructure() + } + }); + + string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); + + var hydraulicBoundaryDatabaseStub = mocksRepository.Stub(); + hydraulicBoundaryDatabaseStub.FilePath = validFilePath; + + var assessmentSectionMock = mocksRepository.Stub(); + assessmentSectionMock.HydraulicBoundaryDatabase = hydraulicBoundaryDatabaseStub; + + var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSectionMock); + + using (var plugin = new StabilityPointStructuresPlugin()) + using (var treeViewControl = new TreeViewControl()) + { + guiMock.Expect(g => g.Get(failureMechanismContext, treeViewControl)).Return(menuBuilder); + guiMock.Expect(g => g.MainWindow).Return(mainWindowStub); + + mocksRepository.ReplayAll(); + + var info = GetInfo(plugin); + 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 puntconstructies 'A' is niet gelukt.", messageList[3]); + StringAssert.StartsWith("Puntconstructies 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 puntconstructies 'B' is niet gelukt.", messageList[9]); + StringAssert.StartsWith("Puntconstructies 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]); + }); + } + } + } + private static TreeNodeInfo GetInfo(StabilityPointStructuresPlugin plugin) { return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(StabilityPointStructuresFailureMechanismContext));