Index: Riskeer/StabilityStoneCover/src/Riskeer.StabilityStoneCover.Forms/PresentationObjects/StabilityStoneCoverCalculationGroupContext.cs
===================================================================
diff -u
--- Riskeer/StabilityStoneCover/src/Riskeer.StabilityStoneCover.Forms/PresentationObjects/StabilityStoneCoverCalculationGroupContext.cs (revision 0)
+++ Riskeer/StabilityStoneCover/src/Riskeer.StabilityStoneCover.Forms/PresentationObjects/StabilityStoneCoverCalculationGroupContext.cs (revision 55786df7f5abe3fbda43470b70929ed7aeaee54f)
@@ -0,0 +1,74 @@
+// Copyright (C) Stichting Deltares 2021. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer 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.Controls.PresentationObjects;
+using Riskeer.Common.Data.AssessmentSection;
+using Riskeer.Common.Data.Calculation;
+using Riskeer.Common.Forms.PresentationObjects;
+using Riskeer.StabilityStoneCover.Data;
+
+namespace Riskeer.StabilityStoneCover.Forms.PresentationObjects
+{
+ ///
+ /// Presentation object for all data required to configure an instance of
+ /// in order be able to create configurable stability stone cover calculations.
+ ///
+ public class StabilityStoneCoverCalculationGroupContext : StabilityStoneCoverContext,
+ ICalculationContext
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The wrapped .
+ /// The that owns the wrapped calculation group.
+ /// The failure mechanism the calculation group belongs to.
+ /// The assessment section the calculation group belongs to.
+ /// Thrown when any input argument is null , except for .
+ public StabilityStoneCoverCalculationGroupContext(CalculationGroup calculationGroup,
+ CalculationGroup parent,
+ StabilityStoneCoverFailureMechanism failureMechanism,
+ IAssessmentSection assessmentSection)
+ : base(calculationGroup, failureMechanism, assessmentSection)
+ {
+ Parent = parent;
+ }
+
+ public CalculationGroup Parent { get; }
+
+ public override bool Equals(WrappedObjectContextBase other)
+ {
+ return base.Equals(other)
+ && other is StabilityStoneCoverCalculationGroupContext
+ && ReferenceEquals(Parent, ((StabilityStoneCoverCalculationGroupContext) other).Parent);
+ }
+
+ public override bool Equals(object obj)
+ {
+ return Equals(obj as StabilityStoneCoverCalculationGroupContext);
+ }
+
+ public override int GetHashCode()
+ {
+ return base.GetHashCode() ^ Parent?.GetHashCode() ?? 0;
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 55786df7f5abe3fbda43470b70929ed7aeaee54f refers to a dead (removed) revision in file `Riskeer/StabilityStoneCover/src/Riskeer.StabilityStoneCover.Forms/PresentationObjects/StabilityStoneCoverWaveConditionsCalculationGroupContext.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Riskeer/StabilityStoneCover/src/Riskeer.StabilityStoneCover.Plugin/StabilityStoneCoverPlugin.cs
===================================================================
diff -u -rce73d815b0583615c74550ba004fd553202b43fe -r55786df7f5abe3fbda43470b70929ed7aeaee54f
--- Riskeer/StabilityStoneCover/src/Riskeer.StabilityStoneCover.Plugin/StabilityStoneCoverPlugin.cs (.../StabilityStoneCoverPlugin.cs) (revision ce73d815b0583615c74550ba004fd553202b43fe)
+++ Riskeer/StabilityStoneCover/src/Riskeer.StabilityStoneCover.Plugin/StabilityStoneCoverPlugin.cs (.../StabilityStoneCoverPlugin.cs) (revision 55786df7f5abe3fbda43470b70929ed7aeaee54f)
@@ -154,10 +154,10 @@
FailurePathEnabledContextMenuStrip,
FailurePathDisabledContextMenuStrip);
- yield return RiskeerTreeNodeInfoFactory.CreateCalculationGroupContextTreeNodeInfo(
- WaveConditionsCalculationGroupContextChildNodeObjects,
- WaveConditionsCalculationGroupContextContextMenuStrip,
- WaveConditionsCalculationGroupContextOnNodeRemoved);
+ yield return RiskeerTreeNodeInfoFactory.CreateCalculationGroupContextTreeNodeInfo(
+ CalculationGroupContextChildNodeObjects,
+ CalculationGroupContextContextMenuStrip,
+ CalculationGroupContextOnNodeRemoved);
yield return RiskeerTreeNodeInfoFactory.CreateCalculationContextTreeNodeInfo(
WaveConditionsCalculationContextChildNodeObjects,
@@ -207,7 +207,7 @@
public override IEnumerable GetImportInfos()
{
- yield return RiskeerImportInfoFactory.CreateCalculationConfigurationImportInfo(
+ yield return RiskeerImportInfoFactory.CreateCalculationConfigurationImportInfo(
(context, filePath) =>
new StabilityStoneCoverWaveConditionsCalculationConfigurationImporter(
filePath,
@@ -220,7 +220,7 @@
public override IEnumerable GetExportInfos()
{
- yield return new ExportInfo
+ yield return new ExportInfo
{
Name = context => RiskeerCommonFormsResources.WaveConditionsExporter_DisplayName,
Extension = RiskeerCommonFormsResources.DataTypeDisplayName_csv_file_filter_Extension,
@@ -247,7 +247,7 @@
GetExportPath = () => ExportHelper.GetFilePath(GetInquiryHelper(), GetWaveConditionsFileFilterGenerator())
};
- yield return RiskeerExportInfoFactory.CreateCalculationGroupConfigurationExportInfo(
+ yield return RiskeerExportInfoFactory.CreateCalculationGroupConfigurationExportInfo(
(context, filePath) => new StabilityStoneCoverWaveConditionsCalculationConfigurationExporter(
context.WrappedData.Children, filePath, context.AssessmentSection),
context => context.WrappedData.Children.Any(),
@@ -321,8 +321,8 @@
{
new CategoryTreeFolder(RiskeerCommonFormsResources.FailureMechanism_Inputs_DisplayName,
GetHydraulicLoadsInputs(failureMechanism, assessmentSection), TreeFolderCategory.Input),
- new StabilityStoneCoverWaveConditionsCalculationGroupContext(failureMechanism.CalculationsGroup, null,
- failureMechanism, assessmentSection)
+ new StabilityStoneCoverCalculationGroupContext(failureMechanism.CalculationsGroup, null,
+ failureMechanism, assessmentSection)
};
}
@@ -451,9 +451,9 @@
#endregion
- #region StabilityStoneCoverWaveConditionsCalculationGroupContext TreeNodeInfo
+ #region StabilityStoneCoverCalculationGroupContext TreeNodeInfo
- private static object[] WaveConditionsCalculationGroupContextChildNodeObjects(StabilityStoneCoverWaveConditionsCalculationGroupContext nodeData)
+ private static object[] CalculationGroupContextChildNodeObjects(StabilityStoneCoverCalculationGroupContext nodeData)
{
var childNodeObjects = new List();
@@ -468,10 +468,10 @@
}
else if (item is CalculationGroup group)
{
- childNodeObjects.Add(new StabilityStoneCoverWaveConditionsCalculationGroupContext(group,
- nodeData.WrappedData,
- nodeData.FailureMechanism,
- nodeData.AssessmentSection));
+ childNodeObjects.Add(new StabilityStoneCoverCalculationGroupContext(group,
+ nodeData.WrappedData,
+ nodeData.FailureMechanism,
+ nodeData.AssessmentSection));
}
else
{
@@ -482,15 +482,15 @@
return childNodeObjects.ToArray();
}
- private ContextMenuStrip WaveConditionsCalculationGroupContextContextMenuStrip(StabilityStoneCoverWaveConditionsCalculationGroupContext nodeData,
- object parentData,
- TreeViewControl treeViewControl)
+ private ContextMenuStrip CalculationGroupContextContextMenuStrip(StabilityStoneCoverCalculationGroupContext nodeData,
+ object parentData,
+ TreeViewControl treeViewControl)
{
CalculationGroup group = nodeData.WrappedData;
IInquiryHelper inquiryHelper = GetInquiryHelper();
var builder = new RiskeerContextMenuBuilder(Gui.Get(nodeData, treeViewControl));
- bool isNestedGroup = parentData is StabilityStoneCoverWaveConditionsCalculationGroupContext;
+ bool isNestedGroup = parentData is StabilityStoneCoverCalculationGroupContext;
StabilityStoneCoverWaveConditionsCalculation[] calculations = group
.GetCalculations()
@@ -550,24 +550,24 @@
.Build();
}
- private StrictContextMenuItem CreateGenerateWaveConditionsCalculationsItem(StabilityStoneCoverWaveConditionsCalculationGroupContext nodeData)
+ private StrictContextMenuItem CreateGenerateWaveConditionsCalculationsItem(StabilityStoneCoverCalculationGroupContext nodeData)
{
bool locationsAvailable = nodeData.AssessmentSection.HydraulicBoundaryDatabase.Locations.Any();
- string stabilityStoneCoverWaveConditionsCalculationGroupContextToolTip = locationsAvailable
- ? RiskeerCommonFormsResources.CalculationGroup_CreateGenerateHydraulicBoundaryCalculationsItem_ToolTip
- : RiskeerCommonFormsResources.CalculationGroup_No_HydraulicBoundaryDatabase_To_Generate_ToolTip;
+ string calculationGroupContextToolTip = locationsAvailable
+ ? RiskeerCommonFormsResources.CalculationGroup_CreateGenerateHydraulicBoundaryCalculationsItem_ToolTip
+ : RiskeerCommonFormsResources.CalculationGroup_No_HydraulicBoundaryDatabase_To_Generate_ToolTip;
return new StrictContextMenuItem(RiskeerCommonFormsResources.CalculationGroup_Generate_calculations,
- stabilityStoneCoverWaveConditionsCalculationGroupContextToolTip,
+ calculationGroupContextToolTip,
RiskeerCommonFormsResources.GenerateScenariosIcon,
(sender, args) => ShowHydraulicBoundaryLocationSelectionDialog(nodeData))
{
Enabled = locationsAvailable
};
}
- private void ShowHydraulicBoundaryLocationSelectionDialog(StabilityStoneCoverWaveConditionsCalculationGroupContext nodeData)
+ private void ShowHydraulicBoundaryLocationSelectionDialog(StabilityStoneCoverCalculationGroupContext nodeData)
{
using (var dialog = new HydraulicBoundaryLocationSelectionDialog(Gui.MainWindow, nodeData.AssessmentSection.HydraulicBoundaryDatabase.Locations))
{
@@ -593,7 +593,7 @@
normType);
}
- private static void AddWaveConditionsCalculation(StabilityStoneCoverWaveConditionsCalculationGroupContext nodeData)
+ private static void AddWaveConditionsCalculation(StabilityStoneCoverCalculationGroupContext nodeData)
{
var calculation = new StabilityStoneCoverWaveConditionsCalculation
{
@@ -608,21 +608,21 @@
nodeData.WrappedData.NotifyObservers();
}
- private static void WaveConditionsCalculationGroupContextOnNodeRemoved(StabilityStoneCoverWaveConditionsCalculationGroupContext nodeData, object parentNodeData)
+ private static void CalculationGroupContextOnNodeRemoved(StabilityStoneCoverCalculationGroupContext nodeData, object parentNodeData)
{
- var parentGroupContext = (StabilityStoneCoverWaveConditionsCalculationGroupContext) parentNodeData;
+ var parentGroupContext = (StabilityStoneCoverCalculationGroupContext) parentNodeData;
parentGroupContext.WrappedData.Children.Remove(nodeData.WrappedData);
parentGroupContext.NotifyObservers();
}
- private static string EnableValidateAndCalculateMenuItemForCalculationGroup(StabilityStoneCoverWaveConditionsCalculationGroupContext context)
+ private static string EnableValidateAndCalculateMenuItemForCalculationGroup(StabilityStoneCoverCalculationGroupContext context)
{
return EnableValidateAndCalculateMenuItem(context.AssessmentSection);
}
- private static void ValidateAllInCalculationGroup(StabilityStoneCoverWaveConditionsCalculationGroupContext context)
+ private static void ValidateAllInCalculationGroup(StabilityStoneCoverCalculationGroupContext context)
{
foreach (StabilityStoneCoverWaveConditionsCalculation calculation in context.WrappedData.GetCalculations().OfType())
{
@@ -632,7 +632,7 @@
}
}
- private void CalculateAllInCalculationGroup(StabilityStoneCoverWaveConditionsCalculationGroupContext context)
+ private void CalculateAllInCalculationGroup(StabilityStoneCoverCalculationGroupContext context)
{
ActivityProgressDialogRunner.Run(
Gui.MainWindow,
@@ -728,7 +728,7 @@
private static void WaveConditionsCalculationContextOnNodeRemoved(StabilityStoneCoverWaveConditionsCalculationContext nodeData, object parentNodeData)
{
- if (parentNodeData is StabilityStoneCoverWaveConditionsCalculationGroupContext calculationGroupContext)
+ if (parentNodeData is StabilityStoneCoverCalculationGroupContext calculationGroupContext)
{
bool successfullyRemovedData = calculationGroupContext.WrappedData.Children.Remove(nodeData.WrappedData);
if (successfullyRemovedData)
Index: Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Forms.Test/PresentationObjects/StabilityStoneCoverCalculationGroupContextTest.cs
===================================================================
diff -u
--- Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Forms.Test/PresentationObjects/StabilityStoneCoverCalculationGroupContextTest.cs (revision 0)
+++ Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Forms.Test/PresentationObjects/StabilityStoneCoverCalculationGroupContextTest.cs (revision 55786df7f5abe3fbda43470b70929ed7aeaee54f)
@@ -0,0 +1,136 @@
+// Copyright (C) Stichting Deltares 2021. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer 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.Collections.Generic;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Riskeer.Common.Data.AssessmentSection;
+using Riskeer.Common.Data.Calculation;
+using Riskeer.Common.Forms.PresentationObjects;
+using Riskeer.StabilityStoneCover.Data;
+using Riskeer.StabilityStoneCover.Forms.PresentationObjects;
+
+namespace Riskeer.StabilityStoneCover.Forms.Test.PresentationObjects
+{
+ [TestFixture]
+ public class StabilityStoneCoverCalculationGroupContextTest
+ {
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void ParameteredConstructor_ExpectedValues(bool hasParent)
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ var calculationGroup = new CalculationGroup();
+
+ CalculationGroup parent = hasParent ? new CalculationGroup() : null;
+
+ // Call
+ var context = new StabilityStoneCoverCalculationGroupContext(calculationGroup, parent, failureMechanism, assessmentSection);
+
+ // Assert
+ Assert.IsInstanceOf>(context);
+ Assert.IsInstanceOf>(context);
+ Assert.AreSame(calculationGroup, context.WrappedData);
+ Assert.AreSame(parent, context.Parent);
+ Assert.AreSame(failureMechanism, context.FailureMechanism);
+ Assert.AreSame(assessmentSection, context.AssessmentSection);
+ mocks.VerifyAll();
+ }
+
+ [TestFixture(true)]
+ [TestFixture(false)]
+ private class StabilityStoneCoverCalculationGroupContextEqualsTest
+ : EqualsTestFixture
+ {
+ private static readonly MockRepository mocks = new MockRepository();
+
+ private static readonly IAssessmentSection assessmentSection = mocks.Stub();
+ private static readonly StabilityStoneCoverFailureMechanism failureMechanism = new StabilityStoneCoverFailureMechanism();
+ private static readonly CalculationGroup calculationGroup = new CalculationGroup();
+
+ private static CalculationGroup parent;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks.ReplayAll();
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ mocks.VerifyAll();
+ }
+
+ public StabilityStoneCoverCalculationGroupContextEqualsTest(bool hasParent)
+ {
+ parent = hasParent ? new CalculationGroup() : null;
+ }
+
+ protected override StabilityStoneCoverCalculationGroupContext CreateObject()
+ {
+ return new StabilityStoneCoverCalculationGroupContext(calculationGroup,
+ parent,
+ failureMechanism,
+ assessmentSection);
+ }
+
+ protected override DerivedStabilityStoneCoverCalculationGroupContext CreateDerivedObject()
+ {
+ return new DerivedStabilityStoneCoverCalculationGroupContext(calculationGroup,
+ parent,
+ failureMechanism,
+ assessmentSection);
+ }
+
+ private static IEnumerable GetUnequalTestCases()
+ {
+ yield return new TestCaseData(new StabilityStoneCoverCalculationGroupContext(new CalculationGroup(),
+ parent,
+ failureMechanism,
+ assessmentSection))
+ .SetName("Wrapped Calculation Group");
+ yield return new TestCaseData(new StabilityStoneCoverCalculationGroupContext(calculationGroup,
+ new CalculationGroup(),
+ failureMechanism,
+ assessmentSection))
+ .SetName("Parent");
+ }
+ }
+
+ private class DerivedStabilityStoneCoverCalculationGroupContext : StabilityStoneCoverCalculationGroupContext
+ {
+ public DerivedStabilityStoneCoverCalculationGroupContext(CalculationGroup calculationGroup,
+ CalculationGroup parent,
+ StabilityStoneCoverFailureMechanism failureMechanism,
+ IAssessmentSection assessmentSection)
+ : base(calculationGroup, parent, failureMechanism, assessmentSection) {}
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 55786df7f5abe3fbda43470b70929ed7aeaee54f refers to a dead (removed) revision in file `Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Forms.Test/PresentationObjects/StabilityStoneCoverWaveConditionsCalculationGroupContextTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/ExportInfos/StabilityStoneCoverCalculationGroupContextConfigurationExportInfoTest.cs
===================================================================
diff -u
--- Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/ExportInfos/StabilityStoneCoverCalculationGroupContextConfigurationExportInfoTest.cs (revision 0)
+++ Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/ExportInfos/StabilityStoneCoverCalculationGroupContextConfigurationExportInfoTest.cs (revision 55786df7f5abe3fbda43470b70929ed7aeaee54f)
@@ -0,0 +1,158 @@
+// Copyright (C) Stichting Deltares 2021. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer 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.Linq;
+using Core.Common.Base.IO;
+using Core.Common.TestUtil;
+using Core.Gui;
+using Core.Gui.Forms.Main;
+using Core.Gui.Plugin;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Riskeer.Common.Data.AssessmentSection;
+using Riskeer.Common.Data.Calculation;
+using Riskeer.Common.Data.Contribution;
+using Riskeer.StabilityStoneCover.Data;
+using Riskeer.StabilityStoneCover.Forms.PresentationObjects;
+using Riskeer.StabilityStoneCover.IO.Configurations;
+using CoreGuiResources = Core.Gui.Properties.Resources;
+
+namespace Riskeer.StabilityStoneCover.Plugin.Test.ExportInfos
+{
+ [TestFixture]
+ public class StabilityStoneCoverCalculationGroupContextConfigurationExportInfoTest
+ {
+ private StabilityStoneCoverPlugin plugin;
+ private ExportInfo info;
+ private MockRepository mocks;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks = new MockRepository();
+ var mainWindow = mocks.Stub();
+ var gui = mocks.Stub();
+ gui.Stub(g => g.MainWindow).Return(mainWindow);
+ mocks.Replay(gui);
+ mocks.Replay(mainWindow);
+
+ plugin = new StabilityStoneCoverPlugin
+ {
+ Gui = gui
+ };
+
+ info = plugin.GetExportInfos()
+ .Single(ei => ei.DataType == typeof(StabilityStoneCoverCalculationGroupContext)
+ && ei.Name(null).Equals("Riskeer berekeningenconfiguratie"));
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ plugin.Dispose();
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Assert
+ Assert.AreEqual("xml", info.Extension);
+ Assert.IsNotNull(info.CreateFileExporter);
+ Assert.IsNotNull(info.IsEnabled);
+ Assert.AreEqual("Algemeen", info.Category);
+ TestHelper.AssertImagesAreEqual(CoreGuiResources.ExportIcon, info.Image);
+ Assert.IsNotNull(info.GetExportPath);
+ }
+
+ [Test]
+ public void CreateFileExporter_Always_ReturnFileExporter()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ assessmentSection.Stub(section => section.FailureMechanismContribution).Return(new FailureMechanismContribution(0.1, 0.1));
+ mocks.ReplayAll();
+
+ var context = new StabilityStoneCoverCalculationGroupContext(new CalculationGroup(),
+ null,
+ new StabilityStoneCoverFailureMechanism(),
+ assessmentSection);
+
+ // Call
+ IFileExporter fileExporter = info.CreateFileExporter(context, "test");
+
+ // Assert
+ Assert.IsInstanceOf(fileExporter);
+ }
+
+ [Test]
+ public void IsEnabled_CalculationGroupNoChildren_ReturnFalse()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var context = new StabilityStoneCoverCalculationGroupContext(new CalculationGroup(),
+ null,
+ new StabilityStoneCoverFailureMechanism(),
+ assessmentSection);
+
+ // Call
+ bool isEnabled = info.IsEnabled(context);
+
+ // Assert
+ Assert.IsFalse(isEnabled);
+ }
+
+ [Test]
+ [TestCase(true, false)]
+ [TestCase(false, true)]
+ public void IsEnabled_CalculationGroupWithChildren_ReturnTrue(bool hasNestedGroup, bool hasCalculation)
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var calculationGroup = new CalculationGroup();
+
+ if (hasNestedGroup)
+ {
+ calculationGroup.Children.Add(new CalculationGroup());
+ }
+
+ if (hasCalculation)
+ {
+ calculationGroup.Children.Add(new StabilityStoneCoverWaveConditionsCalculation());
+ }
+
+ var context = new StabilityStoneCoverCalculationGroupContext(calculationGroup,
+ null,
+ new StabilityStoneCoverFailureMechanism(),
+ assessmentSection);
+
+ // Call
+ bool isEnabled = info.IsEnabled(context);
+
+ // Assert
+ Assert.IsTrue(isEnabled);
+ }
+ }
+}
\ No newline at end of file
Index: Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/ExportInfos/StabilityStoneCoverCalculationGroupContextWaveConditionsExportInfoTest.cs
===================================================================
diff -u
--- Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/ExportInfos/StabilityStoneCoverCalculationGroupContextWaveConditionsExportInfoTest.cs (revision 0)
+++ Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/ExportInfos/StabilityStoneCoverCalculationGroupContextWaveConditionsExportInfoTest.cs (revision 55786df7f5abe3fbda43470b70929ed7aeaee54f)
@@ -0,0 +1,206 @@
+// Copyright (C) Stichting Deltares 2021. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer 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.Linq;
+using Core.Common.Base.IO;
+using Core.Common.TestUtil;
+using Core.Gui;
+using Core.Gui.Forms.Main;
+using Core.Gui.Plugin;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Riskeer.Common.Data.AssessmentSection;
+using Riskeer.Common.Data.Calculation;
+using Riskeer.Revetment.IO.WaveConditions;
+using Riskeer.StabilityStoneCover.Data;
+using Riskeer.StabilityStoneCover.Data.TestUtil;
+using Riskeer.StabilityStoneCover.Forms.PresentationObjects;
+using CoreGuiResources = Core.Gui.Properties.Resources;
+
+namespace Riskeer.StabilityStoneCover.Plugin.Test.ExportInfos
+{
+ [TestFixture]
+ public class StabilityStoneCoverCalculationGroupContextWaveConditionsExportInfoTest
+ {
+ private StabilityStoneCoverPlugin plugin;
+ private ExportInfo info;
+ private MockRepository mocks;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks = new MockRepository();
+ var mainWindow = mocks.Stub();
+ var gui = mocks.Stub();
+ gui.Stub(g => g.MainWindow).Return(mainWindow);
+ mocks.Replay(gui);
+ mocks.Replay(mainWindow);
+
+ plugin = new StabilityStoneCoverPlugin
+ {
+ Gui = gui
+ };
+
+ info = plugin.GetExportInfos()
+ .Single(ei => ei.DataType == typeof(StabilityStoneCoverCalculationGroupContext)
+ && ei.Name(null).Equals("Berekende belastingen bij verschillende waterstanden"));
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ plugin.Dispose();
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Assert
+ Assert.AreEqual("csv", info.Extension);
+ Assert.IsNotNull(info.CreateFileExporter);
+ Assert.IsNotNull(info.IsEnabled);
+ Assert.AreEqual("Algemeen", info.Category);
+ TestHelper.AssertImagesAreEqual(CoreGuiResources.ExportIcon, info.Image);
+ Assert.IsNotNull(info.GetExportPath);
+ }
+
+ [Test]
+ public void CreateFileExporter_Always_ReturnFileExporter()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ var calculationGroup = new CalculationGroup();
+
+ var context = new StabilityStoneCoverCalculationGroupContext(calculationGroup, null, failureMechanism, assessmentSection);
+
+ // Call
+ IFileExporter fileExporter = info.CreateFileExporter(context, "test");
+
+ // Assert
+ Assert.IsInstanceOf(fileExporter);
+ }
+
+ [Test]
+ public void IsEnabled_NoCalculations_ReturnFalse()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ var calculationGroup = new CalculationGroup();
+
+ var context = new StabilityStoneCoverCalculationGroupContext(calculationGroup, null, failureMechanism, assessmentSection);
+
+ // Call
+ bool isEnabled = info.IsEnabled(context);
+
+ // Assert
+ Assert.IsFalse(isEnabled);
+ }
+
+ [Test]
+ public void IsEnabled_CalculationWithoutOutput_ReturnFalse()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ var calculationGroup = new CalculationGroup();
+ calculationGroup.Children.Add(new StabilityStoneCoverWaveConditionsCalculation());
+
+ var context = new StabilityStoneCoverCalculationGroupContext(calculationGroup, null, failureMechanism, assessmentSection);
+
+ // Call
+ bool isEnabled = info.IsEnabled(context);
+
+ // Assert
+ Assert.IsFalse(isEnabled);
+ }
+
+ [Test]
+ public void IsEnabled_CalculationWithOutput_ReturnTrue()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ var calculationGroup = new CalculationGroup();
+ calculationGroup.Children.Add(new StabilityStoneCoverWaveConditionsCalculation
+ {
+ Output = StabilityStoneCoverWaveConditionsOutputTestFactory.Create()
+ });
+
+ var context = new StabilityStoneCoverCalculationGroupContext(calculationGroup, null, failureMechanism, assessmentSection);
+
+ // Call
+ bool isEnabled = info.IsEnabled(context);
+
+ // Assert
+ Assert.IsTrue(isEnabled);
+ }
+
+ [Test]
+ [TestCase(true, TestName = "IsEnabled_WithOutputInSubFolder_ReturnExpectedEnabledState")]
+ [TestCase(false, TestName = "IsEnabled_WithoutOutputInSubFolder_ReturnExpectedEnabledState")]
+ public void IsEnabled_CalculationWithOrWithoutOutputInSubFolder_ReturnExpectedEnabledState(bool hasOutput)
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ var calculationGroup = new CalculationGroup();
+
+ StabilityStoneCoverWaveConditionsOutput stabilityStoneCoverWaveConditionsOutput = null;
+ if (hasOutput)
+ {
+ stabilityStoneCoverWaveConditionsOutput = StabilityStoneCoverWaveConditionsOutputTestFactory.Create();
+ }
+
+ calculationGroup.Children.Add(
+ new CalculationGroup
+ {
+ Children =
+ {
+ new StabilityStoneCoverWaveConditionsCalculation
+ {
+ Output = stabilityStoneCoverWaveConditionsOutput
+ }
+ }
+ });
+
+ var context = new StabilityStoneCoverCalculationGroupContext(calculationGroup, null, failureMechanism, assessmentSection);
+
+ // Call
+ bool isEnabled = info.IsEnabled(context);
+
+ // Assert
+ Assert.AreEqual(hasOutput, isEnabled);
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 55786df7f5abe3fbda43470b70929ed7aeaee54f refers to a dead (removed) revision in file `Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/ExportInfos/StabilityStoneCoverWaveConditionsCalculationGroupContextConfigurationExportInfoTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 55786df7f5abe3fbda43470b70929ed7aeaee54f refers to a dead (removed) revision in file `Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/ExportInfos/StabilityStoneCoverWaveConditionsCalculationGroupContextWaveConditionsExportInfoTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/ImportInfos/StabilityStoneCoverCalculationGroupContextImportInfoTest.cs
===================================================================
diff -u
--- Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/ImportInfos/StabilityStoneCoverCalculationGroupContextImportInfoTest.cs (revision 0)
+++ Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/ImportInfos/StabilityStoneCoverCalculationGroupContextImportInfoTest.cs (revision 55786df7f5abe3fbda43470b70929ed7aeaee54f)
@@ -0,0 +1,136 @@
+// Copyright (C) Stichting Deltares 2021. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer 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.Drawing;
+using System.Linq;
+using Core.Common.Base;
+using Core.Common.Base.IO;
+using Core.Common.TestUtil;
+using Core.Common.Util;
+using Core.Gui.Plugin;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Riskeer.Common.Data.AssessmentSection;
+using Riskeer.Common.Data.Calculation;
+using Riskeer.Common.Data.Hydraulics;
+using Riskeer.Common.Data.TestUtil;
+using Riskeer.StabilityStoneCover.Data;
+using Riskeer.StabilityStoneCover.Forms.PresentationObjects;
+using Riskeer.StabilityStoneCover.IO.Configurations;
+using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources;
+
+namespace Riskeer.StabilityStoneCover.Plugin.Test.ImportInfos
+{
+ [TestFixture]
+ public class StabilityStoneCoverCalculationGroupContextImportInfoTest
+ {
+ private ImportInfo importInfo;
+ private StabilityStoneCoverPlugin plugin;
+
+ [SetUp]
+ public void SetUp()
+ {
+ plugin = new StabilityStoneCoverPlugin();
+ importInfo = plugin.GetImportInfos().First(i => i.DataType == typeof(StabilityStoneCoverCalculationGroupContext));
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ plugin.Dispose();
+ }
+
+ [Test]
+ public void Name_Always_ReturnExpectedName()
+ {
+ // Call
+ string name = importInfo.Name;
+
+ // Assert
+ Assert.AreEqual("Riskeer berekeningenconfiguratie", name);
+ }
+
+ [Test]
+ public void Category_Always_ReturnExpectedCategory()
+ {
+ // Call
+ string category = importInfo.Category;
+
+ // Assert
+ Assert.AreEqual("Algemeen", category);
+ }
+
+ [Test]
+ public void Image_Always_ReturnExpectedIcon()
+ {
+ // Call
+ Image image = importInfo.Image;
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.GeneralFolderIcon, image);
+ }
+
+ [Test]
+ public void FileFilterGenerator_Always_ReturnExpectedFileFilter()
+ {
+ // Call
+ FileFilterGenerator fileFilterGenerator = importInfo.FileFilterGenerator;
+
+ // Assert
+ Assert.AreEqual("Riskeer berekeningenconfiguratie (*.xml)|*.xml", fileFilterGenerator.Filter);
+ }
+
+ [Test]
+ public void IsEnabled_Always_ReturnTrue()
+ {
+ // Call
+ bool isEnabled = importInfo.IsEnabled(null);
+
+ // Assert
+ Assert.IsTrue(isEnabled);
+ }
+
+ [Test]
+ public void CreateFileImporter_Always_ReturnFileImporter()
+ {
+ // Setup
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+
+ var mocks = new MockRepository();
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
+ assessmentSection.Stub(section => section.WaterLevelCalculationsForUserDefinedTargetProbabilities)
+ .Return(new ObservableList());
+ mocks.ReplayAll();
+
+ var context = new StabilityStoneCoverCalculationGroupContext(new CalculationGroup(),
+ null,
+ failureMechanism,
+ assessmentSection);
+
+ // Call
+ IFileImporter importer = importInfo.CreateFileImporter(context, "");
+
+ // Assert
+ Assert.IsInstanceOf(importer);
+ mocks.VerifyAll();
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 55786df7f5abe3fbda43470b70929ed7aeaee54f refers to a dead (removed) revision in file `Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/ImportInfos/StabilityStoneCoverWaveConditionsCalculationGroupContextImportInfoTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/Riskeer.StabilityStoneCover.Plugin.Test.csproj
===================================================================
diff -u -re3b8937a862993685f17f944a7656a7def8b8c3b -r55786df7f5abe3fbda43470b70929ed7aeaee54f
--- Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/Riskeer.StabilityStoneCover.Plugin.Test.csproj (.../Riskeer.StabilityStoneCover.Plugin.Test.csproj) (revision e3b8937a862993685f17f944a7656a7def8b8c3b)
+++ Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/Riskeer.StabilityStoneCover.Plugin.Test.csproj (.../Riskeer.StabilityStoneCover.Plugin.Test.csproj) (revision 55786df7f5abe3fbda43470b70929ed7aeaee54f)
@@ -28,7 +28,7 @@
-
+
Index: Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/StabilityStoneCoverPluginTest.cs
===================================================================
diff -u -raaea9a6608ef667d6b4f6318ac33eebe3819ec5a -r55786df7f5abe3fbda43470b70929ed7aeaee54f
--- Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/StabilityStoneCoverPluginTest.cs (.../StabilityStoneCoverPluginTest.cs) (revision aaea9a6608ef667d6b4f6318ac33eebe3819ec5a)
+++ Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/StabilityStoneCoverPluginTest.cs (.../StabilityStoneCoverPluginTest.cs) (revision 55786df7f5abe3fbda43470b70929ed7aeaee54f)
@@ -142,7 +142,7 @@
Assert.AreEqual(8, treeNodeInfos.Length);
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StabilityStoneCoverHydraulicLoadsContext)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StabilityStoneCoverFailurePathContext)));
- Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StabilityStoneCoverWaveConditionsCalculationGroupContext)));
+ Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StabilityStoneCoverCalculationGroupContext)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StabilityStoneCoverWaveConditionsCalculationContext)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(EmptyStabilityStoneCoverOutput)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StabilityStoneCoverFailureMechanismSectionResultContext)));
@@ -171,7 +171,7 @@
// Assert
Assert.AreEqual(4, exportInfos.Length);
- Assert.AreEqual(2, exportInfos.Count(ei => ei.DataType == typeof(StabilityStoneCoverWaveConditionsCalculationGroupContext)));
+ Assert.AreEqual(2, exportInfos.Count(ei => ei.DataType == typeof(StabilityStoneCoverCalculationGroupContext)));
Assert.AreEqual(2, exportInfos.Count(ei => ei.DataType == typeof(StabilityStoneCoverWaveConditionsCalculationContext)));
}
@@ -189,7 +189,7 @@
// Assert
Assert.AreEqual(1, importInfos.Length);
- Assert.IsTrue(importInfos.Any(i => i.DataType == typeof(StabilityStoneCoverWaveConditionsCalculationGroupContext)));
+ Assert.IsTrue(importInfos.Any(i => i.DataType == typeof(StabilityStoneCoverCalculationGroupContext)));
}
}
Index: Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/TreeNodeInfos/StabilityStoneCoverCalculationGroupContextTreeNodeInfoTest.cs
===================================================================
diff -u
--- Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/TreeNodeInfos/StabilityStoneCoverCalculationGroupContextTreeNodeInfoTest.cs (revision 0)
+++ Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/TreeNodeInfos/StabilityStoneCoverCalculationGroupContextTreeNodeInfoTest.cs (revision 55786df7f5abe3fbda43470b70929ed7aeaee54f)
@@ -0,0 +1,1924 @@
+// Copyright (C) Stichting Deltares 2021. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer 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.Windows.Forms;
+using Core.Common.Base;
+using Core.Common.Base.Data;
+using Core.Common.Controls.DataGrid;
+using Core.Common.Controls.TreeView;
+using Core.Common.TestUtil;
+using Core.Gui;
+using Core.Gui.Commands;
+using Core.Gui.ContextMenu;
+using Core.Gui.Forms.Main;
+using Core.Gui.Plugin;
+using Core.Gui.TestUtil;
+using Core.Gui.TestUtil.ContextMenu;
+using NUnit.Extensions.Forms;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Riskeer.Common.Data.AssessmentSection;
+using Riskeer.Common.Data.Calculation;
+using Riskeer.Common.Data.Contribution;
+using Riskeer.Common.Data.Hydraulics;
+using Riskeer.Common.Data.TestUtil;
+using Riskeer.Common.Forms;
+using Riskeer.Common.Service.TestUtil;
+using Riskeer.HydraRing.Calculation.Calculator.Factory;
+using Riskeer.HydraRing.Calculation.Data.Input;
+using Riskeer.HydraRing.Calculation.TestUtil.Calculator;
+using Riskeer.Revetment.Data;
+using Riskeer.StabilityStoneCover.Data;
+using Riskeer.StabilityStoneCover.Data.TestUtil;
+using Riskeer.StabilityStoneCover.Forms.PresentationObjects;
+using CoreGuiResources = Core.Gui.Properties.Resources;
+using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources;
+
+namespace Riskeer.StabilityStoneCover.Plugin.Test.TreeNodeInfos
+{
+ [TestFixture]
+ public class StabilityStoneCoverCalculationGroupContextTreeNodeInfoTest : NUnitFormTest
+ {
+ private const int contextMenuAddGenerateCalculationsIndex = 3;
+ private const int contextMenuAddCalculationGroupIndexRootGroup = 5;
+ private const int contextMenuAddCalculationIndexRootGroup = 6;
+ private const int contextMenuUpdateForeshoreProfileIndexRootGroup = 8;
+ private const int contextMenuValidateAllIndexRootGroup = 10;
+ private const int contextMenuCalculateAllIndexRootGroup = 11;
+ private const int contextMenuClearOutputIndexRootGroup = 13;
+ private const int contextMenuRemoveAllChildrenIndexRootGroup = 14;
+ private const int contextMenuCollapseAllIndexRootGroup = 16;
+ private const int contextMenuExpandAllIndexRootGroup = 17;
+ private const int contextMenuPropertiesIndexRootGroup = 19;
+
+ private const int contextMenuDuplicateIndexNestedGroup = 3;
+ private const int contextMenuAddCalculationGroupIndexNestedGroup = 5;
+ private const int contextMenuAddCalculationIndexNestedGroup = 6;
+ private const int contextMenuUpdateForeshoreProfileIndexNestedGroup = 9;
+ private const int contextMenuValidateAllIndexNestedGroup = 11;
+ private const int contextMenuCalculateAllIndexNestedGroup = 12;
+ private const int contextMenuClearOutputIndexNestedGroup = 14;
+
+ private IGui gui;
+ private MockRepository mocks;
+ private StabilityStoneCoverPlugin plugin;
+ private TreeNodeInfo info;
+
+ private readonly string validFilePath = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Integration.Service, Path.Combine("HydraRingCalculation", "HRD ijsselmeer.sqlite"));
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ // Assert
+ Assert.IsNotNull(info.Text);
+ Assert.IsNull(info.ForeColor);
+ Assert.IsNotNull(info.Image);
+ Assert.IsNotNull(info.ContextMenuStrip);
+ Assert.IsNotNull(info.EnsureVisibleOnCreate);
+ Assert.IsNull(info.ExpandOnCreate);
+ Assert.IsNotNull(info.ChildNodeObjects);
+ Assert.IsNotNull(info.CanRename);
+ Assert.IsNotNull(info.OnNodeRenamed);
+ Assert.IsNotNull(info.CanRemove);
+ Assert.IsNotNull(info.OnNodeRemoved);
+ Assert.IsNull(info.CanCheck);
+ Assert.IsNull(info.CheckedState);
+ Assert.IsNull(info.OnNodeChecked);
+ Assert.IsNotNull(info.CanDrag);
+ Assert.IsNotNull(info.CanDrop);
+ Assert.IsNotNull(info.CanInsert);
+ Assert.IsNotNull(info.OnDrop);
+ }
+
+ [Test]
+ public void Text_Always_ReturnGroupName()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ var context = new StabilityStoneCoverCalculationGroupContext(failureMechanism.CalculationsGroup,
+ null,
+ failureMechanism,
+ assessmentSection);
+
+ // Call
+ string text = info.Text(context);
+
+ // Assert
+ Assert.AreEqual("Hydraulische belastingen", text);
+ }
+
+ [Test]
+ public void Image_Always_ReturnCalculationGroupIcon()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ var context = new StabilityStoneCoverCalculationGroupContext(failureMechanism.CalculationsGroup,
+ null,
+ failureMechanism,
+ assessmentSection);
+
+ // Call
+ Image icon = info.Image(context);
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.GeneralFolderIcon, icon);
+ }
+
+ [Test]
+ public void ChildNodeObjects_EmptyGroup_ReturnEmpty()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ var groupContext = new StabilityStoneCoverCalculationGroupContext(failureMechanism.CalculationsGroup,
+ null,
+ failureMechanism,
+ assessmentSection);
+
+ // Call
+ object[] children = info.ChildNodeObjects(groupContext);
+
+ // Assert
+ CollectionAssert.IsEmpty(children);
+ }
+
+ [Test]
+ public void ChildNodeObjects_GroupWithChildren_ReturnChildren()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var childGroup = new CalculationGroup();
+ var calculationItem = new StabilityStoneCoverWaveConditionsCalculation();
+
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ failureMechanism.CalculationsGroup.Children.Add(calculationItem);
+ failureMechanism.CalculationsGroup.Children.Add(childGroup);
+
+ var nodeData = new StabilityStoneCoverCalculationGroupContext(failureMechanism.CalculationsGroup,
+ null,
+ failureMechanism,
+ assessmentSection);
+
+ // Call
+ object[] children = info.ChildNodeObjects(nodeData).ToArray();
+
+ // Assert
+ Assert.AreEqual(failureMechanism.CalculationsGroup.Children.Count, children.Length);
+
+ var returnedCalculationContext = (StabilityStoneCoverWaveConditionsCalculationContext) children[0];
+ Assert.AreSame(calculationItem, returnedCalculationContext.WrappedData);
+ Assert.AreSame(failureMechanism.CalculationsGroup, returnedCalculationContext.Parent);
+ Assert.AreSame(failureMechanism, returnedCalculationContext.FailureMechanism);
+ Assert.AreSame(assessmentSection, returnedCalculationContext.AssessmentSection);
+
+ var returnedCalculationGroupContext = (StabilityStoneCoverCalculationGroupContext) children[1];
+ Assert.AreSame(childGroup, returnedCalculationGroupContext.WrappedData);
+ Assert.AreSame(failureMechanism.CalculationsGroup, returnedCalculationGroupContext.Parent);
+ Assert.AreSame(failureMechanism, returnedCalculationGroupContext.FailureMechanism);
+ Assert.AreSame(assessmentSection, returnedCalculationGroupContext.AssessmentSection);
+ }
+
+ [Test]
+ public void ContextMenuStrip_WithoutParentNodeDefaultBehavior_CallsContextMenuBuilderMethods()
+ {
+ // Setup
+ var group = new CalculationGroup();
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocks);
+ var groupContext = new StabilityStoneCoverCalculationGroupContext(group,
+ null,
+ failureMechanism,
+ assessmentSection);
+
+ var orderedMocks = new MockRepository();
+ var menuBuilder = orderedMocks.StrictMock();
+ using (orderedMocks.Ordered())
+ {
+ menuBuilder.Expect(mb => mb.AddImportItem()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddExportItem()).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.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().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.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddDeleteChildrenItem()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.Build()).Return(null);
+ }
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ gui.Stub(g => g.Get(groupContext, treeViewControl)).Return(menuBuilder);
+ gui.Stub(g => g.ViewCommands).Return(mocks.Stub());
+ gui.Stub(g => g.MainWindow).Return(mocks.Stub());
+ mocks.ReplayAll();
+ orderedMocks.ReplayAll();
+
+ // Call
+ info.ContextMenuStrip(groupContext, null, treeViewControl);
+ }
+
+ // Assert
+ orderedMocks.VerifyAll();
+ }
+
+ [Test]
+ public void ContextMenuStrip_WithoutParentNodeDefaultBehavior_AddCustomItems()
+ {
+ // Setup
+ var group = new CalculationGroup();
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocks);
+ var groupContext = new StabilityStoneCoverCalculationGroupContext(group,
+ null,
+ failureMechanism,
+ assessmentSection);
+
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ gui.Stub(g => g.Get(groupContext, treeViewControl)).Return(menuBuilder);
+ gui.Stub(g => g.ViewCommands).Return(mocks.Stub());
+ gui.Stub(g => g.MainWindow).Return(mocks.Stub());
+ mocks.ReplayAll();
+
+ // Call
+ using (ContextMenuStrip menu = info.ContextMenuStrip(groupContext, null, treeViewControl))
+ {
+ // Assert
+ Assert.AreEqual(20, menu.Items.Count);
+
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddGenerateCalculationsIndex,
+ "Genereer &berekeningen...",
+ "Er is geen hydraulische belastingendatabase beschikbaar om de belastingenberekeningen te genereren.",
+ RiskeerCommonFormsResources.GenerateScenariosIcon,
+ false);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationGroupIndexRootGroup,
+ "&Map toevoegen",
+ "Voeg een nieuwe map toe aan deze map met berekeningen.",
+ RiskeerCommonFormsResources.AddFolderIcon);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationIndexRootGroup,
+ "Berekening &toevoegen",
+ "Voeg een nieuwe berekening toe aan deze map met berekeningen.",
+ RiskeerCommonFormsResources.HydraulicCalculationIcon);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuUpdateForeshoreProfileIndexRootGroup,
+ "&Bijwerken voorlandprofielen...",
+ "Er zijn geen berekeningen om bij te werken.",
+ RiskeerCommonFormsResources.UpdateItemIcon,
+ false);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndexRootGroup,
+ "Alles &valideren",
+ "Er zijn geen berekeningen om te valideren.",
+ RiskeerCommonFormsResources.ValidateAllIcon,
+ false);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndexRootGroup,
+ "Alles be&rekenen",
+ "Er zijn geen berekeningen om uit te voeren.",
+ RiskeerCommonFormsResources.CalculateAllIcon,
+ false);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuClearOutputIndexRootGroup,
+ "&Wis alle uitvoer...",
+ "Er zijn geen berekeningen met uitvoer om te wissen.",
+ RiskeerCommonFormsResources.ClearIcon,
+ false);
+ }
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_NestedCalculationGroup_CallsContextMenuBuilderMethods()
+ {
+ // Setup
+ var group = new CalculationGroup();
+ var parentGroup = new CalculationGroup();
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ var assessmentSection = mocks.Stub();
+ var groupContext = new StabilityStoneCoverCalculationGroupContext(group,
+ parentGroup,
+ failureMechanism,
+ assessmentSection);
+ var parentGroupContext = new StabilityStoneCoverCalculationGroupContext(parentGroup,
+ null,
+ failureMechanism,
+ assessmentSection);
+
+ var menuBuilder = mocks.StrictMock();
+ using (mocks.Ordered())
+ {
+ menuBuilder.Expect(mb => mb.AddImportItem()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddExportItem()).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.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddRenameItem()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddDeleteItem()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.Build()).Return(null);
+ }
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ gui.Stub(g => g.Get(groupContext, treeViewControl)).Return(menuBuilder);
+ gui.Stub(g => g.MainWindow).Return(mocks.Stub());
+ mocks.ReplayAll();
+
+ // Call
+ info.ContextMenuStrip(groupContext, parentGroupContext, treeViewControl);
+ }
+
+ // Assert
+ // Assert expectancies called in TearDown()
+ }
+
+ [Test]
+ public void ContextMenuStrip_NestedCalculationGroup_AddCustomItems()
+ {
+ // Setup
+ var group = new CalculationGroup();
+ var parentGroup = new CalculationGroup();
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ var assessmentSection = mocks.Stub();
+ var groupContext = new StabilityStoneCoverCalculationGroupContext(group,
+ parentGroup,
+ failureMechanism,
+ assessmentSection);
+ var parentGroupContext = new StabilityStoneCoverCalculationGroupContext(parentGroup,
+ null,
+ failureMechanism,
+ assessmentSection);
+
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+ using (var treeViewControl = new TreeViewControl())
+ {
+ gui.Stub(g => g.Get(groupContext, treeViewControl)).Return(menuBuilder);
+ gui.Stub(g => g.MainWindow).Return(mocks.Stub());
+ mocks.ReplayAll();
+
+ // Call
+ using (ContextMenuStrip menu = info.ContextMenuStrip(groupContext, parentGroupContext, treeViewControl))
+ {
+ // Assert
+ Assert.AreEqual(21, menu.Items.Count);
+
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuDuplicateIndexNestedGroup,
+ "D&upliceren",
+ "Dupliceer dit element.",
+ RiskeerCommonFormsResources.CopyHS);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationGroupIndexNestedGroup,
+ "&Map toevoegen",
+ "Voeg een nieuwe map toe aan deze map met berekeningen.",
+ RiskeerCommonFormsResources.AddFolderIcon);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationIndexNestedGroup,
+ "Berekening &toevoegen",
+ "Voeg een nieuwe berekening toe aan deze map met berekeningen.",
+ RiskeerCommonFormsResources.HydraulicCalculationIcon);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuUpdateForeshoreProfileIndexNestedGroup,
+ "&Bijwerken voorlandprofielen...",
+ "Er zijn geen berekeningen om bij te werken.",
+ RiskeerCommonFormsResources.UpdateItemIcon,
+ false);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndexNestedGroup,
+ "Alles &valideren",
+ "Er zijn geen berekeningen om te valideren.",
+ RiskeerCommonFormsResources.ValidateAllIcon,
+ false);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndexNestedGroup,
+ "Alles be&rekenen",
+ "Er zijn geen berekeningen om uit te voeren.",
+ RiskeerCommonFormsResources.CalculateAllIcon,
+ false);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuClearOutputIndexNestedGroup,
+ "&Wis alle uitvoer...",
+ "Er zijn geen berekeningen met uitvoer om te wissen.",
+ RiskeerCommonFormsResources.ClearIcon,
+ false);
+ }
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_WithoutParentNodeWithoutHydraulicLocationsDefaultBehavior_ReturnContextMenuWithoutRenameRemove()
+ {
+ // Setup
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocks);
+
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+
+ var nodeData = new StabilityStoneCoverCalculationGroupContext(failureMechanism.CalculationsGroup,
+ null,
+ failureMechanism,
+ assessmentSection);
+
+ var applicationFeatureCommandHandler = mocks.Stub();
+ var importCommandHandler = mocks.StrictMock();
+ importCommandHandler.Expect(ich => ich.GetSupportedImportInfos(nodeData)).Return(new[]
+ {
+ new ImportInfo()
+ });
+ var exportCommandHandler = mocks.StrictMock();
+ exportCommandHandler.Expect(ech => ech.CanExportFrom(nodeData)).Return(true);
+ var updateCommandHandler = mocks.StrictMock();
+ var viewCommandsHandler = mocks.StrictMock();
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler,
+ importCommandHandler,
+ exportCommandHandler,
+ updateCommandHandler,
+ viewCommandsHandler,
+ nodeData,
+ treeViewControl);
+
+ gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder);
+ gui.Stub(g => g.ViewCommands).Return(mocks.Stub());
+ gui.Stub(g => g.MainWindow).Return(mocks.Stub());
+ mocks.ReplayAll();
+
+ // Call
+ using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl))
+ {
+ // Assert
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddGenerateCalculationsIndex,
+ "Genereer &berekeningen...",
+ "Er is geen hydraulische belastingendatabase beschikbaar om de belastingenberekeningen te genereren.",
+ RiskeerCommonFormsResources.GenerateScenariosIcon, false);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationGroupIndexRootGroup,
+ "&Map toevoegen",
+ "Voeg een nieuwe map toe aan deze map met berekeningen.",
+ RiskeerCommonFormsResources.AddFolderIcon);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationIndexRootGroup,
+ "Berekening &toevoegen",
+ "Voeg een nieuwe berekening toe aan deze map met berekeningen.",
+ RiskeerCommonFormsResources.HydraulicCalculationIcon);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuRemoveAllChildrenIndexRootGroup,
+ "Ma&p leegmaken...",
+ "Er zijn geen onderliggende elementen om te verwijderen.",
+ CoreGuiResources.DeleteChildrenIcon,
+ false);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndexRootGroup,
+ "Alles &valideren",
+ "Er zijn geen berekeningen om te valideren.",
+ RiskeerCommonFormsResources.ValidateAllIcon,
+ false);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndexRootGroup,
+ "Alles be&rekenen",
+ "Er zijn geen berekeningen om uit te voeren.",
+ RiskeerCommonFormsResources.CalculateAllIcon,
+ false);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuClearOutputIndexRootGroup,
+ "&Wis alle uitvoer...",
+ "Er zijn geen berekeningen met uitvoer om te wissen.",
+ RiskeerCommonFormsResources.ClearIcon,
+ false);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuExpandAllIndexRootGroup,
+ "Alles ui&tklappen",
+ "Klap dit element en alle onderliggende elementen uit.",
+ CoreGuiResources.ExpandAllIcon,
+ false);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCollapseAllIndexRootGroup,
+ "Alles i&nklappen",
+ "Klap dit element en alle onderliggende elementen in.",
+ CoreGuiResources.CollapseAllIcon,
+ false);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuPropertiesIndexRootGroup,
+ "Ei&genschappen",
+ "Toon de eigenschappen in het Eigenschappenpaneel.",
+ CoreGuiResources.PropertiesHS,
+ false);
+ }
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_WithoutParentNodeWithHydraulicLocationsDefaultBehavior_ReturnContextMenuWithoutRenameRemove()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(new HydraulicBoundaryDatabase
+ {
+ Locations =
+ {
+ new TestHydraulicBoundaryLocation()
+ }
+ });
+
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+
+ var nodeData = new StabilityStoneCoverCalculationGroupContext(failureMechanism.CalculationsGroup,
+ null,
+ failureMechanism,
+ assessmentSection);
+
+ var applicationFeatureCommandHandler = mocks.Stub();
+ var importCommandHandler = mocks.StrictMock();
+ importCommandHandler.Expect(ich => ich.GetSupportedImportInfos(nodeData)).Return(new[]
+ {
+ new ImportInfo()
+ });
+ var exportCommandHandler = mocks.StrictMock();
+ exportCommandHandler.Expect(ech => ech.CanExportFrom(nodeData)).Return(true);
+ var updateCommandHandler = mocks.StrictMock();
+ var viewCommandsHandler = mocks.StrictMock();
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler,
+ importCommandHandler,
+ exportCommandHandler,
+ updateCommandHandler,
+ viewCommandsHandler,
+ nodeData,
+ treeViewControl);
+
+ gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder);
+ gui.Stub(g => g.ViewCommands).Return(mocks.Stub());
+ gui.Stub(g => g.MainWindow).Return(mocks.Stub());
+ mocks.ReplayAll();
+
+ // Call
+ using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl))
+ {
+ // Assert
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddGenerateCalculationsIndex,
+ "Genereer &berekeningen...",
+ "Genereer belastingenberekeningen.",
+ RiskeerCommonFormsResources.GenerateScenariosIcon);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationGroupIndexRootGroup,
+ "&Map toevoegen",
+ "Voeg een nieuwe map toe aan deze map met berekeningen.",
+ RiskeerCommonFormsResources.AddFolderIcon);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationIndexRootGroup,
+ "Berekening &toevoegen",
+ "Voeg een nieuwe berekening toe aan deze map met berekeningen.",
+ RiskeerCommonFormsResources.HydraulicCalculationIcon);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuRemoveAllChildrenIndexRootGroup,
+ "Ma&p leegmaken...",
+ "Er zijn geen onderliggende elementen om te verwijderen.",
+ CoreGuiResources.DeleteChildrenIcon,
+ false);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndexRootGroup,
+ "Alles &valideren",
+ "Er zijn geen berekeningen om te valideren.",
+ RiskeerCommonFormsResources.ValidateAllIcon,
+ false);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndexRootGroup,
+ "Alles be&rekenen",
+ "Er zijn geen berekeningen om uit te voeren.",
+ RiskeerCommonFormsResources.CalculateAllIcon,
+ false);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuClearOutputIndexRootGroup,
+ "&Wis alle uitvoer...",
+ "Er zijn geen berekeningen met uitvoer om te wissen.",
+ RiskeerCommonFormsResources.ClearIcon,
+ false);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuExpandAllIndexRootGroup,
+ "Alles ui&tklappen",
+ "Klap dit element en alle onderliggende elementen uit.",
+ CoreGuiResources.ExpandAllIcon,
+ false);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCollapseAllIndexRootGroup,
+ "Alles i&nklappen",
+ "Klap dit element en alle onderliggende elementen in.",
+ CoreGuiResources.CollapseAllIcon,
+ false);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuPropertiesIndexRootGroup,
+ "Ei&genschappen",
+ "Toon de eigenschappen in het Eigenschappenpaneel.",
+ CoreGuiResources.PropertiesHS,
+ false);
+ }
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_NestedCalculationGroupWithoutCalculations_CalculateAllAndValidateAllDisabled()
+ {
+ // Setup
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var group = new CalculationGroup();
+
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ failureMechanism.CalculationsGroup.Children.Add(group);
+
+ var assessmentSection = mocks.Stub();
+ var nodeData = new StabilityStoneCoverCalculationGroupContext(group,
+ failureMechanism.CalculationsGroup,
+ failureMechanism,
+ assessmentSection);
+ var parentNodeData = new StabilityStoneCoverCalculationGroupContext(failureMechanism.CalculationsGroup,
+ null,
+ failureMechanism,
+ assessmentSection);
+
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+
+ gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder);
+ gui.Stub(g => g.MainWindow).Return(mocks.Stub());
+ mocks.ReplayAll();
+
+ // Call
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl))
+ {
+ // Assert
+ ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroup];
+ ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroup];
+ Assert.IsFalse(validateItem.Enabled);
+ Assert.IsFalse(calculateItem.Enabled);
+ Assert.AreEqual(RiskeerCommonFormsResources.FailureMechanism_CreateCalculateAllItem_No_calculations_to_run, calculateItem.ToolTipText);
+ Assert.AreEqual(RiskeerCommonFormsResources.FailureMechanism_CreateValidateAllItem_No_calculations_to_validate, validateItem.ToolTipText);
+ }
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_HydraulicBoundaryDatabaseNotLinked_CalculateAllAndValidateAllDisabled()
+ {
+ // Setup
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var group = new CalculationGroup();
+
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ group.Children.Add(new StabilityStoneCoverWaveConditionsCalculation());
+ failureMechanism.CalculationsGroup.Children.Add(group);
+
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocks);
+ var nodeData = new StabilityStoneCoverCalculationGroupContext(group,
+ failureMechanism.CalculationsGroup,
+ failureMechanism,
+ assessmentSection);
+ var parentNodeData = new StabilityStoneCoverCalculationGroupContext(failureMechanism.CalculationsGroup,
+ null,
+ failureMechanism,
+ assessmentSection);
+
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+
+ gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder);
+ gui.Stub(g => g.MainWindow).Return(mocks.Stub());
+ mocks.ReplayAll();
+
+ // Call
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl))
+ {
+ // Assert
+ ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroup];
+ ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroup];
+ Assert.IsFalse(validateItem.Enabled);
+ Assert.IsFalse(calculateItem.Enabled);
+ Assert.AreEqual("Er is geen hydraulische belastingendatabase geïmporteerd.", calculateItem.ToolTipText);
+ Assert.AreEqual("Er is geen hydraulische belastingendatabase geïmporteerd.", validateItem.ToolTipText);
+ }
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_HydraulicBoundaryDatabaseLinkedToInvalidFile_CalculateAllAndValidateAllDisabled()
+ {
+ // Setup
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var group = new CalculationGroup();
+
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ group.Children.Add(new StabilityStoneCoverWaveConditionsCalculation());
+ failureMechanism.CalculationsGroup.Children.Add(group);
+
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(null, mocks, "invalidFilePath");
+
+ var nodeData = new StabilityStoneCoverCalculationGroupContext(group,
+ failureMechanism.CalculationsGroup,
+ failureMechanism,
+ assessmentSection);
+ var parentNodeData = new StabilityStoneCoverCalculationGroupContext(failureMechanism.CalculationsGroup,
+ null,
+ failureMechanism,
+ assessmentSection);
+
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+
+ gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder);
+ gui.Stub(g => g.MainWindow).Return(mocks.Stub());
+ mocks.ReplayAll();
+
+ // Call
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl))
+ {
+ // Assert
+ ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroup];
+ ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroup];
+ Assert.IsFalse(validateItem.Enabled);
+ Assert.IsFalse(calculateItem.Enabled);
+ const string message = "Herstellen van de verbinding met de hydraulische belastingendatabase is mislukt. Fout bij het lezen van bestand 'invalidFilePath': het bestand bestaat niet.";
+ Assert.AreEqual(message, calculateItem.ToolTipText);
+ Assert.AreEqual(message, validateItem.ToolTipText);
+ }
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_AllRequiredInputSet_CalculateAllAndValidateAllEnabled()
+ {
+ // Setup
+ string validHydraulicBoundaryDatabasePath = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Common.IO,
+ Path.Combine(nameof(HydraulicBoundaryDatabase), "complete.sqlite"));
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var group = new CalculationGroup();
+
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ group.Children.Add(new StabilityStoneCoverWaveConditionsCalculation());
+ failureMechanism.CalculationsGroup.Children.Add(group);
+
+ var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase
+ {
+ FilePath = validHydraulicBoundaryDatabasePath
+ };
+ HydraulicBoundaryDatabaseTestHelper.SetHydraulicBoundaryLocationConfigurationSettings(hydraulicBoundaryDatabase);
+
+ var assessmentSection = mocks.Stub();
+ assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(hydraulicBoundaryDatabase);
+
+ var nodeData = new StabilityStoneCoverCalculationGroupContext(group,
+ failureMechanism.CalculationsGroup,
+ failureMechanism,
+ assessmentSection);
+ var parentNodeData = new StabilityStoneCoverCalculationGroupContext(failureMechanism.CalculationsGroup,
+ null,
+ failureMechanism,
+ assessmentSection);
+
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+
+ gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder);
+ gui.Stub(g => g.MainWindow).Return(mocks.Stub());
+ mocks.ReplayAll();
+
+ // Call
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl))
+ {
+ // Assert
+ ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroup];
+ ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroup];
+ Assert.IsTrue(validateItem.Enabled);
+ Assert.IsTrue(calculateItem.Enabled);
+ Assert.AreEqual("Voer alle berekeningen binnen deze map met berekeningen uit.", calculateItem.ToolTipText);
+ Assert.AreEqual("Valideer alle berekeningen binnen deze map met berekeningen.", validateItem.ToolTipText);
+ }
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_TwoCalculationsClickOnValidateAllInGroup_ValidationMessagesLogged()
+ {
+ // Setup
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ IAssessmentSection assessmentSection = CreateAssessmentSectionWithHydraulicBoundaryOutput();
+
+ StabilityStoneCoverWaveConditionsCalculation calculationA = GetValidCalculation(assessmentSection.HydraulicBoundaryDatabase.Locations.First());
+ StabilityStoneCoverWaveConditionsCalculation calculationB = GetValidCalculation(assessmentSection.HydraulicBoundaryDatabase.Locations.First());
+
+ var group = new CalculationGroup();
+ group.Children.Add(calculationA);
+ group.Children.Add(calculationB);
+
+ failureMechanism.CalculationsGroup.Children.Add(group);
+ var nodeData = new StabilityStoneCoverCalculationGroupContext(group,
+ failureMechanism.CalculationsGroup,
+ failureMechanism,
+ assessmentSection);
+ var parentNodeData = new StabilityStoneCoverCalculationGroupContext(failureMechanism.CalculationsGroup,
+ null,
+ failureMechanism,
+ assessmentSection);
+
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder);
+ gui.Stub(g => g.MainWindow).Return(mocks.Stub());
+ mocks.ReplayAll();
+
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl))
+ {
+ // Call
+ void Call() => contextMenu.Items[contextMenuValidateAllIndexNestedGroup].PerformClick();
+
+ // Assert
+ TestHelper.AssertLogMessages(Call, m =>
+ {
+ string[] messages = m.ToArray();
+ Assert.AreEqual(4, messages.Length);
+ CalculationServiceTestHelper.AssertValidationStartMessage(messages[0]);
+ CalculationServiceTestHelper.AssertValidationEndMessage(messages[1]);
+ CalculationServiceTestHelper.AssertValidationStartMessage(messages[2]);
+ CalculationServiceTestHelper.AssertValidationEndMessage(messages[3]);
+ });
+ }
+ }
+ }
+
+ [Test]
+ public void ValidateAllViaContextMenuStrip_HydraulicBoundaryDatabaseWithCanUsePreprocessorFalse_NoValidationErrorsLogged()
+ {
+ // Setup
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ IAssessmentSection assessmentSection = CreateAssessmentSectionWithHydraulicBoundaryOutput();
+
+ StabilityStoneCoverWaveConditionsCalculation calculation = GetValidCalculation(assessmentSection.HydraulicBoundaryDatabase.Locations.First());
+
+ var group = new CalculationGroup();
+ group.Children.Add(calculation);
+
+ failureMechanism.CalculationsGroup.Children.Add(group);
+
+ var nodeData = new StabilityStoneCoverCalculationGroupContext(group,
+ failureMechanism.CalculationsGroup,
+ failureMechanism,
+ assessmentSection);
+ var parentNodeData = new StabilityStoneCoverCalculationGroupContext(failureMechanism.CalculationsGroup,
+ null,
+ failureMechanism,
+ assessmentSection);
+
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder);
+ gui.Stub(g => g.MainWindow).Return(mocks.Stub());
+ mocks.ReplayAll();
+
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl))
+ {
+ // Call
+ void Call() => contextMenu.Items[contextMenuValidateAllIndexNestedGroup].PerformClick();
+
+ // Assert
+ TestHelper.AssertLogMessages(Call, m =>
+ {
+ string[] messages = m.ToArray();
+ Assert.AreEqual(2, messages.Length);
+ CalculationServiceTestHelper.AssertValidationStartMessage(messages[0]);
+ CalculationServiceTestHelper.AssertValidationEndMessage(messages[1]);
+ });
+ }
+ }
+ }
+
+ [Test]
+ public void ValidateAllViaContextMenuStrip_HydraulicBoundaryDatabaseWithUsePreprocessorFalse_NoValidationErrorsLogged()
+ {
+ // Setup
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ IAssessmentSection assessmentSection = CreateAssessmentSectionWithHydraulicBoundaryOutput();
+
+ StabilityStoneCoverWaveConditionsCalculation calculation = GetValidCalculation(assessmentSection.HydraulicBoundaryDatabase.Locations.First());
+
+ var group = new CalculationGroup();
+ group.Children.Add(calculation);
+
+ failureMechanism.CalculationsGroup.Children.Add(group);
+
+ assessmentSection.HydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings.CanUsePreprocessor = true;
+ assessmentSection.HydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings.UsePreprocessor = false;
+ assessmentSection.HydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings.PreprocessorDirectory = "InvalidPreprocessorDirectory";
+
+ var nodeData = new StabilityStoneCoverCalculationGroupContext(group,
+ failureMechanism.CalculationsGroup,
+ failureMechanism,
+ assessmentSection);
+ var parentNodeData = new StabilityStoneCoverCalculationGroupContext(failureMechanism.CalculationsGroup,
+ null,
+ failureMechanism,
+ assessmentSection);
+
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder);
+ gui.Stub(g => g.MainWindow).Return(mocks.Stub());
+ mocks.ReplayAll();
+
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl))
+ {
+ // Call
+ void Call() => contextMenu.Items[contextMenuValidateAllIndexNestedGroup].PerformClick();
+
+ // Assert
+ TestHelper.AssertLogMessages(Call, m =>
+ {
+ string[] messages = m.ToArray();
+ Assert.AreEqual(2, messages.Length);
+ CalculationServiceTestHelper.AssertValidationStartMessage(messages[0]);
+ CalculationServiceTestHelper.AssertValidationEndMessage(messages[1]);
+ });
+ }
+ }
+ }
+
+ [Test]
+ public void ValidateAllViaContextMenuStrip_HydraulicBoundaryDatabaseWithUsePreprocessorTrue_NoValidationErrorsLogged()
+ {
+ // Setup
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ IAssessmentSection assessmentSection = CreateAssessmentSectionWithHydraulicBoundaryOutput();
+
+ StabilityStoneCoverWaveConditionsCalculation calculation = GetValidCalculation(assessmentSection.HydraulicBoundaryDatabase.Locations.First());
+
+ var group = new CalculationGroup();
+ group.Children.Add(calculation);
+
+ failureMechanism.CalculationsGroup.Children.Add(group);
+
+ assessmentSection.HydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings.CanUsePreprocessor = true;
+ assessmentSection.HydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings.UsePreprocessor = true;
+ assessmentSection.HydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings.PreprocessorDirectory = TestHelper.GetScratchPadPath();
+
+ var nodeData = new StabilityStoneCoverCalculationGroupContext(group,
+ failureMechanism.CalculationsGroup,
+ failureMechanism,
+ assessmentSection);
+ var parentNodeData = new StabilityStoneCoverCalculationGroupContext(failureMechanism.CalculationsGroup,
+ null,
+ failureMechanism,
+ assessmentSection);
+
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder);
+ gui.Stub(g => g.MainWindow).Return(mocks.Stub());
+ mocks.ReplayAll();
+
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl))
+ {
+ // Call
+ void Call() => contextMenu.Items[contextMenuValidateAllIndexNestedGroup].PerformClick();
+
+ // Assert
+ TestHelper.AssertLogMessages(Call, m =>
+ {
+ string[] messages = m.ToArray();
+ Assert.AreEqual(2, messages.Length);
+ CalculationServiceTestHelper.AssertValidationStartMessage(messages[0]);
+ CalculationServiceTestHelper.AssertValidationEndMessage(messages[1]);
+ });
+ }
+ }
+ }
+
+ [Test]
+ public void ValidateAllViaContextMenuStrip_HydraulicBoundaryDatabaseWithUsePreprocessorTrue_ValidationErrorsLogged()
+ {
+ // Setup
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ IAssessmentSection assessmentSection = CreateAssessmentSectionWithHydraulicBoundaryOutput();
+
+ var calculation = new StabilityStoneCoverWaveConditionsCalculation
+ {
+ Name = "A",
+ InputParameters =
+ {
+ HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(),
+ LowerBoundaryRevetment = (RoundedDouble) 1.0,
+ UpperBoundaryRevetment = (RoundedDouble) 10.0,
+ StepSize = WaveConditionsInputStepSize.One,
+ LowerBoundaryWaterLevels = (RoundedDouble) 1.0,
+ UpperBoundaryWaterLevels = (RoundedDouble) 10.0,
+ Orientation = (RoundedDouble) 0
+ }
+ };
+
+ var group = new CalculationGroup();
+ group.Children.Add(calculation);
+
+ failureMechanism.CalculationsGroup.Children.Add(group);
+
+ assessmentSection.HydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings.CanUsePreprocessor = true;
+ assessmentSection.HydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings.UsePreprocessor = true;
+ assessmentSection.HydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings.PreprocessorDirectory = "InvalidPreprocessorDirectory";
+
+ var nodeData = new StabilityStoneCoverCalculationGroupContext(group,
+ failureMechanism.CalculationsGroup,
+ failureMechanism,
+ assessmentSection);
+ var parentNodeData = new StabilityStoneCoverCalculationGroupContext(failureMechanism.CalculationsGroup,
+ null,
+ failureMechanism,
+ assessmentSection);
+
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder);
+ gui.Stub(g => g.MainWindow).Return(mocks.Stub());
+ mocks.ReplayAll();
+
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl))
+ {
+ // Call
+ void Call() => contextMenu.Items[contextMenuValidateAllIndexNestedGroup].PerformClick();
+
+ // Assert
+ TestHelper.AssertLogMessages(Call, m =>
+ {
+ string[] messages = m.ToArray();
+ Assert.AreEqual(3, messages.Length);
+ CalculationServiceTestHelper.AssertValidationStartMessage(messages[0]);
+ Assert.AreEqual("De bestandsmap waar de preprocessor bestanden opslaat is ongeldig. De bestandsmap bestaat niet.", messages[1]);
+ CalculationServiceTestHelper.AssertValidationEndMessage(messages[2]);
+ });
+ }
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_TwoCalculationsClickOnCalculateAllInGroup_MessagesLogged()
+ {
+ // Setup
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ IAssessmentSection assessmentSection = CreateAssessmentSectionWithHydraulicBoundaryOutput();
+
+ var group = new CalculationGroup();
+ StabilityStoneCoverWaveConditionsCalculation calculationA = GetValidCalculation(assessmentSection.HydraulicBoundaryDatabase.Locations.First());
+ calculationA.Name = "A";
+ StabilityStoneCoverWaveConditionsCalculation calculationB = GetValidCalculation(assessmentSection.HydraulicBoundaryDatabase.Locations.First());
+ calculationB.Name = "B";
+ group.Children.Add(calculationA);
+ group.Children.Add(calculationB);
+
+ failureMechanism.CalculationsGroup.Children.Add(group);
+ var nodeData = new StabilityStoneCoverCalculationGroupContext(group,
+ failureMechanism.CalculationsGroup,
+ failureMechanism,
+ assessmentSection);
+ var parentNodeData = new StabilityStoneCoverCalculationGroupContext(failureMechanism.CalculationsGroup,
+ null,
+ failureMechanism,
+ assessmentSection);
+
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+
+ DialogBoxHandler = (name, wnd) =>
+ {
+ // Expect an activity dialog which is automatically closed
+ };
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ IMainWindow mainWindow = MainWindowTestHelper.CreateMainWindowStub(mocks);
+
+ gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder);
+ gui.Stub(g => g.MainWindow).Return(mainWindow);
+
+ var calculatorFactory = mocks.Stub();
+ calculatorFactory.Stub(cf => cf.CreateWaveConditionsCosineCalculator(Arg.Is.NotNull))
+ .WhenCalled(invocation =>
+ {
+ HydraRingCalculationSettingsTestHelper.AssertHydraRingCalculationSettings(
+ HydraulicBoundaryCalculationSettingsFactory.CreateSettings(assessmentSection.HydraulicBoundaryDatabase),
+ (HydraRingCalculationSettings) invocation.Arguments[0]);
+ })
+ .Return(new TestWaveConditionsCosineCalculator());
+ mocks.ReplayAll();
+
+ using (new HydraRingCalculatorFactoryConfig(calculatorFactory))
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl))
+ {
+ // Call
+ void Call() => contextMenu.Items[contextMenuCalculateAllIndexNestedGroup].PerformClick();
+
+ // Assert
+ TestHelper.AssertLogMessages(Call, m =>
+ {
+ string[] messages = m.ToArray();
+ Assert.AreEqual(56, messages.Length);
+ Assert.AreEqual("Golfcondities berekenen voor 'A' is gestart.", messages[0]);
+ CalculationServiceTestHelper.AssertCalculationStartMessage(messages[3]);
+ CalculationServiceTestHelper.AssertCalculationEndMessage(messages[26]);
+ Assert.AreEqual("Golfcondities berekenen voor 'A' is gelukt.", messages[27]);
+
+ Assert.AreEqual("Golfcondities berekenen voor 'B' is gestart.", messages[28]);
+ CalculationServiceTestHelper.AssertCalculationStartMessage(messages[31]);
+ CalculationServiceTestHelper.AssertCalculationEndMessage(messages[54]);
+ Assert.AreEqual("Golfcondities berekenen voor 'B' is gelukt.", messages[55]);
+ });
+ Assert.AreEqual(3, calculationA.Output.BlocksOutput.Count());
+ Assert.AreEqual(3, calculationA.Output.ColumnsOutput.Count());
+ Assert.AreEqual(3, calculationB.Output.BlocksOutput.Count());
+ Assert.AreEqual(3, calculationB.Output.ColumnsOutput.Count());
+ }
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_NoCalculations_ClearAllOutputItemDisabled()
+ {
+ // Setup
+ var group = new CalculationGroup();
+
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ failureMechanism.CalculationsGroup.Children.Add(group);
+
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(
+ failureMechanism, mocks, validFilePath);
+
+ var nodeData = new StabilityStoneCoverCalculationGroupContext(group,
+ failureMechanism.CalculationsGroup,
+ failureMechanism,
+ assessmentSection);
+ var parentNodeData = new StabilityStoneCoverCalculationGroupContext(failureMechanism.CalculationsGroup,
+ null,
+ failureMechanism,
+ assessmentSection);
+
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var mainWindow = mocks.Stub();
+
+ gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder);
+ gui.Stub(g => g.MainWindow).Return(mainWindow);
+
+ var calculatorFactory = mocks.Stub();
+ mocks.ReplayAll();
+
+ using (new HydraRingCalculatorFactoryConfig(calculatorFactory))
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl))
+ {
+ // Call
+ ToolStripItem clearAllOutputItem = contextMenu.Items[contextMenuClearOutputIndexNestedGroup];
+
+ // Assert
+ Assert.IsFalse(clearAllOutputItem.Enabled);
+ }
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_TwoCalculationsWithoutOutput_ClearAllOutputItemDisabled()
+ {
+ // Setup
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(
+ failureMechanism, mocks, validFilePath);
+
+ var group = new CalculationGroup();
+ StabilityStoneCoverWaveConditionsCalculation calculationA = GetValidCalculation(assessmentSection.HydraulicBoundaryDatabase.Locations.First());
+ StabilityStoneCoverWaveConditionsCalculation calculationB = GetValidCalculation(assessmentSection.HydraulicBoundaryDatabase.Locations.First());
+ group.Children.Add(calculationA);
+ group.Children.Add(calculationB);
+
+ failureMechanism.CalculationsGroup.Children.Add(group);
+ var nodeData = new StabilityStoneCoverCalculationGroupContext(group,
+ failureMechanism.CalculationsGroup,
+ failureMechanism,
+ assessmentSection);
+ var parentNodeData = new StabilityStoneCoverCalculationGroupContext(failureMechanism.CalculationsGroup,
+ null,
+ failureMechanism,
+ assessmentSection);
+
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var mainWindow = mocks.Stub();
+
+ gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder);
+ gui.Stub(g => g.MainWindow).Return(mainWindow);
+ mocks.ReplayAll();
+
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl))
+ {
+ // Call
+ ToolStripItem clearAllOutputItem = contextMenu.Items[contextMenuClearOutputIndexNestedGroup];
+
+ // Assert
+ Assert.IsFalse(clearAllOutputItem.Enabled);
+ }
+ }
+ }
+
+ [Test]
+ [TestCase(true, TestName = "Menu_TwoCalculationsAndOutputClickClearAllOutput_ClearOutputAfterConfirmation(true)")]
+ [TestCase(false, TestName = "Menu_TwoCalculationsAndOutputClickClearAllOutput_ClearOutputAfterConfirmation(false)")]
+ public void ContextMenuStrip_TwoCalculationsWithOutputClickOnClearAllOutput_OutputRemovedForCalculationsAfterConfirmation(bool confirm)
+ {
+ // Setup
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(
+ failureMechanism, mocks, validFilePath);
+
+ var observerA = mocks.StrictMock();
+ var observerB = mocks.StrictMock();
+ if (confirm)
+ {
+ observerA.Expect(o => o.UpdateObserver());
+ observerB.Expect(o => o.UpdateObserver());
+ }
+
+ var group = new CalculationGroup();
+ StabilityStoneCoverWaveConditionsCalculation calculationA = GetValidCalculation(assessmentSection.HydraulicBoundaryDatabase.Locations.First());
+ calculationA.Output = StabilityStoneCoverWaveConditionsOutputTestFactory.Create();
+ StabilityStoneCoverWaveConditionsCalculation calculationB = GetValidCalculation(assessmentSection.HydraulicBoundaryDatabase.Locations.First());
+ calculationB.Output = StabilityStoneCoverWaveConditionsOutputTestFactory.Create();
+ group.Children.Add(calculationA);
+ group.Children.Add(calculationB);
+ calculationA.Attach(observerA);
+ calculationB.Attach(observerB);
+
+ failureMechanism.CalculationsGroup.Children.Add(group);
+ var nodeData = new StabilityStoneCoverCalculationGroupContext(group,
+ failureMechanism.CalculationsGroup,
+ failureMechanism,
+ assessmentSection);
+ var parentNodeData = new StabilityStoneCoverCalculationGroupContext(failureMechanism.CalculationsGroup,
+ null,
+ failureMechanism,
+ assessmentSection);
+
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+
+ DialogBoxHandler = (name, wnd) =>
+ {
+ var dialog = new MessageBoxTester(wnd);
+ if (confirm)
+ {
+ dialog.ClickOk();
+ }
+ else
+ {
+ dialog.ClickCancel();
+ }
+ };
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var mainWindow = mocks.Stub();
+
+ gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder);
+ gui.Stub(g => g.MainWindow).Return(mainWindow);
+
+ var calculatorFactory = mocks.Stub();
+ mocks.ReplayAll();
+
+ using (new HydraRingCalculatorFactoryConfig(calculatorFactory))
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl))
+ {
+ // Call
+ contextMenu.Items[contextMenuClearOutputIndexNestedGroup].PerformClick();
+
+ // Assert
+ if (confirm)
+ {
+ Assert.IsNull(calculationA.Output);
+ Assert.IsNull(calculationB.Output);
+ }
+ }
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_ClickOnAddGroupItem_AddGroupToCalculationGroupAndNotifyObservers()
+ {
+ // Setup
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var assessmentSection = mocks.Stub();
+
+ var group = new CalculationGroup();
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ failureMechanism.CalculationsGroup.Children.Add(group);
+
+ var nodeData = new StabilityStoneCoverCalculationGroupContext(group,
+ failureMechanism.CalculationsGroup,
+ failureMechanism,
+ assessmentSection);
+ var parentNodeData = new StabilityStoneCoverCalculationGroupContext(failureMechanism.CalculationsGroup,
+ null,
+ failureMechanism,
+ assessmentSection);
+
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+
+ gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder);
+ gui.Stub(g => g.MainWindow).Return(mocks.Stub());
+
+ var observer = mocks.StrictMock();
+ observer.Expect(o => o.UpdateObserver());
+ mocks.ReplayAll();
+
+ var calculationItem = new CalculationGroup
+ {
+ Name = "Nieuwe map"
+ };
+ group.Children.Add(calculationItem);
+
+ nodeData.Attach(observer);
+
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl))
+ {
+ // Precondition
+ Assert.AreEqual(1, group.Children.Count);
+
+ // Call
+ contextMenu.Items[contextMenuAddCalculationGroupIndexNestedGroup].PerformClick();
+
+ // Assert
+ Assert.AreEqual(2, group.Children.Count);
+ ICalculationBase newlyAddedItem = group.Children.Last();
+ Assert.IsInstanceOf(newlyAddedItem);
+ Assert.AreEqual("Nieuwe map (1)", newlyAddedItem.Name,
+ "An item with the same name default name already exists, therefore '(1)' needs to be appended.");
+ }
+ }
+ }
+
+ [Test]
+ [TestCase(NormType.SignalFloodingProbability)]
+ [TestCase(NormType.MaximumAllowableFloodingProbability)]
+ public void ContextMenuStrip_ClickOnAddCalculationItem_AddCalculationToCalculationGroupAndNotifyObservers(
+ NormType normType)
+ {
+ // Setup
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+ var group = new CalculationGroup();
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ var assessmentSection = new AssessmentSectionStub
+ {
+ FailureMechanismContribution =
+ {
+ NormativeNorm = normType
+ }
+ };
+ var nodeData = new StabilityStoneCoverCalculationGroupContext(group,
+ null,
+ failureMechanism,
+ assessmentSection);
+ var calculationItem = new StabilityStoneCoverWaveConditionsCalculation
+ {
+ Name = "Nieuwe berekening"
+ };
+ var observer = mocks.StrictMock();
+ observer.Expect(o => o.UpdateObserver());
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder);
+ gui.Stub(g => g.ViewCommands).Return(mocks.Stub());
+ gui.Stub(g => g.MainWindow).Return(mocks.Stub());
+ mocks.ReplayAll();
+
+ group.Children.Add(calculationItem);
+ nodeData.Attach(observer);
+
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl))
+ {
+ // Precondition
+ Assert.AreEqual(1, group.Children.Count);
+
+ // Call
+ contextMenu.Items[contextMenuAddCalculationIndexRootGroup].PerformClick();
+
+ // Assert
+ Assert.AreEqual(2, group.Children.Count);
+ ICalculationBase newlyAddedItem = group.Children.Last();
+ var newCalculationItem = newlyAddedItem as StabilityStoneCoverWaveConditionsCalculation;
+ Assert.IsNotNull(newCalculationItem);
+ Assert.AreEqual("Nieuwe berekening (1)", newlyAddedItem.Name,
+ "An item with the same name default name already exists, therefore '(1)' needs to be appended.");
+ Assert.AreEqual(GetWaterLevelTypeFromNormType(normType), newCalculationItem.InputParameters.WaterLevelType);
+ }
+ }
+ }
+
+ [Test]
+ public void GivenDialogGenerateCalculationButtonClicked_WhenCalculationSelectedAndDialogClosed_ThenUpdateCalculationGroup()
+ {
+ // Given
+ var random = new Random(21);
+ var normType = random.NextEnumValue();
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var existingGroup = new CalculationGroup();
+ var existingCalculation = new StabilityStoneCoverWaveConditionsCalculation();
+ var group = new CalculationGroup
+ {
+ Children =
+ {
+ existingGroup,
+ existingCalculation
+ }
+ };
+
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ var hydraulicBoundaryLocation1 = new TestHydraulicBoundaryLocation();
+ var hydraulicBoundaryLocation2 = new TestHydraulicBoundaryLocation();
+
+ var assessmentSection = new AssessmentSectionStub
+ {
+ FailureMechanismContribution =
+ {
+ NormativeNorm = normType
+ }
+ };
+ assessmentSection.HydraulicBoundaryDatabase.Locations.AddRange(new[]
+ {
+ hydraulicBoundaryLocation1,
+ hydraulicBoundaryLocation2
+ });
+
+ var observer = mocks.StrictMock();
+ observer.Expect(o => o.UpdateObserver());
+ var nodeData = new StabilityStoneCoverCalculationGroupContext(group,
+ null,
+ failureMechanism,
+ assessmentSection);
+
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+ var mainWindow = mocks.Stub();
+ var viewCommands = mocks.StrictMock();
+
+ gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder);
+ gui.Stub(g => g.MainWindow).Return(mainWindow);
+ gui.Stub(g => g.ViewCommands).Return(viewCommands);
+
+ mocks.ReplayAll();
+
+ nodeData.Attach(observer);
+
+ HydraulicBoundaryLocationSelectionDialog dialog = null;
+ DataGridViewControl grid = null;
+ DialogBoxHandler = (name, wnd) =>
+ {
+ dialog = (HydraulicBoundaryLocationSelectionDialog) new FormTester(name).TheObject;
+ grid = (DataGridViewControl) new ControlTester("DataGridViewControl", dialog).TheObject;
+ grid.Rows[0].Cells[0].Value = true;
+ grid.Rows[1].Cells[0].Value = true;
+ new ButtonTester("DoForSelectedButton", dialog).Click();
+ };
+
+ // When
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl))
+ contextMenu.Items[contextMenuAddGenerateCalculationsIndex].PerformClick();
+
+ // Then
+ Assert.AreEqual(4, group.Children.Count);
+ Assert.AreSame(existingGroup, group.Children[0]);
+ Assert.AreSame(existingCalculation, group.Children[1]);
+ Assert.NotNull(dialog);
+ Assert.NotNull(grid);
+
+ WaveConditionsInputWaterLevelType expectedWaveConditionsInputWaterLevelType = GetWaterLevelTypeFromNormType(normType);
+ var firstCalculation = group.Children[2] as StabilityStoneCoverWaveConditionsCalculation;
+ Assert.IsNotNull(firstCalculation);
+ StabilityStoneCoverWaveConditionsInput firstCalculationInputParameters = firstCalculation.InputParameters;
+ Assert.AreSame(hydraulicBoundaryLocation1, firstCalculationInputParameters.HydraulicBoundaryLocation);
+ Assert.AreEqual(expectedWaveConditionsInputWaterLevelType, firstCalculationInputParameters.WaterLevelType);
+
+ var secondCalculation = group.Children[3] as StabilityStoneCoverWaveConditionsCalculation;
+ Assert.IsNotNull(secondCalculation);
+ StabilityStoneCoverWaveConditionsInput secondCalculationInputParameters = secondCalculation.InputParameters;
+ Assert.AreSame(hydraulicBoundaryLocation2, secondCalculationInputParameters.HydraulicBoundaryLocation);
+ Assert.AreEqual(expectedWaveConditionsInputWaterLevelType, secondCalculationInputParameters.WaterLevelType);
+ }
+ }
+
+ [Test]
+ public void GivenDialogGenerateCalculationButtonClicked_WhenCancelButtonClickedAndDialogClosed_ThenCalculationGroupNotUpdated()
+ {
+ // Given
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var group = new CalculationGroup();
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+
+ var assessmentSection = mocks.Stub();
+ assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(new HydraulicBoundaryDatabase
+ {
+ Locations =
+ {
+ new TestHydraulicBoundaryLocation()
+ }
+ });
+
+ var observer = mocks.StrictMock();
+ var nodeData = new StabilityStoneCoverCalculationGroupContext(group,
+ null,
+ failureMechanism,
+ assessmentSection);
+
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+ var mainWindow = mocks.Stub();
+ var viewCommands = mocks.StrictMock();
+
+ gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder);
+ gui.Stub(g => g.MainWindow).Return(mainWindow);
+ gui.Stub(g => g.ViewCommands).Return(viewCommands);
+
+ mocks.ReplayAll();
+
+ nodeData.Attach(observer);
+
+ HydraulicBoundaryLocationSelectionDialog dialog = null;
+ DataGridViewControl grid = null;
+ DialogBoxHandler = (name, wnd) =>
+ {
+ dialog = (HydraulicBoundaryLocationSelectionDialog) new FormTester(name).TheObject;
+ grid = (DataGridViewControl) new ControlTester("DataGridViewControl", dialog).TheObject;
+ grid.Rows[0].Cells[0].Value = true;
+ new ButtonTester("CustomCancelButton", dialog).Click();
+ };
+
+ // When
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl))
+ contextMenu.Items[contextMenuAddGenerateCalculationsIndex].PerformClick();
+
+ // Then
+ Assert.AreEqual(0, group.Children.Count);
+ Assert.NotNull(dialog);
+ Assert.NotNull(grid);
+ }
+ }
+
+ [Test]
+ public void OnNodeRemoved_ParentIsCalculationGroupContainingGroup_RemoveGroupAndNotifyObservers()
+ {
+ // Setup
+ var observer = mocks.StrictMock();
+ observer.Expect(o => o.UpdateObserver());
+
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var group = new CalculationGroup();
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+
+ var nodeData = new StabilityStoneCoverCalculationGroupContext(group,
+ failureMechanism.CalculationsGroup,
+ failureMechanism,
+ assessmentSection);
+
+ failureMechanism.CalculationsGroup.Children.Add(group);
+ var parentNodeData = new StabilityStoneCoverCalculationGroupContext(failureMechanism.CalculationsGroup,
+ null,
+ failureMechanism,
+ assessmentSection);
+ parentNodeData.Attach(observer);
+
+ // Precondition
+ Assert.IsTrue(info.CanRemove(nodeData, parentNodeData));
+
+ // Call
+ info.OnNodeRemoved(nodeData, parentNodeData);
+
+ // Assert
+ CollectionAssert.DoesNotContain(failureMechanism.CalculationsGroup.Children, group);
+ }
+
+ [Test]
+ public void GivenCalculationWithoutOutput_ThenClearOutputItemDisabled()
+ {
+ // Given
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocks);
+
+ var context = new StabilityStoneCoverCalculationGroupContext(failureMechanism.CalculationsGroup,
+ null,
+ failureMechanism,
+ assessmentSection);
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var appFeatureCommandHandler = mocks.Stub();
+ var importHandler = mocks.Stub();
+ importHandler.Stub(ih => ih.GetSupportedImportInfos(context)).Return(Array.Empty());
+ var exportHandler = mocks.Stub();
+ var updateHandler = mocks.Stub();
+ var viewCommands = mocks.Stub();
+ var menuBuilder = new ContextMenuBuilder(appFeatureCommandHandler,
+ importHandler,
+ exportHandler,
+ updateHandler,
+ viewCommands,
+ context,
+ treeViewControl);
+
+ gui.Stub(g => g.ViewCommands).Return(viewCommands);
+ gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilder);
+ gui.Stub(g => g.MainWindow).Return(mocks.Stub());
+ mocks.ReplayAll();
+
+ // When
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl))
+ {
+ // Then
+ TestHelper.AssertContextMenuStripContainsItem(contextMenu,
+ contextMenuAddCalculationIndexRootGroup,
+ "Berekening &toevoegen",
+ "Voeg een nieuwe berekening toe aan deze map met berekeningen.",
+ RiskeerCommonFormsResources.HydraulicCalculationIcon);
+ }
+ }
+ }
+
+ [Test]
+ public void GivenCalculationWithOutput_WhenClearingOutput_ThenClearOutput()
+ {
+ // Given
+ var observer = mocks.Stub();
+ observer.Expect(o => o.UpdateObserver());
+
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ failureMechanism.CalculationsGroup.Attach(observer);
+
+ var context = new StabilityStoneCoverCalculationGroupContext(failureMechanism.CalculationsGroup,
+ null,
+ failureMechanism,
+ new AssessmentSectionStub());
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var appFeatureCommandHandler = mocks.Stub();
+ var importHandler = mocks.Stub();
+ importHandler.Stub(ih => ih.GetSupportedImportInfos(context)).Return(Array.Empty());
+ var exportHandler = mocks.Stub();
+ var updateHandler = mocks.Stub();
+ var viewCommands = mocks.Stub();
+ var menuBuilder = new ContextMenuBuilder(appFeatureCommandHandler,
+ importHandler,
+ exportHandler,
+ updateHandler,
+ viewCommands,
+ context,
+ treeViewControl);
+
+ gui.Stub(g => g.ViewCommands).Return(viewCommands);
+ gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilder);
+ gui.Stub(g => g.MainWindow).Return(mocks.Stub());
+ mocks.ReplayAll();
+
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl))
+ {
+ // When
+ ToolStripItem validateMenuItem = contextMenu.Items[contextMenuAddCalculationIndexRootGroup];
+ validateMenuItem.PerformClick();
+
+ // Then
+ Assert.AreEqual(1, failureMechanism.CalculationsGroup.Children.Count);
+ Assert.IsInstanceOf(failureMechanism.CalculationsGroup.Children[0]);
+ // Check expectancies in TearDown()
+ }
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_CalculationGroupWithCalculationWithForeshoreProfileAndInputOutOfSync_ContextMenuItemUpdateForeshoreProfilesEnabledAndToolTipSet()
+ {
+ // Setup
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocks);
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ var calculation = new StabilityStoneCoverWaveConditionsCalculation
+ {
+ InputParameters =
+ {
+ ForeshoreProfile = new TestForeshoreProfile()
+ }
+ };
+
+ var nodeData = new StabilityStoneCoverCalculationGroupContext(
+ new CalculationGroup
+ {
+ Children =
+ {
+ calculation
+ }
+ },
+ null,
+ failureMechanism,
+ assessmentSection);
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
+ gui.Stub(g => g.MainWindow).Return(mocks.Stub());
+ mocks.ReplayAll();
+
+ calculation.InputParameters.UseBreakWater = true;
+
+ // Call
+ using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl))
+ {
+ // Assert
+ TestHelper.AssertContextMenuStripContainsItem(menu,
+ contextMenuUpdateForeshoreProfileIndexRootGroup,
+ "&Bijwerken voorlandprofielen...",
+ "Alle berekeningen met een voorlandprofiel bijwerken.",
+ RiskeerCommonFormsResources.UpdateItemIcon);
+ }
+ }
+ }
+
+ [Test]
+ public void GivenCalculationWithoutOutputAndWithInputOutOfSync_WhenUpdateForeshoreProfilesClicked_ThenNoInquiryAndCalculationUpdatedAndInputObserverNotified()
+ {
+ // Given
+ var calculationObserver = mocks.StrictMock();
+ var calculationInputObserver = mocks.StrictMock();
+ calculationInputObserver.Expect(o => o.UpdateObserver());
+
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocks);
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+
+ var calculation = new StabilityStoneCoverWaveConditionsCalculation
+ {
+ InputParameters =
+ {
+ ForeshoreProfile = new TestForeshoreProfile(true)
+ }
+ };
+
+ var nodeData = new StabilityStoneCoverCalculationGroupContext(
+ new CalculationGroup
+ {
+ Children =
+ {
+ calculation
+ }
+ },
+ null,
+ failureMechanism,
+ assessmentSection);
+
+ calculation.Attach(calculationObserver);
+ calculation.InputParameters.Attach(calculationInputObserver);
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
+ gui.Stub(g => g.MainWindow).Return(mocks.Stub());
+ mocks.ReplayAll();
+
+ calculation.InputParameters.UseBreakWater = false;
+
+ using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(nodeData, null, treeViewControl))
+ {
+ // When
+ contextMenuStrip.Items[contextMenuUpdateForeshoreProfileIndexRootGroup].PerformClick();
+
+ // Then
+ Assert.IsTrue(calculation.InputParameters.IsForeshoreProfileInputSynchronized);
+ }
+ }
+ }
+
+ public override void Setup()
+ {
+ mocks = new MockRepository();
+ gui = mocks.Stub();
+ plugin = new StabilityStoneCoverPlugin
+ {
+ Gui = gui
+ };
+ info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(StabilityStoneCoverCalculationGroupContext));
+ }
+
+ public override void TearDown()
+ {
+ plugin.Dispose();
+ mocks.VerifyAll();
+
+ base.TearDown();
+ }
+
+ private IAssessmentSection CreateAssessmentSectionWithHydraulicBoundaryOutput()
+ {
+ var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1300001, string.Empty, 0, 0);
+
+ var assessmentSection = new AssessmentSectionStub
+ {
+ HydraulicBoundaryDatabase =
+ {
+ FilePath = validFilePath,
+ Locations =
+ {
+ hydraulicBoundaryLocation
+ }
+ }
+ };
+ HydraulicBoundaryDatabaseTestHelper.SetHydraulicBoundaryLocationConfigurationSettings(assessmentSection.HydraulicBoundaryDatabase);
+
+ assessmentSection.SetHydraulicBoundaryLocationCalculations(new[]
+ {
+ hydraulicBoundaryLocation
+ });
+
+ assessmentSection.WaterLevelCalculationsForLowerLimitNorm.First().Output = new TestHydraulicBoundaryLocationCalculationOutput(9.3);
+
+ return assessmentSection;
+ }
+
+ private static StabilityStoneCoverWaveConditionsCalculation GetValidCalculation(HydraulicBoundaryLocation hydraulicBoundaryLocation)
+ {
+ return new StabilityStoneCoverWaveConditionsCalculation
+ {
+ InputParameters =
+ {
+ HydraulicBoundaryLocation = hydraulicBoundaryLocation,
+ WaterLevelType = WaveConditionsInputWaterLevelType.MaximumAllowableFloodingProbability,
+ ForeshoreProfile = new TestForeshoreProfile(true),
+ UseForeshore = true,
+ UseBreakWater = true,
+ StepSize = WaveConditionsInputStepSize.Half,
+ LowerBoundaryRevetment = (RoundedDouble) 4,
+ UpperBoundaryRevetment = (RoundedDouble) 10,
+ UpperBoundaryWaterLevels = (RoundedDouble) 8,
+ LowerBoundaryWaterLevels = (RoundedDouble) 7.1
+ }
+ };
+ }
+
+ private static WaveConditionsInputWaterLevelType GetWaterLevelTypeFromNormType(NormType normType)
+ {
+ switch (normType)
+ {
+ case NormType.MaximumAllowableFloodingProbability:
+ return WaveConditionsInputWaterLevelType.MaximumAllowableFloodingProbability;
+ case NormType.SignalFloodingProbability:
+ return WaveConditionsInputWaterLevelType.SignalFloodingProbability;
+ default:
+ throw new NotSupportedException();
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/TreeNodeInfos/StabilityStoneCoverHydraulicLoadsContextTreeNodeInfoTest.cs
===================================================================
diff -u -rce73d815b0583615c74550ba004fd553202b43fe -r55786df7f5abe3fbda43470b70929ed7aeaee54f
--- Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/TreeNodeInfos/StabilityStoneCoverHydraulicLoadsContextTreeNodeInfoTest.cs (.../StabilityStoneCoverHydraulicLoadsContextTreeNodeInfoTest.cs) (revision ce73d815b0583615c74550ba004fd553202b43fe)
+++ Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/TreeNodeInfos/StabilityStoneCoverHydraulicLoadsContextTreeNodeInfoTest.cs (.../StabilityStoneCoverHydraulicLoadsContextTreeNodeInfoTest.cs) (revision 55786df7f5abe3fbda43470b70929ed7aeaee54f)
@@ -178,7 +178,7 @@
var calculationsInputComments = (Comment) inputsFolder.Contents.ElementAt(1);
Assert.AreSame(failureMechanism.CalculationsInputComments, calculationsInputComments);
- var hydraulicBoundariesCalculationGroup = (StabilityStoneCoverWaveConditionsCalculationGroupContext) children[1];
+ var hydraulicBoundariesCalculationGroup = (StabilityStoneCoverCalculationGroupContext) children[1];
Assert.AreSame(failureMechanism.CalculationsGroup, hydraulicBoundariesCalculationGroup.WrappedData);
Assert.IsNull(hydraulicBoundariesCalculationGroup.Parent);
Assert.AreSame(failureMechanism, hydraulicBoundariesCalculationGroup.FailureMechanism);
Index: Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs
===================================================================
diff -u -rce73d815b0583615c74550ba004fd553202b43fe -r55786df7f5abe3fbda43470b70929ed7aeaee54f
--- Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision ce73d815b0583615c74550ba004fd553202b43fe)
+++ Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision 55786df7f5abe3fbda43470b70929ed7aeaee54f)
@@ -334,7 +334,7 @@
failureMechanism,
assessmentSection);
- var parentContext = new StabilityStoneCoverWaveConditionsCalculationGroupContext(failureMechanism.CalculationsGroup,
+ var parentContext = new StabilityStoneCoverCalculationGroupContext(failureMechanism.CalculationsGroup,
null,
failureMechanism,
assessmentSection);
@@ -364,7 +364,7 @@
failureMechanism,
assessmentSection);
- var parentContext = new StabilityStoneCoverWaveConditionsCalculationGroupContext(failureMechanism.CalculationsGroup,
+ var parentContext = new StabilityStoneCoverCalculationGroupContext(failureMechanism.CalculationsGroup,
null,
failureMechanism,
assessmentSection);
@@ -398,7 +398,7 @@
failureMechanism,
assessmentSection);
- var parentContext = new StabilityStoneCoverWaveConditionsCalculationGroupContext(failureMechanism.CalculationsGroup,
+ var parentContext = new StabilityStoneCoverCalculationGroupContext(failureMechanism.CalculationsGroup,
null,
failureMechanism,
assessmentSection);
Fisheye: Tag 55786df7f5abe3fbda43470b70929ed7aeaee54f refers to a dead (removed) revision in file `Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/ViewInfos/StabilityStoneCoverWaveConditionsInputViewInfoTest.cs
===================================================================
diff -u -rce73d815b0583615c74550ba004fd553202b43fe -r55786df7f5abe3fbda43470b70929ed7aeaee54f
--- Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/ViewInfos/StabilityStoneCoverWaveConditionsInputViewInfoTest.cs (.../StabilityStoneCoverWaveConditionsInputViewInfoTest.cs) (revision ce73d815b0583615c74550ba004fd553202b43fe)
+++ Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/ViewInfos/StabilityStoneCoverWaveConditionsInputViewInfoTest.cs (.../StabilityStoneCoverWaveConditionsInputViewInfoTest.cs) (revision 55786df7f5abe3fbda43470b70929ed7aeaee54f)
@@ -183,7 +183,7 @@
protected override ICalculationContext GetCalculationGroupContextWithCalculation()
{
- return new StabilityStoneCoverWaveConditionsCalculationGroupContext(
+ return new StabilityStoneCoverCalculationGroupContext(
new CalculationGroup
{
Children =