Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -r02670d8c9fceeaea5f829937a2eb269f3488c6b1 -re92866220b9db723bb193729dc1928015e02f200 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs) (revision 02670d8c9fceeaea5f829937a2eb269f3488c6b1) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs) (revision e92866220b9db723bb193729dc1928015e02f200) @@ -265,11 +265,11 @@ } [Test] - public void ContextMenuStrip_NomSections_ContextMenuItemPerformCalculationDisabledAndTooltipSet() + public void ContextMenuStrip_NoSections_ContextMenuItemPerformCalculationDisabledAndTooltipSet() { // Setup var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var assessmentSectionMock = mocks.StrictMock(); + var assessmentSectionMock = mocks.Stub(); var calculation = new GrassCoverErosionInwardsCalculation(); var nodeData = new GrassCoverErosionInwardsCalculationContext(calculation, failureMechanism, assessmentSectionMock); Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -r2efa0fbe22fee2482e1583a7d6f5ccfdf168f660 -re92866220b9db723bb193729dc1928015e02f200 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresCalculationContextTreeNodeInfoTest.cs (.../StabilityPointStructuresCalculationContextTreeNodeInfoTest.cs) (revision 2efa0fbe22fee2482e1583a7d6f5ccfdf168f660) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresCalculationContextTreeNodeInfoTest.cs (.../StabilityPointStructuresCalculationContextTreeNodeInfoTest.cs) (revision e92866220b9db723bb193729dc1928015e02f200) @@ -44,6 +44,7 @@ using Ringtoets.StabilityPointStructures.Plugin; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; using RingtoetsCommonServiceResources = Ringtoets.Common.Service.Properties.Resources; +using RingtoetsCommonServicesResources = Ringtoets.Common.Service.Properties.Resources; namespace Ringtoets.StabilityPointStructures.Forms.Test.TreeNodeInfos { @@ -259,6 +260,297 @@ } [Test] + public void ContextMenuStrip_NoFailureMechanismSections_ContextMenuItemPerformCalculationDisabledAndTooltipSet() + { + // Setup + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + var assessmentSectionMock = mocks.Stub(); + var calculation = new StabilityPointStructuresCalculation(); + var nodeData = new StabilityPointStructuresCalculationContext(calculation, failureMechanism, assessmentSectionMock); + var guiMock = mocks.StrictMock(); + + using (var treeViewControl = new TreeViewControl()) + { + guiMock.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + mocks.ReplayAll(); + + plugin.Gui = guiMock; + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuCalculateIndex, + RingtoetsCommonFormsResources.Calculate, + RingtoetsCommonFormsResources.Plugin_AllDataAvailable_No_failure_mechanism_sections_imported, + RingtoetsCommonFormsResources.CalculateIcon, + false); + } + } + } + + [Test] + public void ContextMenuStrip_FailureMechanismSectionsSetNoHydraulicBoundaryDatabase_ContextMenuItemPerformCalculationDisabledAndTooltipSet() + { + // Setup + var guiMock = mocks.StrictMock(); + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + failureMechanism.AddSection(new FailureMechanismSection("test", new[] + { + new Point2D(0, 0) + })); + + var assessmentSectionMock = mocks.Stub(); + var calculation = new StabilityPointStructuresCalculation(); + var nodeData = new StabilityPointStructuresCalculationContext(calculation, failureMechanism, assessmentSectionMock); + + using (var treeViewControl = new TreeViewControl()) + { + guiMock.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + mocks.ReplayAll(); + + plugin.Gui = guiMock; + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuCalculateIndex, + RingtoetsCommonFormsResources.Calculate, + RingtoetsCommonFormsResources.Plugin_AllDataAvailable_No_hydraulic_boundary_database_imported, + RingtoetsCommonFormsResources.CalculateIcon, + false); + } + } + } + + [Test] + public void ContextMenuStrip_FailureMechanismSectionsSetHydraulicBoundaryDatabaseNotValid_ContextMenuItemPerformCalculationDisabledAndTooltipSet() + { + // Setup + var guiMock = mocks.StrictMock(); + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + failureMechanism.AddSection(new FailureMechanismSection("test", new[] + { + new Point2D(0, 0) + })); + + var assessmentSectionMock = mocks.Stub(); + assessmentSectionMock.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); + + var calculation = new StabilityPointStructuresCalculation(); + var nodeData = new StabilityPointStructuresCalculationContext(calculation, failureMechanism, assessmentSectionMock); + + using (var treeViewControl = new TreeViewControl()) + { + guiMock.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + mocks.ReplayAll(); + + plugin.Gui = guiMock; + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + ToolStripItem contextMenuItem = contextMenu.Items[contextMenuCalculateIndex]; + + Assert.AreEqual(RingtoetsCommonFormsResources.Calculate, contextMenuItem.Text); + StringAssert.Contains(string.Format(RingtoetsCommonServicesResources.Hydraulic_boundary_database_connection_failed_0_, ""), contextMenuItem.ToolTipText); + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.CalculateIcon, contextMenuItem.Image); + Assert.IsFalse(contextMenuItem.Enabled); + } + } + } + + [Test] + public void ContextMenuStrip_FailureMechanismSectionsAndHydraulicBoundaryDatabaseSet_ContextMenuItemPerformCalculationEnabled() + { + // Setup + var guiMock = mocks.StrictMock(); + string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = validFilePath, + Version = "1.0" + }; + + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + failureMechanism.AddSection(new FailureMechanismSection("test", new[] + { + new Point2D(0, 0) + })); + + var assessmentSectionMock = mocks.Stub(); + assessmentSectionMock.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; + + var calculation = new StabilityPointStructuresCalculation(); + var nodeData = new StabilityPointStructuresCalculationContext(calculation, failureMechanism, assessmentSectionMock); + + using (var treeViewControl = new TreeViewControl()) + { + guiMock.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + + mocks.ReplayAll(); + + plugin.Gui = guiMock; + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuCalculateIndex, + RingtoetsCommonFormsResources.Calculate, + RingtoetsCommonFormsResources.Calculate_ToolTip, + RingtoetsCommonFormsResources.CalculateIcon); + } + } + } + + [Test] + public void ContextMenuStrip_NoFailureMechanismSections_ContextMenuItemValidateCalculationDisabledAndTooltipSet() + { + // Setup + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + var assessmentSectionMock = mocks.Stub(); + var calculation = new StabilityPointStructuresCalculation(); + var nodeData = new StabilityPointStructuresCalculationContext(calculation, failureMechanism, assessmentSectionMock); + var guiMock = mocks.StrictMock(); + + using (var treeViewControl = new TreeViewControl()) + { + guiMock.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + mocks.ReplayAll(); + + plugin.Gui = guiMock; + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuValidateIndex, + RingtoetsCommonFormsResources.Validate, + RingtoetsCommonFormsResources.Plugin_AllDataAvailable_No_failure_mechanism_sections_imported, + RingtoetsCommonFormsResources.ValidateIcon, + false); + } + } + } + + [Test] + public void ContextMenuStrip_FailureMechanismSectionsSetNoHydraulicBoundaryDatabase_ContextMenuItemValidateCalculationDisabledAndTooltipSet() + { + // Setup + var guiMock = mocks.StrictMock(); + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + failureMechanism.AddSection(new FailureMechanismSection("test", new[] + { + new Point2D(0, 0) + })); + + var assessmentSectionMock = mocks.Stub(); + var calculation = new StabilityPointStructuresCalculation(); + var nodeData = new StabilityPointStructuresCalculationContext(calculation, failureMechanism, assessmentSectionMock); + + using (var treeViewControl = new TreeViewControl()) + { + guiMock.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + mocks.ReplayAll(); + + plugin.Gui = guiMock; + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuValidateIndex, + RingtoetsCommonFormsResources.Validate, + RingtoetsCommonFormsResources.Plugin_AllDataAvailable_No_hydraulic_boundary_database_imported, + RingtoetsCommonFormsResources.ValidateIcon, + false); + } + } + } + + [Test] + public void ContextMenuStrip_FailureMechanismSectionsSetHydraulicBoundaryDatabaseNotValid_ContextMenuItemValidateCalculationDisabledAndTooltipSet() + { + // Setup + var guiMock = mocks.StrictMock(); + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + failureMechanism.AddSection(new FailureMechanismSection("test", new[] + { + new Point2D(0, 0) + })); + + var assessmentSectionMock = mocks.Stub(); + assessmentSectionMock.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); + var calculation = new StabilityPointStructuresCalculation(); + var nodeData = new StabilityPointStructuresCalculationContext(calculation, failureMechanism, assessmentSectionMock); + + using (var treeViewControl = new TreeViewControl()) + { + guiMock.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + mocks.ReplayAll(); + + plugin.Gui = guiMock; + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + ToolStripItem contextMenuItem = contextMenu.Items[contextMenuValidateIndex]; + + Assert.AreEqual(RingtoetsCommonFormsResources.Validate, contextMenuItem.Text); + StringAssert.Contains(string.Format(RingtoetsCommonServicesResources.Hydraulic_boundary_database_connection_failed_0_, ""), contextMenuItem.ToolTipText); + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.ValidateIcon, contextMenuItem.Image); + Assert.IsFalse(contextMenuItem.Enabled); + } + } + } + + [Test] + public void ContextMenuStrip_FailureMechanismSectionsAndHydraulicBoundaryDatabaseSet_ContextMenuItemValidateCalculationEnabled() + { + // Setup + var guiMock = mocks.StrictMock(); + string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = validFilePath, + Version = "1.0" + }; + + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + failureMechanism.AddSection(new FailureMechanismSection("test", new[] + { + new Point2D(0, 0) + })); + + var assessmentSectionMock = mocks.Stub(); + assessmentSectionMock.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; + var calculation = new StabilityPointStructuresCalculation(); + var nodeData = new StabilityPointStructuresCalculationContext(calculation, failureMechanism, assessmentSectionMock); + + using (var treeViewControl = new TreeViewControl()) + { + guiMock.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + mocks.ReplayAll(); + + plugin.Gui = guiMock; + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuValidateIndex, + RingtoetsCommonFormsResources.Validate, + RingtoetsCommonFormsResources.Validate_ToolTip, + RingtoetsCommonFormsResources.ValidateIcon); + } + } + } + + [Test] public void OnNodeRemoved_ParentIsCalculationGroupContext_RemoveCalculationFromGroup() { // Setup