Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.Designer.cs
===================================================================
diff -u -r46a43161180fdb21438c4b48ac66479ea38b9764 -r59a82ae3063f2dda858cc5cf43e25c224856d88d
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 46a43161180fdb21438c4b48ac66479ea38b9764)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 59a82ae3063f2dda858cc5cf43e25c224856d88d)
@@ -390,9 +390,9 @@
///
/// Looks up a localized string similar to Toetspeilen.
///
- public static string DesignWaterLevelLocationsContext_DisplayName {
+ public static string DesignWaterLevelCalculationsContext_DisplayName {
get {
- return ResourceManager.GetString("DesignWaterLevelLocationsContext_DisplayName", resourceCulture);
+ return ResourceManager.GetString("DesignWaterLevelCalculationsContext_DisplayName", resourceCulture);
}
}
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.resx
===================================================================
diff -u -r46a43161180fdb21438c4b48ac66479ea38b9764 -r59a82ae3063f2dda858cc5cf43e25c224856d88d
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.resx (.../Resources.resx) (revision 46a43161180fdb21438c4b48ac66479ea38b9764)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.resx (.../Resources.resx) (revision 59a82ae3063f2dda858cc5cf43e25c224856d88d)
@@ -237,7 +237,7 @@
T&raject toevoegen...
-
+
Toetspeilen
Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs
===================================================================
diff -u -r72ec3a0d168944ed9625ac807af2757ca29cebfc -r59a82ae3063f2dda858cc5cf43e25c224856d88d
--- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 72ec3a0d168944ed9625ac807af2757ca29cebfc)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 59a82ae3063f2dda858cc5cf43e25c224856d88d)
@@ -397,7 +397,7 @@
yield return new ViewInfo, DesignWaterLevelCalculationsView>
{
- GetViewName = (view, context) => $"{RingtoetsFormsResources.DesignWaterLevelLocationsContext_DisplayName} - {context.CategoryBoundaryName}",
+ GetViewName = (view, context) => $"{RingtoetsFormsResources.DesignWaterLevelCalculationsContext_DisplayName} - {context.CategoryBoundaryName}",
GetViewData = context => context.WrappedData,
Image = RingtoetsCommonFormsResources.GenericInputOutputIcon,
CloseForData = CloseHydraulicBoundaryCalculationsViewForData,
@@ -760,7 +760,7 @@
yield return new TreeNodeInfo
{
- Text = context => RingtoetsFormsResources.DesignWaterLevelLocationsContext_DisplayName,
+ Text = context => RingtoetsFormsResources.DesignWaterLevelCalculationsContext_DisplayName,
Image = context => RingtoetsCommonFormsResources.GeneralFolderIcon,
ContextMenuStrip = DesignWaterLevelLocationsGroupContextMenuStrip,
ChildNodeObjects = DesignWaterLevelLocationsGroupContextChildNodeObjects
@@ -770,7 +770,7 @@
{
Text = context => context.CategoryBoundaryName,
Image = context => RingtoetsCommonFormsResources.GenericInputOutputIcon,
- ContextMenuStrip = DesignWaterLevelLocationsContextMenuStrip
+ ContextMenuStrip = DesignWaterLevelCalculationsContextMenuStrip
};
yield return new TreeNodeInfo
@@ -1736,7 +1736,7 @@
return new object[0];
}
- private ContextMenuStrip DesignWaterLevelLocationsContextMenuStrip(DesignWaterLevelCalculationsContext nodeData, object parentData, TreeViewControl treeViewControl)
+ private ContextMenuStrip DesignWaterLevelCalculationsContextMenuStrip(DesignWaterLevelCalculationsContext nodeData, object parentData, TreeViewControl treeViewControl)
{
var designWaterLevelItem = new StrictContextMenuItem(
RingtoetsFormsResources.DesignWaterLevel_Calculate_All,
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/DesignWaterLevelCalculationsContextTest.cs
===================================================================
diff -u -r72ec3a0d168944ed9625ac807af2757ca29cebfc -r59a82ae3063f2dda858cc5cf43e25c224856d88d
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/DesignWaterLevelCalculationsContextTest.cs (.../DesignWaterLevelCalculationsContextTest.cs) (revision 72ec3a0d168944ed9625ac807af2757ca29cebfc)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/DesignWaterLevelCalculationsContextTest.cs (.../DesignWaterLevelCalculationsContextTest.cs) (revision 59a82ae3063f2dda858cc5cf43e25c224856d88d)
@@ -134,7 +134,7 @@
}
[TestFixture]
- private class DesignWaterLevelLocationsContextEqualsTest
+ private class DesignWaterLevelCalculationsContextEqualsTest
: EqualsTestFixture
{
private static readonly MockRepository mocks = new MockRepository();
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/DesignWaterLevelCalculationsContextPropertyInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/DesignWaterLevelCalculationsContextPropertyInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/DesignWaterLevelCalculationsContextPropertyInfoTest.cs (revision 59a82ae3063f2dda858cc5cf43e25c224856d88d)
@@ -0,0 +1,104 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Linq;
+using Core.Common.Base;
+using Core.Common.Gui.Plugin;
+using Core.Common.Gui.PropertyBag;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.Integration.Forms.PresentationObjects;
+using Ringtoets.Integration.Forms.PropertyClasses;
+
+namespace Ringtoets.Integration.Plugin.Test.PropertyInfos
+{
+ [TestFixture]
+ public class DesignWaterLevelCalculationsContextPropertyInfoTest
+ {
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ using (var plugin = new RingtoetsPlugin())
+ {
+ // Call
+ PropertyInfo info = GetInfo(plugin);
+
+ // Assert
+ Assert.AreEqual(typeof(DesignWaterLevelCalculationsContext), info.DataType);
+ Assert.AreEqual(typeof(DesignWaterLevelCalculationsProperties), info.PropertyObjectType);
+ }
+ }
+
+ [Test]
+ public void CreateInstance_WithContext_SetsDataCorrectly()
+ {
+ // Setup
+ var mockRepository = new MockRepository();
+ var assessmentSection = mockRepository.Stub();
+ mockRepository.ReplayAll();
+
+ var random = new Random();
+
+ var hydraulicBoundaryLocationCalculations = new ObservableList
+ {
+ new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation())
+ {
+ Output = new TestHydraulicBoundaryLocationOutput(random.NextDouble())
+ },
+ new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation())
+ {
+ Output = new TestHydraulicBoundaryLocationOutput(random.NextDouble())
+ }
+ };
+
+ var context = new DesignWaterLevelCalculationsContext(hydraulicBoundaryLocationCalculations,
+ assessmentSection,
+ () => 0.01,
+ "Category");
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ PropertyInfo info = GetInfo(plugin);
+
+ // Call
+ IObjectProperties objectProperties = info.CreateInstance(context);
+
+ // Assert
+ Assert.IsInstanceOf(objectProperties);
+ Assert.AreSame(hydraulicBoundaryLocationCalculations, objectProperties.Data);
+ DesignWaterLevelCalculationProperties[] calculationProperties = ((DesignWaterLevelCalculationsProperties) objectProperties).Calculations;
+ CollectionAssert.AreEqual(hydraulicBoundaryLocationCalculations, calculationProperties.Select(p => p.Data));
+ }
+
+ mockRepository.VerifyAll();
+ }
+
+ private static PropertyInfo GetInfo(RingtoetsPlugin plugin)
+ {
+ return plugin.GetPropertyInfos().First(pi => pi.DataType == typeof(DesignWaterLevelCalculationsContext));
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 59a82ae3063f2dda858cc5cf43e25c224856d88d refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/DesignWaterLevelLocationsContextPropertyInfoTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj
===================================================================
diff -u -r682dfada6e821a0dd7cf3f6be9a2823eb72d9302 -r59a82ae3063f2dda858cc5cf43e25c224856d88d
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision 682dfada6e821a0dd7cf3f6be9a2823eb72d9302)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision 59a82ae3063f2dda858cc5cf43e25c224856d88d)
@@ -51,7 +51,7 @@
-
+
@@ -71,7 +71,7 @@
-
+
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/DesignWaterLevelCalculationsContextTreeNodeInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/DesignWaterLevelCalculationsContextTreeNodeInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/DesignWaterLevelCalculationsContextTreeNodeInfoTest.cs (revision 59a82ae3063f2dda858cc5cf43e25c224856d88d)
@@ -0,0 +1,619 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Drawing;
+using System.IO;
+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;
+using Core.Common.Gui.Forms.MainWindow;
+using Core.Common.Gui.Forms.ViewHost;
+using Core.Common.Gui.TestUtil.ContextMenu;
+using Core.Common.TestUtil;
+using Core.Common.Util;
+using NUnit.Extensions.Forms;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.Common.Service.TestUtil;
+using Ringtoets.HydraRing.Calculation.Calculator.Factory;
+using Ringtoets.HydraRing.Calculation.Data.Input.Hydraulics;
+using Ringtoets.HydraRing.Calculation.TestUtil.Calculator;
+using Ringtoets.Integration.Data;
+using Ringtoets.Integration.Forms.PresentationObjects;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.Integration.Plugin.Test.TreeNodeInfos
+{
+ [TestFixture]
+ public class DesignWaterLevelCalculationsContextTreeNodeInfoTest : NUnitFormTest
+ {
+ private const int contextMenuRunAssessmentLevelCalculationsIndex = 2;
+ private MockRepository mockRepository;
+
+ private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Service, "HydraRingCalculation");
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ using (var plugin = new RingtoetsPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+
+ // Assert
+ Assert.IsNotNull(info.Text);
+ Assert.IsNull(info.ForeColor);
+ Assert.IsNotNull(info.Image);
+ Assert.IsNotNull(info.ContextMenuStrip);
+ Assert.IsNull(info.EnsureVisibleOnCreate);
+ Assert.IsNull(info.ExpandOnCreate);
+ Assert.IsNull(info.ChildNodeObjects);
+ Assert.IsNull(info.CanRename);
+ Assert.IsNull(info.OnNodeRenamed);
+ Assert.IsNull(info.CanRemove);
+ Assert.IsNull(info.OnNodeRemoved);
+ Assert.IsNull(info.CanCheck);
+ Assert.IsNull(info.IsChecked);
+ Assert.IsNull(info.OnNodeChecked);
+ Assert.IsNull(info.CanDrag);
+ Assert.IsNull(info.CanDrop);
+ Assert.IsNull(info.CanInsert);
+ Assert.IsNull(info.OnDrop);
+ }
+ }
+
+ [Test]
+ public void Text_Always_ReturnsCategoryBoundaryName()
+ {
+ // Setup
+ IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(mockRepository);
+ mockRepository.ReplayAll();
+
+ const string categoryBoundaryName = "Category";
+ var context = new DesignWaterLevelCalculationsContext(new ObservableList(),
+ assessmentSection,
+ () => 0.01,
+ categoryBoundaryName);
+
+ // Setup
+ using (var plugin = new RingtoetsPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+
+ // Call
+ string text = info.Text(context);
+
+ // Assert
+ Assert.AreEqual(categoryBoundaryName, text);
+ }
+
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void Image_Always_ReturnsGenericInputOutputIcon()
+ {
+ // Setup
+ using (var plugin = new RingtoetsPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+
+ // Call
+ Image image = info.Image(null);
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, image);
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods()
+ {
+ // Setup
+ IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(mockRepository);
+
+ var menuBuilder = mockRepository.StrictMock();
+ using (mockRepository.Ordered())
+ {
+ menuBuilder.Expect(mb => mb.AddOpenItem()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.Build()).Return(null);
+ }
+
+ var nodeData = new DesignWaterLevelCalculationsContext(new ObservableList(),
+ assessmentSection,
+ () => 0.01,
+ "Category");
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ 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(menuBuilder);
+ mockRepository.ReplayAll();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+
+ plugin.Gui = gui;
+
+ // Call
+ info.ContextMenuStrip(nodeData, null, treeViewControl);
+ }
+ }
+
+ // Assert
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void ContextMenuStrip_HydraulicBoundaryDatabaseNotLinked_ContextMenuItemCalculateAllDisabledAndTooltipSet()
+ {
+ // Setup
+ IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(mockRepository);
+
+ var nodeData = new DesignWaterLevelCalculationsContext(new ObservableList(),
+ assessmentSection,
+ () => 0.01,
+ "Category");
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ 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())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+
+ plugin.Gui = gui;
+
+ // Call
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl))
+ {
+ // Assert
+ ToolStripItem contextMenuItem = contextMenu.Items[contextMenuRunAssessmentLevelCalculationsIndex];
+
+ 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 DesignWaterLevelCalculationsContext(new ObservableList(),
+ assessmentSection,
+ () => 0.01,
+ "Category");
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ 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())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+
+ plugin.Gui = gui;
+
+ // Call
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl))
+ {
+ // Assert
+ ToolStripItem contextMenuItem = contextMenu.Items[contextMenuRunAssessmentLevelCalculationsIndex];
+
+ 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);
+ }
+ }
+ }
+
+ mockRepository.VerifyAll(); // Expect no calls on arguments
+ }
+
+ [Test]
+ public void ContextMenuStrip_AllRequiredInputSet_ContextMenuItemCalculateAllEnabled()
+ {
+ // Setup
+ var assessmentSection = mockRepository.Stub();
+ var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase
+ {
+ FilePath = Path.Combine(TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, "HydraulicBoundaryDatabaseImporter"), "complete.sqlite")
+ };
+
+ assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(hydraulicBoundaryDatabase);
+
+ var nodeData = new DesignWaterLevelCalculationsContext(new ObservableList(),
+ assessmentSection,
+ () => 0.01,
+ "Category");
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ 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())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+
+ plugin.Gui = gui;
+
+ // Call
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl))
+ {
+ // Assert
+ const string expectedItemText = @"Alles be&rekenen";
+ const string expectedItemTooltip = @"Alle toetspeilen berekenen.";
+
+ TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuRunAssessmentLevelCalculationsIndex,
+ expectedItemText, expectedItemTooltip, RingtoetsCommonFormsResources.CalculateAllIcon);
+ }
+ }
+ }
+
+ mockRepository.VerifyAll(); // Expect no calls on arguments
+ }
+
+ [Test]
+ [Apartment(ApartmentState.STA)]
+ public void CalculateDesignWaterLevelsFromContextMenu_HydraulicBoundaryDatabaseWithCanUsePreprocessorFalse_SendsRightInputToCalculationService()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ HydraulicBoundaryDatabase =
+ {
+ FilePath = Path.Combine(testDataPath, "HRD ijsselmeer.sqlite")
+ }
+ };
+
+ var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation("locationName");
+ var hydraulicBoundaryLocationCalculations = new ObservableList
+ {
+ new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation)
+ };
+
+ Func getNormFunc = () => 0.01;
+ var context = new DesignWaterLevelCalculationsContext(hydraulicBoundaryLocationCalculations,
+ assessmentSection,
+ getNormFunc,
+ "Category");
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var gui = mockRepository.Stub();
+ gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+ gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
+ gui.Stub(g => g.MainWindow).Return(mockRepository.Stub());
+ gui.Stub(g => g.DocumentViewController).Return(mockRepository.Stub());
+
+ var designWaterLevelCalculator = new TestDesignWaterLevelCalculator();
+ var calculatorFactory = mockRepository.Stub();
+ calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(testDataPath, string.Empty)).Return(designWaterLevelCalculator);
+ mockRepository.ReplayAll();
+
+ DialogBoxHandler = (name, wnd) =>
+ {
+ // Expect an activity dialog which is automatically closed
+ };
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+ plugin.Gui = gui;
+ plugin.Activate();
+
+ using (ContextMenuStrip contextMenuAdapter = info.ContextMenuStrip(context, null, treeViewControl))
+ using (new HydraRingCalculatorFactoryConfig(calculatorFactory))
+ {
+ // Call
+ contextMenuAdapter.Items[contextMenuRunAssessmentLevelCalculationsIndex].PerformClick();
+
+ // Assert
+ AssessmentLevelCalculationInput designWaterLevelCalculationInput = designWaterLevelCalculator.ReceivedInputs.First();
+
+ Assert.AreEqual(hydraulicBoundaryLocation.Id, designWaterLevelCalculationInput.HydraulicBoundaryLocationId);
+ Assert.AreEqual(StatisticsConverter.ProbabilityToReliability(getNormFunc()), designWaterLevelCalculationInput.Beta);
+ }
+ }
+ }
+
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ [Apartment(ApartmentState.STA)]
+ public void CalculateDesignWaterLevelsFromContextMenu_HydraulicBoundaryDatabaseWithUsePreprocessorTrue_SendsRightInputToCalculationService()
+ {
+ // Setup
+ string preprocessorDirectory = TestHelper.GetScratchPadPath();
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ HydraulicBoundaryDatabase =
+ {
+ FilePath = Path.Combine(testDataPath, "HRD ijsselmeer.sqlite"),
+ CanUsePreprocessor = true,
+ UsePreprocessor = true,
+ PreprocessorDirectory = preprocessorDirectory
+ }
+ };
+
+ Func getNormFunc = () => 0.01;
+
+ var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation("locationName");
+ var hydraulicBoundaryLocationCalculations = new ObservableList
+ {
+ new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation)
+ };
+
+ var context = new DesignWaterLevelCalculationsContext(hydraulicBoundaryLocationCalculations,
+ assessmentSection,
+ getNormFunc,
+ "Category");
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var gui = mockRepository.Stub();
+ gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+ gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
+ gui.Stub(g => g.MainWindow).Return(mockRepository.Stub());
+ gui.Stub(g => g.DocumentViewController).Return(mockRepository.Stub());
+
+ var designWaterLevelCalculator = new TestDesignWaterLevelCalculator();
+ var calculatorFactory = mockRepository.Stub();
+ calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(testDataPath, preprocessorDirectory)).Return(designWaterLevelCalculator);
+ mockRepository.ReplayAll();
+
+ DialogBoxHandler = (name, wnd) =>
+ {
+ // Expect an activity dialog which is automatically closed
+ };
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+ plugin.Gui = gui;
+ plugin.Activate();
+
+ using (ContextMenuStrip contextMenuAdapter = info.ContextMenuStrip(context, null, treeViewControl))
+ using (new HydraRingCalculatorFactoryConfig(calculatorFactory))
+ {
+ // Call
+ contextMenuAdapter.Items[contextMenuRunAssessmentLevelCalculationsIndex].PerformClick();
+
+ // Assert
+ AssessmentLevelCalculationInput designWaterLevelCalculationInput = designWaterLevelCalculator.ReceivedInputs.First();
+
+ Assert.AreEqual(hydraulicBoundaryLocation.Id, designWaterLevelCalculationInput.HydraulicBoundaryLocationId);
+ Assert.AreEqual(StatisticsConverter.ProbabilityToReliability(getNormFunc()), designWaterLevelCalculationInput.Beta);
+ }
+ }
+ }
+
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ [Apartment(ApartmentState.STA)]
+ public void CalculateDesignWaterLevelsFromContextMenu_HydraulicBoundaryDatabaseWithUsePreprocessorFalse_SendsRightInputToCalculationService()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ HydraulicBoundaryDatabase =
+ {
+ FilePath = Path.Combine(testDataPath, "HRD ijsselmeer.sqlite"),
+ CanUsePreprocessor = true,
+ UsePreprocessor = false,
+ PreprocessorDirectory = "InvalidPreprocessorDirectory"
+ }
+ };
+
+ Func getNormFunc = () => 0.01;
+
+ var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation("locationName");
+ var hydraulicBoundaryLocationCalculations = new ObservableList
+ {
+ new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation)
+ };
+
+ var context = new DesignWaterLevelCalculationsContext(hydraulicBoundaryLocationCalculations,
+ assessmentSection,
+ getNormFunc,
+ "Category");
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var gui = mockRepository.Stub();
+ gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+ gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
+ gui.Stub(g => g.MainWindow).Return(mockRepository.Stub());
+ gui.Stub(g => g.DocumentViewController).Return(mockRepository.Stub());
+
+ var designWaterLevelCalculator = new TestDesignWaterLevelCalculator();
+ var calculatorFactory = mockRepository.Stub();
+ calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(testDataPath, string.Empty)).Return(designWaterLevelCalculator);
+ mockRepository.ReplayAll();
+
+ DialogBoxHandler = (name, wnd) =>
+ {
+ // Expect an activity dialog which is automatically closed
+ };
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+ plugin.Gui = gui;
+ plugin.Activate();
+
+ using (ContextMenuStrip contextMenuAdapter = info.ContextMenuStrip(context, null, treeViewControl))
+ using (new HydraRingCalculatorFactoryConfig(calculatorFactory))
+ {
+ // Call
+ contextMenuAdapter.Items[contextMenuRunAssessmentLevelCalculationsIndex].PerformClick();
+
+ // Assert
+ AssessmentLevelCalculationInput designWaterLevelCalculationInput = designWaterLevelCalculator.ReceivedInputs.First();
+
+ Assert.AreEqual(hydraulicBoundaryLocation.Id, designWaterLevelCalculationInput.HydraulicBoundaryLocationId);
+ Assert.AreEqual(StatisticsConverter.ProbabilityToReliability(getNormFunc()), designWaterLevelCalculationInput.Beta);
+ }
+ }
+ }
+
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ [Apartment(ApartmentState.STA)]
+ public void GivenHydraulicBoundaryLocationThatSucceeds_CalculatingAssessmentLevelFromContextMenu_ThenLogMessagesAddedOutputSet()
+ {
+ // Given
+ const string locationName = "locationName";
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ HydraulicBoundaryDatabase =
+ {
+ FilePath = Path.Combine(testDataPath, "HRD ijsselmeer.sqlite")
+ }
+ };
+
+ const string categoryBoundaryName = "Category";
+ var hydraulicBoundaryLocationCalculation = new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation("locationName"));
+ var hydraulicBoundaryLocationCalculations = new ObservableList
+ {
+ hydraulicBoundaryLocationCalculation
+ };
+
+ var context = new DesignWaterLevelCalculationsContext(hydraulicBoundaryLocationCalculations,
+ assessmentSection,
+ () => 0.01,
+ categoryBoundaryName);
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var gui = mockRepository.Stub();
+ gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+ gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
+ gui.Stub(g => g.MainWindow).Return(mockRepository.Stub());
+ gui.Stub(g => g.DocumentViewController).Return(mockRepository.Stub());
+
+ var calculator = new TestDesignWaterLevelCalculator
+ {
+ Converged = false
+ };
+ var calculatorFactory = mockRepository.Stub();
+ calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(testDataPath, string.Empty)).Return(calculator);
+ mockRepository.ReplayAll();
+
+ DialogBoxHandler = (name, wnd) =>
+ {
+ // Expect an activity dialog which is automatically closed
+ };
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+ plugin.Gui = gui;
+ plugin.Activate();
+
+ using (ContextMenuStrip contextMenuAdapter = info.ContextMenuStrip(context, null, treeViewControl))
+ using (new HydraRingCalculatorFactoryConfig(calculatorFactory))
+ {
+ // When
+ Action call = () => contextMenuAdapter.Items[contextMenuRunAssessmentLevelCalculationsIndex].PerformClick();
+
+ // Then
+ TestHelper.AssertLogMessages(call, messages =>
+ {
+ string[] msgs = messages.ToArray();
+ Assert.AreEqual(8, msgs.Length);
+ Assert.AreEqual($"Toetspeil berekenen voor locatie '{locationName}' ({categoryBoundaryName}) is gestart.", msgs[0]);
+ CalculationServiceTestHelper.AssertValidationStartMessage(msgs[1]);
+ CalculationServiceTestHelper.AssertValidationEndMessage(msgs[2]);
+ CalculationServiceTestHelper.AssertCalculationStartMessage(msgs[3]);
+ Assert.AreEqual($"Toetspeil berekening voor locatie '{locationName}' ({categoryBoundaryName}) is niet geconvergeerd.", msgs[4]);
+ StringAssert.StartsWith("Toetspeil berekening is uitgevoerd op de tijdelijke locatie", msgs[5]);
+ CalculationServiceTestHelper.AssertCalculationEndMessage(msgs[6]);
+ Assert.AreEqual($"Toetspeil berekenen voor locatie '{locationName}' ({categoryBoundaryName}) is gelukt.", msgs[7]);
+ });
+
+ HydraulicBoundaryLocationOutput output = hydraulicBoundaryLocationCalculation.Output;
+ Assert.AreEqual(calculator.DesignWaterLevel, output.Result, output.Result.GetAccuracy());
+ Assert.AreEqual(CalculationConvergence.CalculatedNotConverged, output.CalculationConvergence);
+ }
+ }
+ }
+
+ mockRepository.VerifyAll();
+ }
+
+ public override void Setup()
+ {
+ mockRepository = new MockRepository();
+ }
+
+ private static TreeNodeInfo GetInfo(RingtoetsPlugin plugin)
+ {
+ return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(DesignWaterLevelCalculationsContext));
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 59a82ae3063f2dda858cc5cf43e25c224856d88d refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/DesignWaterLevelLocationsContextTreeNodeInfoTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/DesignWaterLevelCalculationsViewInfoTest.cs
===================================================================
diff -u -r72ec3a0d168944ed9625ac807af2757ca29cebfc -r59a82ae3063f2dda858cc5cf43e25c224856d88d
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/DesignWaterLevelCalculationsViewInfoTest.cs (.../DesignWaterLevelCalculationsViewInfoTest.cs) (revision 72ec3a0d168944ed9625ac807af2757ca29cebfc)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/DesignWaterLevelCalculationsViewInfoTest.cs (.../DesignWaterLevelCalculationsViewInfoTest.cs) (revision 59a82ae3063f2dda858cc5cf43e25c224856d88d)
@@ -68,7 +68,7 @@
}
[Test]
- public void GetViewName_WithDesignWaterLevelLocationsContext_ReturnsViewNameContainingCategoryBoundaryName()
+ public void GetViewName_WithDesignWaterLevelCalculationsContext_ReturnsViewNameContainingCategoryBoundaryName()
{
// Setup
const string categoryBoundaryName = "Category";