Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/WaveHeightCalculationsContext.cs
===================================================================
diff -u
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/WaveHeightCalculationsContext.cs (revision 0)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/WaveHeightCalculationsContext.cs (revision 466a02f3ba52351117297fcc1ea2d4242ab92b39)
@@ -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 Core.Common.Base;
+using Core.Common.Controls.PresentationObjects;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.Hydraulics;
+
+namespace Ringtoets.Integration.Forms.PresentationObjects
+{
+ ///
+ /// Presentation object for all data required to configure an enumeration of
+ /// with a wave height calculation result.
+ ///
+ public class WaveHeightCalculationsContext : ObservableWrappedObjectContextBase>
+ {
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The calculations that the belongs to.
+ /// The that the belongs to.
+ /// for obtaining the norm to use during calculations.
+ /// The name of the category boundary.
+ /// Thrown when , or
+ /// is null.
+ /// Thrown when is null or empty.
+ public WaveHeightCalculationsContext(ObservableList wrappedData,
+ IAssessmentSection assessmentSection,
+ Func getNormFunc,
+ string categoryBoundaryName)
+ : base(wrappedData)
+ {
+ if (assessmentSection == null)
+ {
+ throw new ArgumentNullException(nameof(assessmentSection));
+ }
+
+ if (getNormFunc == null)
+ {
+ throw new ArgumentNullException(nameof(getNormFunc));
+ }
+
+ if (string.IsNullOrEmpty(categoryBoundaryName))
+ {
+ throw new ArgumentException($"'{nameof(categoryBoundaryName)}' must have a value.");
+ }
+
+ AssessmentSection = assessmentSection;
+ GetNormFunc = getNormFunc;
+ CategoryBoundaryName = categoryBoundaryName;
+ }
+
+ ///
+ /// Gets the assessment section that the context belongs to.
+ ///
+ public IAssessmentSection AssessmentSection { get; }
+
+ ///
+ /// Gets the for obtaining the norm to use during calculations.
+ ///
+ public Func GetNormFunc { get; }
+
+ ///
+ /// Gets the name of the category boundary.
+ ///
+ public string CategoryBoundaryName { get; }
+
+ public override bool Equals(WrappedObjectContextBase> other)
+ {
+ return base.Equals(other)
+ && other is WaveHeightCalculationsContext
+ && CategoryBoundaryName.Equals(((WaveHeightCalculationsContext) other).CategoryBoundaryName);
+ }
+
+ public override bool Equals(object obj)
+ {
+ return Equals(obj as WaveHeightCalculationsContext);
+ }
+
+ public override int GetHashCode()
+ {
+ return base.GetHashCode() ^ CategoryBoundaryName.GetHashCode();
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 466a02f3ba52351117297fcc1ea2d4242ab92b39 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/WaveHeightLocationsContext.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.Designer.cs
===================================================================
diff -u -r59a82ae3063f2dda858cc5cf43e25c224856d88d -r466a02f3ba52351117297fcc1ea2d4242ab92b39
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 59a82ae3063f2dda858cc5cf43e25c224856d88d)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 466a02f3ba52351117297fcc1ea2d4242ab92b39)
@@ -780,9 +780,9 @@
///
/// Looks up a localized string similar to Golfhoogtes.
///
- public static string WaveHeightLocationsContext_DisplayName {
+ public static string WaveHeightCalculationsContext_DisplayName {
get {
- return ResourceManager.GetString("WaveHeightLocationsContext_DisplayName", resourceCulture);
+ return ResourceManager.GetString("WaveHeightCalculationsContext_DisplayName", resourceCulture);
}
}
}
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.resx
===================================================================
diff -u -r59a82ae3063f2dda858cc5cf43e25c224856d88d -r466a02f3ba52351117297fcc1ea2d4242ab92b39
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.resx (.../Resources.resx) (revision 59a82ae3063f2dda858cc5cf43e25c224856d88d)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.resx (.../Resources.resx) (revision 466a02f3ba52351117297fcc1ea2d4242ab92b39)
@@ -240,7 +240,7 @@
Toetspeilen
-
+
Golfhoogtes
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj
===================================================================
diff -u -r72ec3a0d168944ed9625ac807af2757ca29cebfc -r466a02f3ba52351117297fcc1ea2d4242ab92b39
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision 72ec3a0d168944ed9625ac807af2757ca29cebfc)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision 466a02f3ba52351117297fcc1ea2d4242ab92b39)
@@ -35,7 +35,7 @@
-
+
Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs
===================================================================
diff -u -r59a82ae3063f2dda858cc5cf43e25c224856d88d -r466a02f3ba52351117297fcc1ea2d4242ab92b39
--- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 59a82ae3063f2dda858cc5cf43e25c224856d88d)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 466a02f3ba52351117297fcc1ea2d4242ab92b39)
@@ -334,7 +334,7 @@
{
CreateInstance = context => new DesignWaterLevelCalculationProperties(context.WrappedData)
};
- yield return new PropertyInfo
+ yield return new PropertyInfo
{
CreateInstance = context => new WaveHeightCalculationsProperties(context.WrappedData)
};
@@ -408,9 +408,9 @@
AfterCreate = (view, context) => { view.CalculationGuiService = hydraulicBoundaryLocationCalculationGuiService; }
};
- yield return new ViewInfo, WaveHeightCalculationsView>
+ yield return new ViewInfo, WaveHeightCalculationsView>
{
- GetViewName = (view, context) => $"{RingtoetsFormsResources.WaveHeightLocationsContext_DisplayName} - {context.CategoryBoundaryName}",
+ GetViewName = (view, context) => $"{RingtoetsFormsResources.WaveHeightCalculationsContext_DisplayName} - {context.CategoryBoundaryName}",
GetViewData = context => context.WrappedData,
Image = RingtoetsCommonFormsResources.GenericInputOutputIcon,
CloseForData = CloseHydraulicBoundaryCalculationsViewForData,
@@ -775,17 +775,17 @@
yield return new TreeNodeInfo
{
- Text = context => RingtoetsFormsResources.WaveHeightLocationsContext_DisplayName,
+ Text = context => RingtoetsFormsResources.WaveHeightCalculationsContext_DisplayName,
Image = context => RingtoetsCommonFormsResources.GeneralFolderIcon,
ContextMenuStrip = WaveHeightLocationsGroupContextMenuStrip,
ChildNodeObjects = WaveHeightLocationsGroupContextChildNodeObjects
};
- yield return new TreeNodeInfo
+ yield return new TreeNodeInfo
{
Text = context => context.CategoryBoundaryName,
Image = context => RingtoetsCommonFormsResources.GenericInputOutputIcon,
- ContextMenuStrip = WaveHeightLocationsContextMenuStrip
+ ContextMenuStrip = WaveHeightCalculationsContextMenuStrip
};
yield return new TreeNodeInfo
@@ -1768,7 +1768,7 @@
.Build();
}
- private ContextMenuStrip WaveHeightLocationsContextMenuStrip(WaveHeightLocationsContext nodeData, object parentData, TreeViewControl treeViewControl)
+ private ContextMenuStrip WaveHeightCalculationsContextMenuStrip(WaveHeightCalculationsContext nodeData, object parentData, TreeViewControl treeViewControl)
{
var waveHeightItem = new StrictContextMenuItem(
RingtoetsFormsResources.WaveHeight_Calculate_All,
@@ -1985,22 +1985,22 @@
{
return new object[]
{
- new WaveHeightLocationsContext(GetHydraulicBoundaryLocationCalculations(context.WrappedData, hbl => hbl.WaveHeightCalculation1),
- context.AssessmentSection,
- () => GetFirstHydraulicBoundaryNorm(context.AssessmentSection),
- RingtoetsIntegrationPluginResources.Hydraulic_category_boundary_name_1),
- new WaveHeightLocationsContext(GetHydraulicBoundaryLocationCalculations(context.WrappedData, hbl => hbl.WaveHeightCalculation2),
- context.AssessmentSection,
- () => GetSecondHydraulicBoundaryNorm(context.AssessmentSection),
- RingtoetsIntegrationPluginResources.Hydraulic_category_boundary_name_2),
- new WaveHeightLocationsContext(GetHydraulicBoundaryLocationCalculations(context.WrappedData, hbl => hbl.WaveHeightCalculation3),
- context.AssessmentSection,
- () => GetThirdHydraulicBoundaryNorm(context.AssessmentSection),
- RingtoetsIntegrationPluginResources.Hydraulic_category_boundary_name_3),
- new WaveHeightLocationsContext(GetHydraulicBoundaryLocationCalculations(context.WrappedData, hbl => hbl.WaveHeightCalculation4),
- context.AssessmentSection,
- () => GetFourthHydraulicBoundaryNorm(context.AssessmentSection),
- RingtoetsIntegrationPluginResources.Hydraulic_category_boundary_name_4)
+ new WaveHeightCalculationsContext(GetHydraulicBoundaryLocationCalculations(context.WrappedData, hbl => hbl.WaveHeightCalculation1),
+ context.AssessmentSection,
+ () => GetFirstHydraulicBoundaryNorm(context.AssessmentSection),
+ RingtoetsIntegrationPluginResources.Hydraulic_category_boundary_name_1),
+ new WaveHeightCalculationsContext(GetHydraulicBoundaryLocationCalculations(context.WrappedData, hbl => hbl.WaveHeightCalculation2),
+ context.AssessmentSection,
+ () => GetSecondHydraulicBoundaryNorm(context.AssessmentSection),
+ RingtoetsIntegrationPluginResources.Hydraulic_category_boundary_name_2),
+ new WaveHeightCalculationsContext(GetHydraulicBoundaryLocationCalculations(context.WrappedData, hbl => hbl.WaveHeightCalculation3),
+ context.AssessmentSection,
+ () => GetThirdHydraulicBoundaryNorm(context.AssessmentSection),
+ RingtoetsIntegrationPluginResources.Hydraulic_category_boundary_name_3),
+ new WaveHeightCalculationsContext(GetHydraulicBoundaryLocationCalculations(context.WrappedData, hbl => hbl.WaveHeightCalculation4),
+ context.AssessmentSection,
+ () => GetFourthHydraulicBoundaryNorm(context.AssessmentSection),
+ RingtoetsIntegrationPluginResources.Hydraulic_category_boundary_name_4)
};
}
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/WaveHeightCalculationsContextTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/WaveHeightCalculationsContextTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/WaveHeightCalculationsContextTest.cs (revision 466a02f3ba52351117297fcc1ea2d4242ab92b39)
@@ -0,0 +1,196 @@
+// 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.Collections.Generic;
+using Core.Common.Base;
+using Core.Common.Controls.PresentationObjects;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Integration.Forms.PresentationObjects;
+
+namespace Ringtoets.Integration.Forms.Test.PresentationObjects
+{
+ [TestFixture]
+ public class WaveHeightCalculationsContextTest
+ {
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Setup
+ var mockRepository = new MockRepository();
+ var assessmentSection = mockRepository.Stub();
+ mockRepository.ReplayAll();
+
+ var calculations = new ObservableList();
+ Func getNormFunc = () => 0.01;
+ const string categoryBoundaryName = "Test name";
+
+ // Call
+ var presentationObject = new WaveHeightCalculationsContext(calculations,
+ assessmentSection,
+ getNormFunc,
+ categoryBoundaryName);
+
+ // Assert
+ Assert.IsInstanceOf>>(presentationObject);
+ Assert.AreSame(calculations, presentationObject.WrappedData);
+ Assert.AreSame(assessmentSection, presentationObject.AssessmentSection);
+ Assert.AreSame(getNormFunc, presentationObject.GetNormFunc);
+ Assert.AreEqual(categoryBoundaryName, presentationObject.CategoryBoundaryName);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void Constructor_AssessmentSectionNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => new WaveHeightCalculationsContext(new ObservableList(),
+ null,
+ () => 0.01,
+ "Test name");
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("assessmentSection", exception.ParamName);
+ }
+
+ [Test]
+ public void Constructor_GetNormFuncNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mockRepository = new MockRepository();
+ var assessmentSection = mockRepository.Stub();
+ mockRepository.ReplayAll();
+
+ // Call
+ TestDelegate call = () => new WaveHeightCalculationsContext(new ObservableList(),
+ assessmentSection,
+ null,
+ "Test name");
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("getNormFunc", exception.ParamName);
+ }
+
+ [Test]
+ public void Constructor_CategoryBoundaryNameNull_ThrowsArgumentException()
+ {
+ // Setup
+ var mockRepository = new MockRepository();
+ var assessmentSection = mockRepository.Stub();
+ mockRepository.ReplayAll();
+
+ // Call
+ TestDelegate call = () => new WaveHeightCalculationsContext(new ObservableList(),
+ assessmentSection,
+ () => 0.01,
+ null);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("'categoryBoundaryName' must have a value.", exception.Message);
+ }
+
+ [Test]
+ public void Constructor_CategoryBoundaryNameEmpty_ThrowsArgumentException()
+ {
+ // Setup
+ var mockRepository = new MockRepository();
+ var assessmentSection = mockRepository.Stub();
+ mockRepository.ReplayAll();
+
+ // Call
+ TestDelegate call = () => new WaveHeightCalculationsContext(new ObservableList(),
+ assessmentSection,
+ () => 0.01,
+ string.Empty);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("'categoryBoundaryName' must have a value.", exception.Message);
+ }
+
+ [TestFixture]
+ private class WaveHeightCalculationsContextEqualsTest
+ : EqualsTestFixture
+ {
+ private static readonly MockRepository mocks = new MockRepository();
+ private static readonly IAssessmentSection assessmentSection = mocks.Stub();
+ private static readonly Func getNormFunc = () => 0.01;
+ private static readonly ObservableList hydraulicBoundaryLocationCalculations = new ObservableList();
+ private static readonly string categoryBoundaryName = "Test name";
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks.ReplayAll();
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ mocks.VerifyAll();
+ }
+
+ protected override WaveHeightCalculationsContext CreateObject()
+ {
+ return new WaveHeightCalculationsContext(hydraulicBoundaryLocationCalculations,
+ assessmentSection,
+ getNormFunc,
+ categoryBoundaryName);
+ }
+
+ protected override DerivedWaveHeightCalculationsContext CreateDerivedObject()
+ {
+ return new DerivedWaveHeightCalculationsContext(hydraulicBoundaryLocationCalculations,
+ assessmentSection,
+ getNormFunc,
+ categoryBoundaryName);
+ }
+
+ private static IEnumerable GetUnequalTestCases()
+ {
+ yield return new TestCaseData(new WaveHeightCalculationsContext(hydraulicBoundaryLocationCalculations,
+ assessmentSection,
+ getNormFunc,
+ "Other"))
+ .SetName("CategoryBoundaryName");
+ }
+ }
+
+ private class DerivedWaveHeightCalculationsContext : WaveHeightCalculationsContext
+ {
+ public DerivedWaveHeightCalculationsContext(ObservableList wrappedData,
+ IAssessmentSection assessmentSection,
+ Func getNormFunc,
+ string categoryBoundaryName)
+ : base(wrappedData,
+ assessmentSection,
+ getNormFunc,
+ categoryBoundaryName) {}
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 466a02f3ba52351117297fcc1ea2d4242ab92b39 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/WaveHeightLocationsContextTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj
===================================================================
diff -u -r72ec3a0d168944ed9625ac807af2757ca29cebfc -r466a02f3ba52351117297fcc1ea2d4242ab92b39
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 72ec3a0d168944ed9625ac807af2757ca29cebfc)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 466a02f3ba52351117297fcc1ea2d4242ab92b39)
@@ -51,7 +51,7 @@
-
+
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/WaveHeightCalculationsContextPropertyInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/WaveHeightCalculationsContextPropertyInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/WaveHeightCalculationsContextPropertyInfoTest.cs (revision 466a02f3ba52351117297fcc1ea2d4242ab92b39)
@@ -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 WaveHeightCalculationsContextPropertyInfoTest
+ {
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ using (var plugin = new RingtoetsPlugin())
+ {
+ // Call
+ PropertyInfo info = GetInfo(plugin);
+
+ // Assert
+ Assert.AreEqual(typeof(WaveHeightCalculationsContext), info.DataType);
+ Assert.AreEqual(typeof(WaveHeightCalculationsProperties), 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 WaveHeightCalculationsContext(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);
+ WaveHeightCalculationProperties[] calculationProperties = ((WaveHeightCalculationsProperties) 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(WaveHeightCalculationsContext));
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 466a02f3ba52351117297fcc1ea2d4242ab92b39 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/WaveHeightLocationsContextPropertyInfoTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj
===================================================================
diff -u -r59a82ae3063f2dda858cc5cf43e25c224856d88d -r466a02f3ba52351117297fcc1ea2d4242ab92b39
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision 59a82ae3063f2dda858cc5cf43e25c224856d88d)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision 466a02f3ba52351117297fcc1ea2d4242ab92b39)
@@ -63,7 +63,7 @@
-
+
@@ -93,7 +93,7 @@
-
+
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs
===================================================================
diff -u -r72ec3a0d168944ed9625ac807af2757ca29cebfc -r466a02f3ba52351117297fcc1ea2d4242ab92b39
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs (.../RingtoetsPluginTest.cs) (revision 72ec3a0d168944ed9625ac807af2757ca29cebfc)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs (.../RingtoetsPluginTest.cs) (revision 466a02f3ba52351117297fcc1ea2d4242ab92b39)
@@ -287,7 +287,7 @@
PluginTestHelper.AssertPropertyInfoDefined(
propertyInfos,
- typeof(WaveHeightLocationsContext),
+ typeof(WaveHeightCalculationsContext),
typeof(WaveHeightCalculationsProperties));
PluginTestHelper.AssertPropertyInfoDefined(
@@ -379,7 +379,7 @@
PluginTestHelper.AssertViewInfoDefined(
viewInfos,
- typeof(WaveHeightLocationsContext),
+ typeof(WaveHeightCalculationsContext),
typeof(IEnumerable),
typeof(WaveHeightCalculationsView));
@@ -489,7 +489,7 @@
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HydraulicBoundaryDatabaseContext)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(DesignWaterLevelCalculationsContext)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(DesignWaterLevelLocationsGroupContext)));
- Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(WaveHeightLocationsContext)));
+ Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(WaveHeightCalculationsContext)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(WaveHeightLocationsGroupContext)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(ForeshoreProfilesContext)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(DikeProfile)));
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/WaveHeightCalculationsContextTreeNodeInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/WaveHeightCalculationsContextTreeNodeInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/WaveHeightCalculationsContextTreeNodeInfoTest.cs (revision 466a02f3ba52351117297fcc1ea2d4242ab92b39)
@@ -0,0 +1,622 @@
+// 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 WaveHeightCalculationsContextTreeNodeInfoTest : NUnitFormTest
+ {
+ private const int contextMenuRunWaveHeightCalculationsIndex = 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 WaveHeightCalculationsContext(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 WaveHeightCalculationsContext(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 WaveHeightCalculationsContext(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[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 WaveHeightCalculationsContext(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[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);
+ }
+ }
+ }
+
+ mockRepository.VerifyAll(); // Expect no calls on arguments
+ }
+
+ [Test]
+ public void ContextMenuStrip_AllRequiredInputSet_ContextMenuItemCalculateAllEnabled()
+ {
+ // Setup
+ var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase
+ {
+ 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 WaveHeightCalculationsContext(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 golfhoogtes berekenen.";
+
+ TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuRunWaveHeightCalculationsIndex,
+ expectedItemText, expectedItemTooltip, RingtoetsCommonFormsResources.CalculateAllIcon);
+ }
+ }
+ }
+
+ mockRepository.VerifyAll(); // Expect no calls on arguments
+ }
+
+ [Test]
+ [Apartment(ApartmentState.STA)]
+ public void CalculateWaveHeightsFromContextMenu_HydraulicBoundaryDatabaseWithCanUsePreprocessorFalse_SendsRightInputToCalculationService()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ HydraulicBoundaryDatabase =
+ {
+ FilePath = Path.Combine(testDataPath, "HRD ijsselmeer.sqlite")
+ }
+ };
+
+ Func getNormFunc = () => 0.01;
+
+ var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation("locationName");
+ var hydraulicBoundaryLocationCalculations = new ObservableList
+ {
+ new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation)
+ };
+
+ var context = new WaveHeightCalculationsContext(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 waveHeightCalculator = new TestWaveHeightCalculator();
+ var calculatorFactory = mockRepository.Stub();
+ calculatorFactory.Expect(cf => cf.CreateWaveHeightCalculator(testDataPath, string.Empty)).Return(waveHeightCalculator);
+ 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[contextMenuRunWaveHeightCalculationsIndex].PerformClick();
+
+ // Assert
+ WaveHeightCalculationInput waveHeightCalculationInput = waveHeightCalculator.ReceivedInputs.First();
+
+ Assert.AreEqual(hydraulicBoundaryLocation.Id, waveHeightCalculationInput.HydraulicBoundaryLocationId);
+ Assert.AreEqual(StatisticsConverter.ProbabilityToReliability(getNormFunc()), waveHeightCalculationInput.Beta);
+ }
+ }
+ }
+
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ [Apartment(ApartmentState.STA)]
+ public void CalculateWaveHeightsFromContextMenu_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 WaveHeightCalculationsContext(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 waveHeightCalculator = new TestWaveHeightCalculator();
+ var calculatorFactory = mockRepository.Stub();
+ calculatorFactory.Expect(cf => cf.CreateWaveHeightCalculator(testDataPath, preprocessorDirectory)).Return(waveHeightCalculator);
+ 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[contextMenuRunWaveHeightCalculationsIndex].PerformClick();
+
+ // Assert
+ WaveHeightCalculationInput waveHeightCalculationInput = waveHeightCalculator.ReceivedInputs.First();
+
+ Assert.AreEqual(hydraulicBoundaryLocation.Id, waveHeightCalculationInput.HydraulicBoundaryLocationId);
+ Assert.AreEqual(StatisticsConverter.ProbabilityToReliability(getNormFunc()), waveHeightCalculationInput.Beta);
+ }
+ }
+ }
+
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ [Apartment(ApartmentState.STA)]
+ public void CalculateWaveHeightsFromContextMenu_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 WaveHeightCalculationsContext(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 waveHeightCalculator = new TestWaveHeightCalculator();
+ var calculatorFactory = mockRepository.Stub();
+ calculatorFactory.Expect(cf => cf.CreateWaveHeightCalculator(testDataPath, string.Empty)).Return(waveHeightCalculator);
+ 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[contextMenuRunWaveHeightCalculationsIndex].PerformClick();
+
+ // Assert
+ WaveHeightCalculationInput waveHeightCalculationInput = waveHeightCalculator.ReceivedInputs.First();
+
+ Assert.AreEqual(hydraulicBoundaryLocation.Id, waveHeightCalculationInput.HydraulicBoundaryLocationId);
+ Assert.AreEqual(StatisticsConverter.ProbabilityToReliability(getNormFunc()), waveHeightCalculationInput.Beta);
+ }
+ }
+ }
+
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ [Apartment(ApartmentState.STA)]
+ public void GivenHydraulicBoundaryLocationThatSucceeds_CalculatingWaveHeightFromContextMenu_ThenLogMessagesAddedPreviousOutputAffected()
+ {
+ // Given
+ const string locationName = "locationName";
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ HydraulicBoundaryDatabase =
+ {
+ FilePath = Path.Combine(testDataPath, "HRD ijsselmeer.sqlite")
+ },
+ Id = string.Empty
+ };
+
+ const string categoryBoundaryName = "Category";
+
+ var hydraulicBoundaryLocationCalculation = new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation("locationName"));
+ var hydraulicBoundaryLocationCalculations = new ObservableList
+ {
+ hydraulicBoundaryLocationCalculation
+ };
+
+ var context = new WaveHeightCalculationsContext(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 TestWaveHeightCalculator
+ {
+ Converged = false
+ };
+ var calculatorFactory = mockRepository.Stub();
+ calculatorFactory.Expect(cf => cf.CreateWaveHeightCalculator(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 action = () => contextMenuAdapter.Items[contextMenuRunWaveHeightCalculationsIndex].PerformClick();
+
+ // Then
+ TestHelper.AssertLogMessages(action, messages =>
+ {
+ string[] msgs = messages.ToArray();
+ Assert.AreEqual(8, msgs.Length);
+ Assert.AreEqual($"Golfhoogte berekenen voor locatie '{locationName}' ({categoryBoundaryName}) is gestart.", msgs[0]);
+ CalculationServiceTestHelper.AssertValidationStartMessage(msgs[1]);
+ CalculationServiceTestHelper.AssertValidationEndMessage(msgs[2]);
+ CalculationServiceTestHelper.AssertCalculationStartMessage(msgs[3]);
+ Assert.AreEqual($"Golfhoogte berekening voor locatie '{locationName}' ({categoryBoundaryName}) is niet geconvergeerd.", msgs[4]);
+ StringAssert.StartsWith("Golfhoogte berekening is uitgevoerd op de tijdelijke locatie", msgs[5]);
+ CalculationServiceTestHelper.AssertCalculationEndMessage(msgs[6]);
+ Assert.AreEqual($"Golfhoogte berekenen voor locatie '{locationName}' ({categoryBoundaryName}) is gelukt.", msgs[7]);
+ });
+
+ HydraulicBoundaryLocationOutput output = hydraulicBoundaryLocationCalculation.Output;
+ Assert.AreEqual(calculator.WaveHeight, output.Result, output.Result.GetAccuracy());
+ Assert.AreEqual(CalculationConvergence.CalculatedNotConverged, hydraulicBoundaryLocationCalculation.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(WaveHeightCalculationsContext));
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 466a02f3ba52351117297fcc1ea2d4242ab92b39 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/WaveHeightLocationsContextTreeNodeInfoTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/WaveHeightLocationsGroupContextTreeNodeInfoTest.cs
===================================================================
diff -u -r225ee2a212b464c8bfe5517ad9737f4e0582ccbe -r466a02f3ba52351117297fcc1ea2d4242ab92b39
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/WaveHeightLocationsGroupContextTreeNodeInfoTest.cs (.../WaveHeightLocationsGroupContextTreeNodeInfoTest.cs) (revision 225ee2a212b464c8bfe5517ad9737f4e0582ccbe)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/WaveHeightLocationsGroupContextTreeNodeInfoTest.cs (.../WaveHeightLocationsGroupContextTreeNodeInfoTest.cs) (revision 466a02f3ba52351117297fcc1ea2d4242ab92b39)
@@ -177,26 +177,26 @@
// Assert
Assert.AreEqual(4, childNodeObjects.Length);
- WaveHeightLocationsContext[] locationsContexts = childNodeObjects.OfType().ToArray();
- Assert.AreEqual(4, locationsContexts.Length);
+ WaveHeightCalculationsContext[] calculationsContexts = childNodeObjects.OfType().ToArray();
+ Assert.AreEqual(4, calculationsContexts.Length);
- Assert.IsTrue(locationsContexts.All(c => ReferenceEquals(assessmentSection, c.AssessmentSection)));
+ Assert.IsTrue(calculationsContexts.All(c => ReferenceEquals(assessmentSection, c.AssessmentSection)));
- Assert.AreEqual("Categorie A+->A", locationsContexts[0].CategoryBoundaryName);
- CollectionAssert.AreEqual(locations.Select(loc => loc.WaveHeightCalculation1), locationsContexts[0].WrappedData);
- Assert.AreEqual(signalingNorm / 30, locationsContexts[0].GetNormFunc());
+ Assert.AreEqual("Categorie A+->A", calculationsContexts[0].CategoryBoundaryName);
+ CollectionAssert.AreEqual(locations.Select(loc => loc.WaveHeightCalculation1), calculationsContexts[0].WrappedData);
+ Assert.AreEqual(signalingNorm / 30, calculationsContexts[0].GetNormFunc());
- Assert.AreEqual("Categorie A->B", locationsContexts[1].CategoryBoundaryName);
- CollectionAssert.AreEqual(locations.Select(loc => loc.WaveHeightCalculation2), locationsContexts[1].WrappedData);
- Assert.AreEqual(signalingNorm, locationsContexts[1].GetNormFunc());
+ Assert.AreEqual("Categorie A->B", calculationsContexts[1].CategoryBoundaryName);
+ CollectionAssert.AreEqual(locations.Select(loc => loc.WaveHeightCalculation2), calculationsContexts[1].WrappedData);
+ Assert.AreEqual(signalingNorm, calculationsContexts[1].GetNormFunc());
- Assert.AreEqual("Categorie B->C", locationsContexts[2].CategoryBoundaryName);
- CollectionAssert.AreEqual(locations.Select(loc => loc.WaveHeightCalculation3), locationsContexts[2].WrappedData);
- Assert.AreEqual(lowerLimitNorm, locationsContexts[2].GetNormFunc());
+ Assert.AreEqual("Categorie B->C", calculationsContexts[2].CategoryBoundaryName);
+ CollectionAssert.AreEqual(locations.Select(loc => loc.WaveHeightCalculation3), calculationsContexts[2].WrappedData);
+ Assert.AreEqual(lowerLimitNorm, calculationsContexts[2].GetNormFunc());
- Assert.AreEqual("Categorie C->D", locationsContexts[3].CategoryBoundaryName);
- CollectionAssert.AreEqual(locations.Select(loc => loc.WaveHeightCalculation4), locationsContexts[3].WrappedData);
- Assert.AreEqual(lowerLimitNorm * 30, locationsContexts[3].GetNormFunc());
+ Assert.AreEqual("Categorie C->D", calculationsContexts[3].CategoryBoundaryName);
+ CollectionAssert.AreEqual(locations.Select(loc => loc.WaveHeightCalculation4), calculationsContexts[3].WrappedData);
+ Assert.AreEqual(lowerLimitNorm * 30, calculationsContexts[3].GetNormFunc());
}
mocks.VerifyAll();
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveHeightCalculationsViewInfoTest.cs
===================================================================
diff -u -rf9302ac7b9aaba301867d26c87c226da5b46572e -r466a02f3ba52351117297fcc1ea2d4242ab92b39
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveHeightCalculationsViewInfoTest.cs (.../WaveHeightCalculationsViewInfoTest.cs) (revision f9302ac7b9aaba301867d26c87c226da5b46572e)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveHeightCalculationsViewInfoTest.cs (.../WaveHeightCalculationsViewInfoTest.cs) (revision 466a02f3ba52351117297fcc1ea2d4242ab92b39)
@@ -68,15 +68,15 @@
}
[Test]
- public void GetViewName_WithWaveHeightLocationsContext_ReturnsViewNameContainingCategoryBoundaryName()
+ public void GetViewName_WithWaveHeightCalculationsContext_ReturnsViewNameContainingCategoryBoundaryName()
{
// Setup
const string categoryBoundaryName = "Category";
- var context = new WaveHeightLocationsContext(new ObservableList(),
- new ObservableTestAssessmentSectionStub(),
- () => 0.01,
- categoryBoundaryName);
+ var context = new WaveHeightCalculationsContext(new ObservableList(),
+ new ObservableTestAssessmentSectionStub(),
+ () => 0.01,
+ categoryBoundaryName);
// Call
string viewName = info.GetViewName(null, context);
@@ -102,7 +102,7 @@
Type dataType = info.DataType;
// Assert
- Assert.AreEqual(typeof(WaveHeightLocationsContext), dataType);
+ Assert.AreEqual(typeof(WaveHeightCalculationsContext), dataType);
}
[Test]
@@ -122,10 +122,10 @@
var assessmentSection = new ObservableTestAssessmentSectionStub();
var calculations = new ObservableList();
- var context = new WaveHeightLocationsContext(calculations,
- assessmentSection,
- () => 0.01,
- "Category");
+ var context = new WaveHeightCalculationsContext(calculations,
+ assessmentSection,
+ () => 0.01,
+ "Category");
// Call
object viewData = info.GetViewData(context);
@@ -139,10 +139,10 @@
{
// Setup
var assessmentSection = new ObservableTestAssessmentSectionStub();
- var context = new WaveHeightLocationsContext(new ObservableList(),
- assessmentSection,
- () => 0.01,
- "Category");
+ var context = new WaveHeightCalculationsContext(new ObservableList(),
+ assessmentSection,
+ () => 0.01,
+ "Category");
// Call
var view = (WaveHeightCalculationsView) info.CreateInstance(context);
@@ -169,10 +169,10 @@
}
};
- var context = new WaveHeightLocationsContext(hydraulicBoundaryLocationCalculations,
- new ObservableTestAssessmentSectionStub(),
- () => 0.01,
- "Category");
+ var context = new WaveHeightCalculationsContext(hydraulicBoundaryLocationCalculations,
+ new ObservableTestAssessmentSectionStub(),
+ () => 0.01,
+ "Category");
// Call
var view = (WaveHeightCalculationsView) info.CreateInstance(context);
@@ -203,10 +203,10 @@
hydraulicBoundaryLocationCalculation
};
- var context = new WaveHeightLocationsContext(hydraulicBoundaryLocationCalculations,
- new ObservableTestAssessmentSectionStub(),
- getNormFunc,
- "Category");
+ var context = new WaveHeightCalculationsContext(hydraulicBoundaryLocationCalculations,
+ new ObservableTestAssessmentSectionStub(),
+ getNormFunc,
+ "Category");
var mockRepository = new MockRepository();
var guiService = mockRepository.StrictMock();
@@ -269,10 +269,10 @@
const string categoryBoundaryName = "Category";
- var context = new WaveHeightLocationsContext(calculations,
- assessmentSection,
- getNormFunc,
- categoryBoundaryName);
+ var context = new WaveHeightCalculationsContext(calculations,
+ assessmentSection,
+ getNormFunc,
+ categoryBoundaryName);
using (var view = new WaveHeightCalculationsView(new ObservableList(),
assessmentSection,