Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/WaveHeightLocationsContextTreeNodeInfoTest.cs =================================================================== diff -u -rac96d7c315129af851634ed5a4a6800b59ede718 -r61ab2a112211952c337eea98bae62a4c93335229 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/WaveHeightLocationsContextTreeNodeInfoTest.cs (.../WaveHeightLocationsContextTreeNodeInfoTest.cs) (revision ac96d7c315129af851634ed5a4a6800b59ede718) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/WaveHeightLocationsContextTreeNodeInfoTest.cs (.../WaveHeightLocationsContextTreeNodeInfoTest.cs) (revision 61ab2a112211952c337eea98bae62a4c93335229) @@ -25,6 +25,7 @@ using System.Linq; using System.Threading; using System.Windows.Forms; +using Core.Common.Base; using Core.Common.Controls.TreeView; using Core.Common.Gui; using Core.Common.Gui.ContextMenu; @@ -129,7 +130,7 @@ public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods() { // Setup - var assessmentSection = mockRepository.Stub(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(mockRepository); var menuBuilder = mockRepository.StrictMock(); using (mockRepository.Ordered()) @@ -142,7 +143,8 @@ menuBuilder.Expect(mb => mb.Build()).Return(null); } - var nodeData = new WaveHeightLocationsContext(assessmentSection); + var nodeData = new WaveHeightLocationsContext(new ObservableList(), + assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -167,18 +169,54 @@ } [Test] - public void ContextMenuStrip_HydraulicBoundaryDatabaseNotValid_ContextMenuItemCalculateAllDisabledAndTooltipSet() + public void ContextMenuStrip_HydraulicBoundaryDatabaseNotLinked_ContextMenuItemCalculateAllDisabledAndTooltipSet() { // Setup - var assessmentSection = mockRepository.Stub(); - var nodeData = new WaveHeightLocationsContext(assessmentSection) + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(mockRepository); + + var nodeData = new WaveHeightLocationsContext(new ObservableList(), + assessmentSection); + + using (var treeViewControl = new TreeViewControl()) { - WrappedData = + var gui = mockRepository.Stub(); + gui.Stub(g => g.ProjectOpened += null).IgnoreArguments(); + gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); + gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + mockRepository.ReplayAll(); + + using (var plugin = new RingtoetsPlugin()) { - HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase() + TreeNodeInfo info = GetInfo(plugin); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + ToolStripItem contextMenuItem = contextMenu.Items[contextMenuRunWaveHeightCalculationsIndex]; + + Assert.AreEqual("Alles be&rekenen", contextMenuItem.Text); + StringAssert.Contains("Er is geen hydraulische randvoorwaardendatabase geïmporteerd.", contextMenuItem.ToolTipText); + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.CalculateAllIcon, contextMenuItem.Image); + Assert.IsFalse(contextMenuItem.Enabled); + } } - }; + } + mockRepository.VerifyAll(); // Expect no calls on arguments + } + + [Test] + public void ContextMenuStrip_HydraulicBoundaryDatabaseLinkedToInvalidFile_ContextMenuItemCalculateAllDisabledAndTooltipSet() + { + // Setup + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(null, mockRepository, "invalidFilePath"); + + var nodeData = new WaveHeightLocationsContext(assessmentSection.HydraulicBoundaryDatabase.Locations, + assessmentSection); + using (var treeViewControl = new TreeViewControl()) { var gui = mockRepository.Stub(); @@ -214,18 +252,17 @@ public void ContextMenuStrip_AllRequiredInputSet_ContextMenuItemCalculateAllEnabled() { // Setup - var assessmentSection = mockRepository.Stub(); - var nodeData = new WaveHeightLocationsContext(assessmentSection) + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { - WrappedData = - { - HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase - { - FilePath = Path.Combine(TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, "HydraulicBoundaryDatabaseImporter"), "complete.sqlite") - } - } + FilePath = Path.Combine(TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, "HydraulicBoundaryDatabaseImporter"), "complete.sqlite") }; + var assessmentSection = mockRepository.Stub(); + assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(hydraulicBoundaryDatabase); + + var nodeData = new WaveHeightLocationsContext(hydraulicBoundaryDatabase.Locations, + assessmentSection); + using (var treeViewControl = new TreeViewControl()) { var gui = mockRepository.Stub(); @@ -264,7 +301,7 @@ var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation("locationName"); var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) { - HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + HydraulicBoundaryDatabase = { Locations = { @@ -274,7 +311,8 @@ } }; - var context = new WaveHeightLocationsContext(assessmentSection); + var context = new WaveHeightLocationsContext(assessmentSection.HydraulicBoundaryDatabase.Locations, + assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -328,7 +366,7 @@ var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation("locationName"); var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) { - HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + HydraulicBoundaryDatabase = { Locations = { @@ -341,7 +379,8 @@ } }; - var context = new WaveHeightLocationsContext(assessmentSection); + var context = new WaveHeightLocationsContext(assessmentSection.HydraulicBoundaryDatabase.Locations, + assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -394,7 +433,7 @@ var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation("locationName"); var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) { - HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + HydraulicBoundaryDatabase = { Locations = { @@ -407,7 +446,8 @@ } }; - var context = new WaveHeightLocationsContext(assessmentSection); + var context = new WaveHeightLocationsContext(assessmentSection.HydraulicBoundaryDatabase.Locations, + assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -461,7 +501,7 @@ var location = new TestHydraulicBoundaryLocation(locationName); var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) { - HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + HydraulicBoundaryDatabase = { Locations = { @@ -472,7 +512,8 @@ Id = string.Empty }; - var context = new WaveHeightLocationsContext(assessmentSection); + var context = new WaveHeightLocationsContext(assessmentSection.HydraulicBoundaryDatabase.Locations, + assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -522,7 +563,7 @@ CalculationServiceTestHelper.AssertCalculationEndMessage(msgs[6]); Assert.AreEqual($"Golfhoogte berekenen voor locatie '{locationName}' is gelukt.", msgs[7]); }); - Assert.AreEqual(CalculationConvergence.CalculatedNotConverged, location.WaveHeightCalculationConvergence); + Assert.AreEqual(CalculationConvergence.CalculatedNotConverged, location.WaveHeightCalculation.Output.CalculationConvergence); } } }