Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/TreeNodeInfos/HeightStructuresCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -r37453954b2d36699ea16375cdfbf89785a094ab9 -r98bec982f07dc65fdc5636f32689d972843c124d --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/TreeNodeInfos/HeightStructuresCalculationContextTreeNodeInfoTest.cs (.../HeightStructuresCalculationContextTreeNodeInfoTest.cs) (revision 37453954b2d36699ea16375cdfbf89785a094ab9) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/TreeNodeInfos/HeightStructuresCalculationContextTreeNodeInfoTest.cs (.../HeightStructuresCalculationContextTreeNodeInfoTest.cs) (revision 98bec982f07dc65fdc5636f32689d972843c124d) @@ -262,7 +262,7 @@ } [Test] - public void ContextMenuStrip_FailureMechanismSectionsSetNoHydraulicBoundaryDatabase_ContextMenuItemPerformCalculationDisabledAndTooltipSet() + public void ContextMenuStrip_NoHydraulicBoundaryDatabase_ContextMenuItemPerformCalculationDisabledAndTooltipSet() { // Setup var guiMock = mocks.StrictMock(); @@ -329,7 +329,7 @@ } [Test] - public void ContextMenuStrip_FailureMechanismSectionsAndHydraulicBoundaryDatabaseSet_ContextMenuItemPerformCalculationEnabled() + public void ContextMenuStrip_FailureMechanismContributionZero_ContextMenuItemPerformCalculationDisabledAndTooltipSet() { // Setup var guiMock = mocks.StrictMock(); @@ -342,6 +342,49 @@ Version = "1.0" }; + var failureMechanism = new HeightStructuresFailureMechanism(); + var assessmentSectionStub = mocks.Stub(); + + var calculation = new StructuresCalculation(); + var nodeData = new HeightStructuresCalculationContext(calculation, failureMechanism, assessmentSectionStub); + + using (var treeViewControl = new TreeViewControl()) + { + guiMock.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + + mocks.ReplayAll(); + + assessmentSectionStub.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; + + plugin.Gui = guiMock; + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuCalculateIndex, + "Be&rekenen", + "De bijdrage van dit toetsspoor is nul.", + RingtoetsCommonFormsResources.CalculateIcon, + false); + } + } + } + + [Test] + public void ContextMenuStrip_AllRequiredInputSet_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 TestHeightStructuresFailureMechanism(); var assessmentSectionStub = mocks.Stub(); @@ -371,7 +414,7 @@ } [Test] - public void ContextMenuStrip_FailureMechanismSectionsSetNoHydraulicBoundaryDatabase_ContextMenuItemValidateCalculationDisabledAndTooltipSet() + public void ContextMenuStrip_NoHydraulicBoundaryDatabase_ContextMenuItemValidateCalculationDisabledAndTooltipSet() { // Setup var guiMock = mocks.StrictMock(); @@ -438,7 +481,7 @@ } [Test] - public void ContextMenuStrip_HydraulicBoundaryDatabaseSet_ContextMenuItemValidateCalculationEnabled() + public void ContextMenuStrip_FailureMechanismContributionZero_ContextMenuItemValidateCalculationDisabledAndTooltipSet() { // Setup var guiMock = mocks.StrictMock(); @@ -455,6 +498,48 @@ assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; var calculation = new StructuresCalculation(); + var failureMechanism = new HeightStructuresFailureMechanism(); + var nodeData = new HeightStructuresCalculationContext(calculation, failureMechanism, assessmentSection); + + 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, + "&Valideren", + "De bijdrage van dit toetsspoor is nul.", + RingtoetsCommonFormsResources.ValidateIcon, + false); + } + } + } + + [Test] + public void ContextMenuStrip_AllRequiredInputSet_ContextMenuItemValidateCalculationEnabled() + { + // Setup + var guiMock = mocks.StrictMock(); + + string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); + + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = validFilePath, + Version = "1.0" + }; + + var assessmentSection = mocks.Stub(); + assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; + + var calculation = new StructuresCalculation(); var failureMechanism = new TestHeightStructuresFailureMechanism(); var nodeData = new HeightStructuresCalculationContext(calculation, failureMechanism, assessmentSection); Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/TreeNodeInfos/HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r37453954b2d36699ea16375cdfbf89785a094ab9 -r98bec982f07dc65fdc5636f32689d972843c124d --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/TreeNodeInfos/HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision 37453954b2d36699ea16375cdfbf89785a094ab9) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/TreeNodeInfos/HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision 98bec982f07dc65fdc5636f32689d972843c124d) @@ -413,7 +413,7 @@ } [Test] - public void ContextMenuStrip_FailureMechanismSectionsSetNoHydraulicBoundaryDatabase_ContextMenuItemCalculateAllDisabledAndTooltipSet() + public void ContextMenuStrip_NoHydraulicBoundaryDatabase_ContextMenuItemCalculateAllDisabledAndTooltipSet() { // Setup var group = new CalculationGroup @@ -500,7 +500,7 @@ } [Test] - public void ContextMenuStrip_HydraulicDatabaseSet_ContextMenuItemCalculateAllEnabled() + public void ContextMenuStrip_FailureMechanismContributionZero_ContextMenuItemCalculateAllDisabledAndTooltipSet() { // Setup var group = new CalculationGroup @@ -519,6 +519,58 @@ Version = "1.0" }; + var failureMechanism = new HeightStructuresFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation()); + + var assessmentSectionStub = mocks.Stub(); + var nodeData = new HeightStructuresCalculationGroupContext(group, + failureMechanism, + assessmentSectionStub); + + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + using (var treeViewControl = new TreeViewControl()) + { + guiStub.Expect(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + guiStub.Stub(cmp => cmp.ViewCommands).Return(mocks.Stub()); + + mocks.ReplayAll(); + + assessmentSectionStub.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; + + // Call + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndexRootGroup, + "Alles be&rekenen", + "De bijdrage van dit toetsspoor is nul.", + RingtoetsCommonFormsResources.CalculateAllIcon, + false); + } + } + } + + [Test] + public void ContextMenuStrip_AllRequiredInputSet_ContextMenuItemCalculateAllEnabled() + { + // Setup + var group = new CalculationGroup + { + Children = + { + new StructuresCalculation() + } + }; + + string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); + + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = validFilePath, + Version = "1.0" + }; + var failureMechanism = new TestHeightStructuresFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation()); @@ -594,7 +646,7 @@ } [Test] - public void ContextMenuStrip_FailureMechanismSectionsSetHydraulicBoundaryDatabaseNotValid_ContextMenuItemValidateAllDisabledAndTooltipSet() + public void ContextMenuStrip_HydraulicBoundaryDatabaseNotValid_ContextMenuItemValidateAllDisabledAndTooltipSet() { // Setup var group = new CalculationGroup @@ -638,7 +690,7 @@ } [Test] - public void ContextMenuStrip_HydraulicDatabaseSet_ContextMenuItemValidateAllEnabled() + public void ContextMenuStrip_FailureMechanismContributionZero_ContextMenuItemValidateAllDisabledAndTooltipSet() { // Setup var group = new CalculationGroup @@ -657,6 +709,58 @@ Version = "1.0" }; + var failureMechanism = new HeightStructuresFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation()); + + var assessmentSection = mocks.Stub(); + assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; + + var nodeData = new HeightStructuresCalculationGroupContext(group, + failureMechanism, + assessmentSection); + + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + using (var treeViewControl = new TreeViewControl()) + { + guiStub.Expect(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + guiStub.Stub(cmp => cmp.ViewCommands).Return(mocks.Stub()); + + mocks.ReplayAll(); + + // Call + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndexRootGroup, + "Alles &valideren", + "De bijdrage van dit toetsspoor is nul.", + RingtoetsCommonFormsResources.ValidateAllIcon, + false); + } + } + } + + [Test] + public void ContextMenuStrip_AllRequiredInputSet_ContextMenuItemValidateAllEnabled() + { + // Setup + var group = new CalculationGroup + { + Children = + { + new StructuresCalculation() + } + }; + + string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); + + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = validFilePath, + Version = "1.0" + }; + var failureMechanism = new TestHeightStructuresFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation()); Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/TreeNodeInfos/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -r37453954b2d36699ea16375cdfbf89785a094ab9 -r98bec982f07dc65fdc5636f32689d972843c124d --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/TreeNodeInfos/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision 37453954b2d36699ea16375cdfbf89785a094ab9) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/TreeNodeInfos/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision 98bec982f07dc65fdc5636f32689d972843c124d) @@ -455,7 +455,7 @@ } [Test] - public void ContextMenuStrip_FailureMechanismSectionsSetHydraulicBoundaryDatabaseNotValid_ContextMenuItemCalculateAllDisabledAndTooltipSet() + public void ContextMenuStrip_HydraulicBoundaryDatabaseNotValid_ContextMenuItemCalculateAllDisabledAndTooltipSet() { // Setup var guiMock = mocksRepository.StrictMock(); @@ -491,10 +491,57 @@ } [Test] - public void ContextMenuStrip_FailureMechanismSectionsAndHydraulicDatabaseSet_ContextMenuItemCalculateAllEnabled() + public void ContextMenuStrip_FailureMechanismContributionZero_ContextMenuItemCalculateAllDisabledAndTooltipSet() { // Setup var guiMock = mocksRepository.StrictMock(); + var failureMechanism = new HeightStructuresFailureMechanism(); + failureMechanism.AddSection(new FailureMechanismSection("test", new[] + { + new Point2D(0, 0) + })); + failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation()); + + string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); + + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = validFilePath, + Version = "1.0" + }; + + var assessmentSection = mocksRepository.Stub(); + assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; + + var nodeData = new HeightStructuresFailureMechanismContext(failureMechanism, assessmentSection); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + using (var treeViewControl = new TreeViewControl()) + { + guiMock.Expect(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + + mocksRepository.ReplayAll(); + + plugin.Gui = guiMock; + + // Call + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndex, + "Alles be&rekenen", + "De bijdrage van dit toetsspoor is nul.", + RingtoetsCommonFormsResources.CalculateAllIcon, + false); + } + } + } + + [Test] + public void ContextMenuStrip_AllRequiredInputSet_ContextMenuItemCalculateAllEnabled() + { + // Setup + var guiMock = mocksRepository.StrictMock(); var failureMechanism = new TestHeightStructuresFailureMechanism(); failureMechanism.AddSection(new FailureMechanismSection("test", new[] { @@ -607,10 +654,57 @@ } [Test] - public void ContextMenuStrip_FailureMechanismSectionsAndHydraulicDatabaseSet_ContextMenuItemValidateAllEnabled() + public void ContextMenuStrip_FailureMechanismContributionZero_ContextMenuItemValidateAllDisabledAndTooltipSet() { // Setup var guiMock = mocksRepository.StrictMock(); + var failureMechanism = new HeightStructuresFailureMechanism(); + failureMechanism.AddSection(new FailureMechanismSection("test", new[] + { + new Point2D(0, 0) + })); + failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation()); + + string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); + + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = validFilePath, + Version = "1.0" + }; + + var assessmentSection = mocksRepository.Stub(); + assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; + + var nodeData = new HeightStructuresFailureMechanismContext(failureMechanism, assessmentSection); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + using (var treeViewControl = new TreeViewControl()) + { + guiMock.Expect(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + + mocksRepository.ReplayAll(); + + plugin.Gui = guiMock; + + // Call + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndex, + "Alles &valideren", + "De bijdrage van dit toetsspoor is nul.", + RingtoetsCommonFormsResources.ValidateAllIcon, + false); + } + } + } + + [Test] + public void ContextMenuStrip_AllRequiredInputSet_ContextMenuItemValidateAllEnabled() + { + // Setup + var guiMock = mocksRepository.StrictMock(); var failureMechanism = new TestHeightStructuresFailureMechanism(); failureMechanism.AddSection(new FailureMechanismSection("test", new[] {