Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.Designer.cs =================================================================== diff -u -rb41f4c465f094e91312ffd90174e765417b28ba9 -r604d0e202fa546642f20240c80aac5d98447e4fc --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision b41f4c465f094e91312ffd90174e765417b28ba9) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 604d0e202fa546642f20240c80aac5d98447e4fc) @@ -370,15 +370,6 @@ } /// - /// Looks up a localized string similar to Er is geen hydraulische randvoorwaardendatabase beschikbaar om de toetspeilen te berekenen.. - /// - public static string DesignWaterLevel_No_HRD_To_Calculate { - get { - return ResourceManager.GetString("DesignWaterLevel_No_HRD_To_Calculate", resourceCulture); - } - } - - /// /// Looks up a localized string similar to Toetspeilen. /// public static string DesignWaterLevelLocationsContext_DisplayName { @@ -680,15 +671,6 @@ } /// - /// Looks up a localized string similar to Er is geen hydraulische randvoorwaardendatabase beschikbaar om de golfhoogtes te berekenen.. - /// - public static string WaveHeight_No_HRD_To_Calculate { - get { - return ResourceManager.GetString("WaveHeight_No_HRD_To_Calculate", resourceCulture); - } - } - - /// /// Looks up a localized string similar to Golfhoogtes. /// public static string WaveHeightLocationsContext_DisplayName { Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.resx =================================================================== diff -u -rb41f4c465f094e91312ffd90174e765417b28ba9 -r604d0e202fa546642f20240c80aac5d98447e4fc --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.resx (.../Resources.resx) (revision b41f4c465f094e91312ffd90174e765417b28ba9) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.resx (.../Resources.resx) (revision 604d0e202fa546642f20240c80aac5d98447e4fc) @@ -150,9 +150,6 @@ Alle toetspeilen berekenen. - - Er is geen hydraulische randvoorwaardendatabase beschikbaar om de toetspeilen te berekenen. - &Koppel aan database... @@ -249,9 +246,6 @@ Golfhoogtes - - Er is geen hydraulische randvoorwaardendatabase beschikbaar om de golfhoogtes te berekenen. - Alles be&rekenen Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs =================================================================== diff -u -r67823f50a5a4e994c13dac0269fb61e8783efead -r604d0e202fa546642f20240c80aac5d98447e4fc --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 67823f50a5a4e994c13dac0269fb61e8783efead) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 604d0e202fa546642f20240c80aac5d98447e4fc) @@ -56,6 +56,7 @@ using Ringtoets.Common.IO.HydraRing; using Ringtoets.Common.IO.Hydraulics; using Ringtoets.Common.IO.ReferenceLines; +using Ringtoets.Common.Service; using Ringtoets.DuneErosion.Data; using Ringtoets.DuneErosion.Forms.PresentationObjects; using Ringtoets.DuneErosion.Plugin.Handlers; @@ -111,111 +112,111 @@ new FailureMechanismContextAssociation( typeof(PipingFailureMechanism), (mechanism, assessmentSection) => new PipingFailureMechanismContext( - (PipingFailureMechanism) mechanism, - assessmentSection) - ), + (PipingFailureMechanism) mechanism, + assessmentSection) + ), new FailureMechanismContextAssociation( typeof(GrassCoverErosionInwardsFailureMechanism), (mechanism, assessmentSection) => new GrassCoverErosionInwardsFailureMechanismContext( - (GrassCoverErosionInwardsFailureMechanism) mechanism, - assessmentSection) - ), + (GrassCoverErosionInwardsFailureMechanism) mechanism, + assessmentSection) + ), new FailureMechanismContextAssociation( typeof(HeightStructuresFailureMechanism), (mechanism, assessmentSection) => new HeightStructuresFailureMechanismContext( - (HeightStructuresFailureMechanism) mechanism, - assessmentSection) - ), + (HeightStructuresFailureMechanism) mechanism, + assessmentSection) + ), new FailureMechanismContextAssociation( typeof(DuneErosionFailureMechanism), (mechanism, assessmentSection) => new DuneErosionFailureMechanismContext( - (DuneErosionFailureMechanism) mechanism, - assessmentSection) - ), + (DuneErosionFailureMechanism) mechanism, + assessmentSection) + ), new FailureMechanismContextAssociation( typeof(GrassCoverErosionOutwardsFailureMechanism), (mechanism, assessmentSection) => new GrassCoverErosionOutwardsFailureMechanismContext( - (GrassCoverErosionOutwardsFailureMechanism) mechanism, - assessmentSection) - ), + (GrassCoverErosionOutwardsFailureMechanism) mechanism, + assessmentSection) + ), new FailureMechanismContextAssociation( typeof(GrassCoverSlipOffInwardsFailureMechanism), (mechanism, assessmentSection) => new FailureMechanismContext( - mechanism, - assessmentSection) - ), + mechanism, + assessmentSection) + ), new FailureMechanismContextAssociation( typeof(GrassCoverSlipOffOutwardsFailureMechanism), (mechanism, assessmentSection) => new FailureMechanismContext( - mechanism, - assessmentSection) - ), + mechanism, + assessmentSection) + ), new FailureMechanismContextAssociation( typeof(MicrostabilityFailureMechanism), (mechanism, assessmentSection) => new FailureMechanismContext( - mechanism, - assessmentSection) - ), + mechanism, + assessmentSection) + ), new FailureMechanismContextAssociation( typeof(PipingStructureFailureMechanism), (mechanism, assessmentSection) => new FailureMechanismContext( - mechanism, - assessmentSection) - ), + mechanism, + assessmentSection) + ), new FailureMechanismContextAssociation( typeof(StabilityStoneCoverFailureMechanism), (mechanism, assessmentSection) => new StabilityStoneCoverFailureMechanismContext( - (StabilityStoneCoverFailureMechanism) mechanism, - assessmentSection) - ), + (StabilityStoneCoverFailureMechanism) mechanism, + assessmentSection) + ), new FailureMechanismContextAssociation( typeof(TechnicalInnovationFailureMechanism), (mechanism, assessmentSection) => new FailureMechanismContext( - mechanism, - assessmentSection) - ), + mechanism, + assessmentSection) + ), new FailureMechanismContextAssociation( typeof(StrengthStabilityLengthwiseConstructionFailureMechanism), (mechanism, assessmentSection) => new FailureMechanismContext( - mechanism, - assessmentSection) - ), + mechanism, + assessmentSection) + ), new FailureMechanismContextAssociation( typeof(WaveImpactAsphaltCoverFailureMechanism), (mechanism, assessmentSection) => new WaveImpactAsphaltCoverFailureMechanismContext( - (WaveImpactAsphaltCoverFailureMechanism) mechanism, - assessmentSection) - ), + (WaveImpactAsphaltCoverFailureMechanism) mechanism, + assessmentSection) + ), new FailureMechanismContextAssociation( typeof(WaterPressureAsphaltCoverFailureMechanism), (mechanism, assessmentSection) => new FailureMechanismContext( - mechanism, - assessmentSection) - ), + mechanism, + assessmentSection) + ), new FailureMechanismContextAssociation( typeof(ClosingStructuresFailureMechanism), (mechanism, assessmentSection) => new ClosingStructuresFailureMechanismContext( - (ClosingStructuresFailureMechanism) mechanism, - assessmentSection) - ), + (ClosingStructuresFailureMechanism) mechanism, + assessmentSection) + ), new FailureMechanismContextAssociation( typeof(MacrostabilityInwardsFailureMechanism), (mechanism, assessmentSection) => new FailureMechanismContext( - mechanism, - assessmentSection) - ), + mechanism, + assessmentSection) + ), new FailureMechanismContextAssociation( typeof(MacrostabilityOutwardsFailureMechanism), (mechanism, assessmentSection) => new FailureMechanismContext( - mechanism, - assessmentSection) - ), + mechanism, + assessmentSection) + ), new FailureMechanismContextAssociation( typeof(StabilityPointStructuresFailureMechanism), (mechanism, assessmentSection) => new StabilityPointStructuresFailureMechanismContext( - (StabilityPointStructuresFailureMechanism) mechanism, - assessmentSection) - ) + (StabilityPointStructuresFailureMechanism) mechanism, + assessmentSection) + ) }; #endregion @@ -279,10 +280,10 @@ yield return new PropertyInfo { CreateInstance = context => new FailureMechanismContributionProperties( - context.WrappedData, - context.Parent, - new FailureMechanismContributionNormChangeHandler(), - new AssessmentSectionCompositionChangeHandler()) + context.WrappedData, + context.Parent, + new FailureMechanismContributionNormChangeHandler(), + new AssessmentSectionCompositionChangeHandler()) }; yield return new PropertyInfo, StandAloneFailureMechanismContextProperties>(); yield return new PropertyInfo, CalculationGroupContextProperties>(); @@ -291,13 +292,13 @@ yield return new PropertyInfo { CreateInstance = context => new DesignWaterLevelLocationsContextProperties( - context.WrappedData.HydraulicBoundaryDatabase) + context.WrappedData.HydraulicBoundaryDatabase) }; yield return new PropertyInfo(); yield return new PropertyInfo { CreateInstance = context => new WaveHeightLocationsContextProperties( - context.WrappedData.HydraulicBoundaryDatabase) + context.WrappedData.HydraulicBoundaryDatabase) }; yield return new PropertyInfo(); yield return new PropertyInfo(); @@ -456,8 +457,8 @@ yield return new ExportInfo { CreateFileExporter = (context, filePath) => new HydraulicBoundaryLocationsExporter( - context.WrappedData.HydraulicBoundaryDatabase.Locations, filePath, - RingtoetsIntegrationPluginResources.DesignWaterLevel_Description, RingtoetsIntegrationPluginResources.WaveHeight_Description), + context.WrappedData.HydraulicBoundaryDatabase.Locations, filePath, + RingtoetsIntegrationPluginResources.DesignWaterLevel_Description, RingtoetsIntegrationPluginResources.WaveHeight_Description), IsEnabled = context => context.WrappedData.HydraulicBoundaryDatabase != null, FileFilter = RingtoetsCommonIoResources.DataTypeDisplayName_shape_file_filter }; @@ -522,10 +523,10 @@ Color.FromKnownColor(KnownColor.GrayText) : Color.FromKnownColor(KnownColor.ControlText), ContextMenuStrip = (nodeData, parentData, treeViewControl) => - Gui.Get(nodeData, treeViewControl) - .AddImportItem() - .AddExportItem() - .Build() + Gui.Get(nodeData, treeViewControl) + .AddImportItem() + .AddExportItem() + .Build() }; yield return RingtoetsTreeNodeInfoFactory.CreateFailureMechanismContextTreeNodeInfo>( @@ -1062,8 +1063,8 @@ return assessmentSection .GetFailureMechanisms() .Select(failureMechanism => failureMechanismAssociations - .First(a => a.Match(failureMechanism)) - .Create(failureMechanism, assessmentSection) + .First(a => a.Match(failureMechanism)) + .Create(failureMechanism, assessmentSection) ); } @@ -1327,11 +1328,7 @@ } }); - if (nodeData.WrappedData.HydraulicBoundaryDatabase == null) - { - designWaterLevelItem.Enabled = false; - designWaterLevelItem.ToolTipText = RingtoetsFormsResources.DesignWaterLevel_No_HRD_To_Calculate; - } + SetHydraulicsMenuItemEnabledStateAndTooltip(nodeData.WrappedData, designWaterLevelItem); return Gui.Get(nodeData, treeViewControl) .AddOpenItem() @@ -1366,11 +1363,7 @@ } }); - if (nodeData.WrappedData.HydraulicBoundaryDatabase == null) - { - waveHeightItem.Enabled = false; - waveHeightItem.ToolTipText = RingtoetsFormsResources.WaveHeight_No_HRD_To_Calculate; - } + SetHydraulicsMenuItemEnabledStateAndTooltip(nodeData.WrappedData, waveHeightItem); return Gui.Get(nodeData, treeViewControl) .AddOpenItem() @@ -1381,6 +1374,16 @@ .Build(); } + private static void SetHydraulicsMenuItemEnabledStateAndTooltip(IAssessmentSection assessmentSection, StrictContextMenuItem menuItem) + { + var validationText = HydraulicBoundaryDatabaseConnectionValidator.Validate(assessmentSection.HydraulicBoundaryDatabase); + if (!string.IsNullOrEmpty(validationText)) + { + menuItem.Enabled = false; + menuItem.ToolTipText = validationText; + } + } + private ContextMenuStrip HydraulicBoundaryDatabaseContextMenuStrip(HydraulicBoundaryDatabaseContext nodeData, object parentData, TreeViewControl treeViewControl) { var connectionItem = new StrictContextMenuItem( Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/DesignWaterLevelLocationsContextTreeNodeInfoTest.cs =================================================================== diff -u -r67823f50a5a4e994c13dac0269fb61e8783efead -r604d0e202fa546642f20240c80aac5d98447e4fc --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/DesignWaterLevelLocationsContextTreeNodeInfoTest.cs (.../DesignWaterLevelLocationsContextTreeNodeInfoTest.cs) (revision 67823f50a5a4e994c13dac0269fb61e8783efead) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/DesignWaterLevelLocationsContextTreeNodeInfoTest.cs (.../DesignWaterLevelLocationsContextTreeNodeInfoTest.cs) (revision 604d0e202fa546642f20240c80aac5d98447e4fc) @@ -24,7 +24,6 @@ using System.Linq; using System.Threading; using System.Windows.Forms; -using Core.Common.Base.Data; using Core.Common.Controls.TreeView; using Core.Common.Gui; using Core.Common.Gui.ContextMenu; @@ -160,19 +159,24 @@ } [Test] - public void ContextMenuStrip_NoHydraulicBoundaryDatabase_ContextMenuItemCalculateAllDisabled() + public void ContextMenuStrip_HydraulicBoundaryDatabaseNotValid_ContextMenuItemCalculateAllDisabledAndTooltipSet() { // Setup - var guiMock = mockRepository.StrictMock(); var assessmentSectionMock = mockRepository.Stub(); - var nodeData = new DesignWaterLevelLocationsContext(assessmentSectionMock); + var nodeData = new DesignWaterLevelLocationsContext(assessmentSectionMock) + { + WrappedData = + { + HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase() + } + }; - guiMock.Stub(g => g.ProjectOpened += null).IgnoreArguments(); - guiMock.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); - using (var treeViewControl = new TreeViewControl()) { + var guiMock = mockRepository.StrictMock(); + guiMock.Stub(g => g.ProjectOpened += null).IgnoreArguments(); + guiMock.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); guiMock.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); mockRepository.ReplayAll(); @@ -186,11 +190,12 @@ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // Assert - const string expectedItemText = "Alles be&rekenen"; - const string expectedItemTooltip = "Er is geen hydraulische randvoorwaardendatabase beschikbaar om de toetspeilen te berekenen."; + ToolStripItem contextMenuItem = contextMenu.Items[contextMenuRunAssessmentLevelCalculationsIndex]; - TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuRunAssessmentLevelCalculationsIndex, - expectedItemText, expectedItemTooltip, RingtoetsCommonFormsResources.CalculateAllIcon, false); + Assert.AreEqual("Alles be&rekenen", contextMenuItem.Text); + StringAssert.Contains("Herstellen van de verbinding met de hydraulische randvoorwaardendatabase is mislukt.", contextMenuItem.ToolTipText); + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.CalculateAllIcon, contextMenuItem.Image); + Assert.IsFalse(contextMenuItem.Enabled); } } } @@ -208,7 +213,10 @@ { WrappedData = { - HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase() + HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = Path.Combine(TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, "HydraulicBoundaryDatabaseImporter"), "complete.sqlite") + } } }; @@ -244,71 +252,6 @@ [Test] [Apartment(ApartmentState.STA)] - public void GivenHydraulicBoundaryDatabaseWithNonExistingFilePath_WhenCalculatingAssessmentLevelFromContextMenu_ThenLogMessagesAddedPreviousOutputNotAffected() - { - // Given - var guiMock = mockRepository.DynamicMock(); - RoundedDouble designWaterLevel = (RoundedDouble) 4.2; - - var hydraulicBoundaryLocation1 = new HydraulicBoundaryLocation(100001, "", 1.1, 2.2); - var hydraulicBoundaryLocation2 = new HydraulicBoundaryLocation(100002, "", 3.3, 4.4) - { - DesignWaterLevelOutput = new TestHydraulicBoundaryLocationOutput(designWaterLevel) - }; - - var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase - { - Locations = - { - hydraulicBoundaryLocation1, - hydraulicBoundaryLocation2 - }, - FilePath = "D:/nonExistingDirectory/nonExistingFile", - Version = "random" - }; - - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) - { - HydraulicBoundaryDatabase = hydraulicBoundaryDatabase - }; - var context = new DesignWaterLevelLocationsContext(assessmentSection); - - using (var treeViewControl = new TreeViewControl()) - { - guiMock.Expect(g => g.Get(context, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); - guiMock.Expect(g => g.MainWindow).Return(mockRepository.Stub()); - guiMock.Expect(g => g.DocumentViewController).Return(mockRepository.Stub()); - - mockRepository.ReplayAll(); - - using (var plugin = new RingtoetsPlugin()) - { - TreeNodeInfo info = GetInfo(plugin); - plugin.Gui = guiMock; - plugin.Activate(); - - using (ContextMenuStrip contextMenuAdapter = info.ContextMenuStrip(context, null, treeViewControl)) - { - // When - Action action = () => contextMenuAdapter.Items[contextMenuRunAssessmentLevelCalculationsIndex].PerformClick(); - - // Then - string message = string.Format("Berekeningen konden niet worden gestart. Fout bij het lezen van bestand '{0}': het bestand bestaat niet.", - hydraulicBoundaryDatabase.FilePath); - TestHelper.AssertLogMessageWithLevelIsGenerated(action, new Tuple(message, LogLevelConstant.Error)); - - Assert.IsNaN(hydraulicBoundaryLocation1.DesignWaterLevel); // No result set - - // Previous result not cleared - Assert.AreEqual(designWaterLevel, hydraulicBoundaryLocation2.DesignWaterLevel, hydraulicBoundaryLocation2.DesignWaterLevel.GetAccuracy()); - } - } - } - mockRepository.VerifyAll(); - } - - [Test] - [Apartment(ApartmentState.STA)] public void GivenHydraulicBoundaryLocationThatSucceeds_CalculatingAssessmentLevelFromContextMenu_ThenLogMessagesAddedOutputSet() { // Given Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/WaveHeightLocationsContextTreeNodeInfoTest.cs =================================================================== diff -u -r67823f50a5a4e994c13dac0269fb61e8783efead -r604d0e202fa546642f20240c80aac5d98447e4fc --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/WaveHeightLocationsContextTreeNodeInfoTest.cs (.../WaveHeightLocationsContextTreeNodeInfoTest.cs) (revision 67823f50a5a4e994c13dac0269fb61e8783efead) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/WaveHeightLocationsContextTreeNodeInfoTest.cs (.../WaveHeightLocationsContextTreeNodeInfoTest.cs) (revision 604d0e202fa546642f20240c80aac5d98447e4fc) @@ -25,7 +25,6 @@ using System.Linq; using System.Threading; using System.Windows.Forms; -using Core.Common.Base.Data; using Core.Common.Controls.TreeView; using Core.Common.Gui; using Core.Common.Gui.ContextMenu; @@ -38,7 +37,6 @@ using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Hydraulics; -using Ringtoets.Common.Data.TestUtil; using Ringtoets.HydraRing.Calculation.TestUtil.Calculator; using Ringtoets.Integration.Data; using Ringtoets.Integration.Forms.PresentationObjects; @@ -163,14 +161,19 @@ } [Test] - public void ContextMenuStrip_NoHydraulicBoundaryDatabase_ContextMenuItemCalculateAllDisabled() + public void ContextMenuStrip_HydraulicBoundaryDatabaseNotValid_ContextMenuItemCalculateAllDisabledAndTooltipSet() { // Setup var guiMock = mockRepository.StrictMock(); var assessmentSectionMock = mockRepository.Stub(); - var nodeData = new WaveHeightLocationsContext(assessmentSectionMock); - + var nodeData = new WaveHeightLocationsContext(assessmentSectionMock) + { + WrappedData = + { + HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase() + } + }; guiMock.Stub(g => g.ProjectOpened += null).IgnoreArguments(); guiMock.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); @@ -189,10 +192,12 @@ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // Assert - const string expectedItemText = "Alles be&rekenen"; - const string expectedItemTooltip = "Er is geen hydraulische randvoorwaardendatabase beschikbaar om de golfhoogtes te berekenen."; - TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuRunWaveHeightCalculationsIndex, - expectedItemText, expectedItemTooltip, RingtoetsCommonFormsResources.CalculateAllIcon, false); + ToolStripItem contextMenuItem = contextMenu.Items[contextMenuRunWaveHeightCalculationsIndex]; + + Assert.AreEqual("Alles be&rekenen", contextMenuItem.Text); + StringAssert.Contains("Herstellen van de verbinding met de hydraulische randvoorwaardendatabase is mislukt.", contextMenuItem.ToolTipText); + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.CalculateAllIcon, contextMenuItem.Image); + Assert.IsFalse(contextMenuItem.Enabled); } } } @@ -211,7 +216,10 @@ { WrappedData = { - HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase() + HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = Path.Combine(TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, "HydraulicBoundaryDatabaseImporter"), "complete.sqlite") + } } }; guiMock.Stub(g => g.ProjectOpened += null).IgnoreArguments(); @@ -246,71 +254,6 @@ [Test] [Apartment(ApartmentState.STA)] - public void GivenHydraulicBoundaryDatabaseWithNonExistingFilePath_WhenCalculatingWaveHeightFromContextMenu_ThenLogMessagesAddedPreviousOutputNotAffected() - { - // Given - var guiMock = mockRepository.DynamicMock(); - - RoundedDouble waveHeight = (RoundedDouble) 4.2; - var hydraulicBoundaryLocation1 = new HydraulicBoundaryLocation(100001, "", 1.1, 2.2); - var hydraulicBoundaryLocation2 = new HydraulicBoundaryLocation(100002, "", 3.3, 4.4) - { - WaveHeightOutput = new TestHydraulicBoundaryLocationOutput(waveHeight) - }; - - var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase - { - Locations = - { - hydraulicBoundaryLocation1, - hydraulicBoundaryLocation2 - }, - FilePath = "D:/nonExistingDirectory/nonExistingFile", - Version = "random" - }; - - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) - { - HydraulicBoundaryDatabase = hydraulicBoundaryDatabase - }; - var context = new WaveHeightLocationsContext(assessmentSection); - - using (var treeViewControl = new TreeViewControl()) - { - guiMock.Expect(g => g.Get(context, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); - guiMock.Expect(g => g.MainWindow).Return(mockRepository.Stub()); - guiMock.Expect(g => g.DocumentViewController).Return(mockRepository.Stub()); - - mockRepository.ReplayAll(); - - using (var plugin = new RingtoetsPlugin()) - { - TreeNodeInfo info = GetInfo(plugin); - plugin.Gui = guiMock; - plugin.Activate(); - - using (ContextMenuStrip contextMenuAdapter = info.ContextMenuStrip(context, null, treeViewControl)) - { - // When - Action action = () => contextMenuAdapter.Items[contextMenuRunWaveHeightCalculationsIndex].PerformClick(); - - // Then - string message = string.Format("Berekeningen konden niet worden gestart. Fout bij het lezen van bestand '{0}': het bestand bestaat niet.", - hydraulicBoundaryDatabase.FilePath); - TestHelper.AssertLogMessageWithLevelIsGenerated(action, new Tuple(message, LogLevelConstant.Error)); - - Assert.IsNaN(hydraulicBoundaryLocation1.WaveHeight); // No result set - - // Previous result not cleared - Assert.AreEqual(waveHeight, hydraulicBoundaryLocation2.WaveHeight, hydraulicBoundaryLocation2.WaveHeight.GetAccuracy()); - } - } - } - mockRepository.VerifyAll(); - } - - [Test] - [Apartment(ApartmentState.STA)] public void GivenHydraulicBoundaryLocationThatSucceeds_CalculatingWaveHeightFromContextMenu_ThenLogMessagesAddedPreviousOutputAffected() { // Given