Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -rf5664da05a4c337985a9c55b62e825fce82844e3 -rb3a98c795a51363606d0b9271d424b248e5afe52 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision f5664da05a4c337985a9c55b62e825fce82844e3) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision b3a98c795a51363606d0b9271d424b248e5afe52) @@ -579,14 +579,72 @@ } [Test] - public void GivenAssessmentSectionWithValidInput_ThenValidationItemEnabled() + public void GivenFailureMechanismContributionZero_ThenValidationItemDisabled() { // Given string validHydroDatabasePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, Path.Combine("HydraulicBoundaryDatabaseImporter", "complete.sqlite")); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism { + Contribution = 0 + }; + var assessmentSection = mocks.Stub(); + assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = validHydroDatabasePath + }; + + var calculation = new GrassCoverErosionOutwardsWaveConditionsCalculation + { + Name = "A" + }; + var context = new GrassCoverErosionOutwardsWaveConditionsCalculationContext(calculation, + failureMechanism, + assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + var appFeatureCommandHandler = mocks.Stub(); + var importHandler = mocks.Stub(); + var exportHandler = mocks.Stub(); + var viewCommands = mocks.Stub(); + var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, + importHandler, + exportHandler, + viewCommands, + context, + treeViewControl); + + var gui = mocks.Stub(); + gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilderMock); + + mocks.ReplayAll(); + + plugin.Gui = gui; + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) + { + // Then + TestHelper.AssertContextMenuStripContainsItem(contextMenu, + validateMenuItemIndex, + "&Valideren", + "De bijdrage van dit toetsspoor is nul.", + RingtoetsCommonFormsResources.ValidateIcon, + false); + } + } + } + + [Test] + public void GivenValidInput_ThenValidationItemEnabled() + { + // Given + string validHydroDatabasePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, + Path.Combine("HydraulicBoundaryDatabaseImporter", "complete.sqlite")); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism + { Contribution = 5 }; var assessmentSection = mocks.Stub(); @@ -827,14 +885,72 @@ } [Test] - public void GivenAssessmentSectionWithValidInput_ThenCalculationItemEnabled() + public void GivenFailureMechanismContributionZero_ThenCalculationItemDisabled() { // Given string validHydroDatabasePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, Path.Combine("HydraulicBoundaryDatabaseImporter", "complete.sqlite")); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism { + Contribution = 0 + }; + var assessmentSection = mocks.Stub(); + assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = validHydroDatabasePath + }; + + var calculation = new GrassCoverErosionOutwardsWaveConditionsCalculation + { + Name = "A" + }; + var context = new GrassCoverErosionOutwardsWaveConditionsCalculationContext(calculation, + failureMechanism, + assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + var appFeatureCommandHandler = mocks.Stub(); + var importHandler = mocks.Stub(); + var exportHandler = mocks.Stub(); + var viewCommands = mocks.Stub(); + var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, + importHandler, + exportHandler, + viewCommands, + context, + treeViewControl); + + var gui = mocks.Stub(); + gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilderMock); + + mocks.ReplayAll(); + + plugin.Gui = gui; + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) + { + // Then + TestHelper.AssertContextMenuStripContainsItem(contextMenu, + calculateMenuItemIndex, + "Be&rekenen", + "De bijdrage van dit toetsspoor is nul.", + RingtoetsCommonFormsResources.CalculateIcon, + false); + } + } + } + + [Test] + public void GivenValidInput_ThenCalculationItemEnabled() + { + // Given + string validHydroDatabasePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, + Path.Combine("HydraulicBoundaryDatabaseImporter", "complete.sqlite")); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism + { Contribution = 5 }; var assessmentSection = mocks.Stub(); Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -rf5664da05a4c337985a9c55b62e825fce82844e3 -rb3a98c795a51363606d0b9271d424b248e5afe52 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision f5664da05a4c337985a9c55b62e825fce82844e3) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision b3a98c795a51363606d0b9271d424b248e5afe52) @@ -660,6 +660,109 @@ } [Test] + public void ContextMenuStrip_FailureMechanismContributionZero_CalculateAllAndValidateAllDisabled() + { + // Setup + string validHydroDatabasePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, + Path.Combine("HydraulicBoundaryDatabaseImporter", "complete.sqlite")); + + using (var treeViewControl = new TreeViewControl()) + { + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism + { + Contribution = 0 + }; + var group = new CalculationGroup(); + group.Children.Add(new GrassCoverErosionOutwardsWaveConditionsCalculation()); + failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); + var assessmentSection = mocks.Stub(); + assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = validHydroDatabasePath + }; + var nodeData = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(group, + failureMechanism, + assessmentSection); + var parentNodeData = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, + failureMechanism, + assessmentSection); + + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + var gui = mocks.Stub(); + gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); + + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) + { + // Assert + ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroup]; + ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroup]; + Assert.IsFalse(validateItem.Enabled); + Assert.IsFalse(calculateItem.Enabled); + var message = "De bijdrage van dit toetsspoor is nul."; + Assert.AreEqual(message, calculateItem.ToolTipText); + Assert.AreEqual(message, validateItem.ToolTipText); + } + } + } + + [Test] + public void ContextMenuStrip_AllRequiredInputSet_CalculateAllAndValidateAllEnabled() + { + // Setup + string validHydroDatabasePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, + Path.Combine("HydraulicBoundaryDatabaseImporter", "complete.sqlite")); + + using (var treeViewControl = new TreeViewControl()) + { + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism + { + Contribution = 5 + }; + var group = new CalculationGroup(); + group.Children.Add(new GrassCoverErosionOutwardsWaveConditionsCalculation()); + failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); + var assessmentSection = mocks.Stub(); + assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = validHydroDatabasePath + }; + var nodeData = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(group, + failureMechanism, + assessmentSection); + var parentNodeData = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, + failureMechanism, + assessmentSection); + + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + var gui = mocks.Stub(); + gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); + + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) + { + // Assert + ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroup]; + ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroup]; + Assert.IsTrue(validateItem.Enabled); + Assert.IsTrue(calculateItem.Enabled); + Assert.AreEqual("Voer alle berekeningen binnen deze berekeningsmap uit.", calculateItem.ToolTipText); + Assert.AreEqual("Valideer alle berekeningen binnen deze berekeningsmap.", validateItem.ToolTipText); + } + } + } + + [Test] public void ContextMenuStrip_TwoCalculationsClickOnValidateAllInGroup_ValidationMessagesLogged() { // Setup Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -rf5664da05a4c337985a9c55b62e825fce82844e3 -rb3a98c795a51363606d0b9271d424b248e5afe52 --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision f5664da05a4c337985a9c55b62e825fce82844e3) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision b3a98c795a51363606d0b9271d424b248e5afe52) @@ -612,7 +612,7 @@ } [Test] - public void GivenAssessmentSectionWithValidInput_ThenValidationItemEnabled() + public void GivenValidInput_ThenValidationItemEnabled() { // Given string validHydroDatabasePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, @@ -848,7 +848,7 @@ } [Test] - public void GivenAssessmentSectionWithValidInput_ThenCalculationItemEnabled() + public void GivenValidInput_ThenCalculationItemEnabled() { // Given string validHydroDatabasePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -rf5664da05a4c337985a9c55b62e825fce82844e3 -rb3a98c795a51363606d0b9271d424b248e5afe52 --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision f5664da05a4c337985a9c55b62e825fce82844e3) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision b3a98c795a51363606d0b9271d424b248e5afe52) @@ -652,6 +652,54 @@ } [Test] + public void ContextMenuStrip_AllRequiredInputSet_CalculateAllAndValidateAllEnabled() + { + // Setup + string validHydroDatabasePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, + Path.Combine("HydraulicBoundaryDatabaseImporter", "complete.sqlite")); + + using (var treeViewControl = new TreeViewControl()) + { + var failureMechanism = new StabilityStoneCoverFailureMechanism(); + var group = new CalculationGroup(); + group.Children.Add(new StabilityStoneCoverWaveConditionsCalculation()); + failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); + var assessmentSection = mocks.Stub(); + assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = validHydroDatabasePath + }; + var nodeData = new StabilityStoneCoverWaveConditionsCalculationGroupContext(group, + failureMechanism, + assessmentSection); + var parentNodeData = new StabilityStoneCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, + failureMechanism, + assessmentSection); + + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + var gui = mocks.Stub(); + gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); + + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) + { + // Assert + ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroup]; + ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroup]; + Assert.IsTrue(validateItem.Enabled); + Assert.IsTrue(calculateItem.Enabled); + Assert.AreEqual("Voer alle berekeningen binnen deze berekeningsmap uit.", calculateItem.ToolTipText); + Assert.AreEqual("Valideer alle berekeningen binnen deze berekeningsmap.", validateItem.ToolTipText); + } + } + } + + [Test] public void ContextMenuStrip_TwoCalculationsClickOnValidateAllInGroup_ValidationMessagesLogged() { // Setup Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -rf5664da05a4c337985a9c55b62e825fce82844e3 -rb3a98c795a51363606d0b9271d424b248e5afe52 --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../WaveImpactAsphaltCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision f5664da05a4c337985a9c55b62e825fce82844e3) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../WaveImpactAsphaltCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision b3a98c795a51363606d0b9271d424b248e5afe52) @@ -569,7 +569,7 @@ } [Test] - public void GivenAssessmentSectionWithValidInput_ThenValidationItemEnabled() + public void GivenValidInput_ThenValidationItemEnabled() { // Given string validHydroDatabasePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, @@ -823,7 +823,7 @@ } [Test] - public void GivenAssessmentSectionWithValidInput_ThenCalculationItemEnabled() + public void GivenValidInput_ThenCalculationItemEnabled() { // Given string validHydroDatabasePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -rf5664da05a4c337985a9c55b62e825fce82844e3 -rb3a98c795a51363606d0b9271d424b248e5afe52 --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision f5664da05a4c337985a9c55b62e825fce82844e3) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision b3a98c795a51363606d0b9271d424b248e5afe52) @@ -653,6 +653,54 @@ } [Test] + public void ContextMenuStrip_AllRequiredInputSet_CalculateAllAndValidateAllEnabled() + { + // Setup + string validHydroDatabasePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, + Path.Combine("HydraulicBoundaryDatabaseImporter", "complete.sqlite")); + + using (var treeViewControl = new TreeViewControl()) + { + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var group = new CalculationGroup(); + group.Children.Add(new WaveImpactAsphaltCoverWaveConditionsCalculation()); + failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); + var assessmentSection = mocks.Stub(); + assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = validHydroDatabasePath + }; + var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(group, + failureMechanism, + assessmentSection); + var parentNodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, + failureMechanism, + assessmentSection); + + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + var gui = mocks.Stub(); + gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); + + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) + { + // Assert + ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroup]; + ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroup]; + Assert.IsTrue(validateItem.Enabled); + Assert.IsTrue(calculateItem.Enabled); + Assert.AreEqual("Voer alle berekeningen binnen deze berekeningsmap uit.", calculateItem.ToolTipText); + Assert.AreEqual("Valideer alle berekeningen binnen deze berekeningsmap.", validateItem.ToolTipText); + } + } + } + + [Test] public void ContextMenuStrip_TwoCalculationsClickOnValidateAllInGroup_ValidationMessagesLogged() { // Setup