Index: Riskeer/Integration/src/Riskeer.Integration.Forms/PresentationObjects/HydraulicBoundaryDataContext.cs
===================================================================
diff -u
--- Riskeer/Integration/src/Riskeer.Integration.Forms/PresentationObjects/HydraulicBoundaryDataContext.cs (revision 0)
+++ Riskeer/Integration/src/Riskeer.Integration.Forms/PresentationObjects/HydraulicBoundaryDataContext.cs (revision 48727c54a1ff6a81a910dca143daeba5530a84a2)
@@ -0,0 +1,56 @@
+// Copyright (C) Stichting Deltares 2022. 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.Hydraulics;
+using Riskeer.Integration.Data;
+
+namespace Riskeer.Integration.Forms.PresentationObjects
+{
+ ///
+ /// Presentation object for all data required to configure an instance of .
+ ///
+ public class HydraulicBoundaryDataContext : ObservableWrappedObjectContextBase
+ {
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The that the belongs to.
+ /// The assessment section that the belongs to.
+ /// Thrown when any parameter is null.
+ public HydraulicBoundaryDataContext(HydraulicBoundaryData wrappedData, AssessmentSection assessmentSection)
+ : base(wrappedData)
+ {
+ if (assessmentSection == null)
+ {
+ throw new ArgumentNullException(nameof(assessmentSection));
+ }
+
+ AssessmentSection = assessmentSection;
+ }
+
+ ///
+ /// Gets the assessment section that the context belongs to.
+ ///
+ public AssessmentSection AssessmentSection { get; }
+ }
+}
\ No newline at end of file
Fisheye: Tag 48727c54a1ff6a81a910dca143daeba5530a84a2 refers to a dead (removed) revision in file `Riskeer/Integration/src/Riskeer.Integration.Forms/PresentationObjects/HydraulicBoundaryDatabaseContext.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs
===================================================================
diff -u -r8339953df3276b6c7b4a3d9f5a278e4c19e85be3 -r48727c54a1ff6a81a910dca143daeba5530a84a2
--- Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs (.../RiskeerPlugin.cs) (revision 8339953df3276b6c7b4a3d9f5a278e4c19e85be3)
+++ Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs (.../RiskeerPlugin.cs) (revision 48727c54a1ff6a81a910dca143daeba5530a84a2)
@@ -237,7 +237,7 @@
{
CreateInstance = data => new BackgroundDataProperties(data)
};
- yield return new PropertyInfo
+ yield return new PropertyInfo
{
CreateInstance = context => new HydraulicBoundaryDatabaseProperties(
context.WrappedData,
@@ -560,7 +560,7 @@
VerifyUpdates = context => VerifyForeshoreProfileUpdates(context, Resources.RiskeerPlugin_VerifyForeshoreProfileUpdates_When_importing_ForeshoreProfile_definitions_assigned_to_calculations_output_will_be_cleared_confirm)
};
- yield return new ImportInfo
+ yield return new ImportInfo
{
Name = RiskeerCommonDataResources.HydraulicBoundaryConditions_DisplayName,
Image = RiskeerCommonFormsResources.DatabaseIcon,
@@ -587,7 +587,7 @@
RiskeerCommonIOResources.Shape_file_filter_Description))
};
- yield return new ExportInfo
+ yield return new ExportInfo
{
Name = context => RiskeerCommonDataResources.HydraulicBoundaryConditions_DisplayName,
Extension = RiskeerCommonIOResources.Zip_file_filter_Extension,
@@ -857,15 +857,15 @@
ContextMenuStrip = CategoryTreeFolderContextMenu
};
- yield return new TreeNodeInfo
+ yield return new TreeNodeInfo
{
Text = hydraulicBoundaryDatabase => RiskeerCommonDataResources.HydraulicBoundaryConditions_DisplayName,
Image = hydraulicBoundaryDatabase => RiskeerCommonFormsResources.GeneralFolderIcon,
ForeColor = context => context.WrappedData.IsLinked()
? Color.FromKnownColor(KnownColor.ControlText)
: Color.FromKnownColor(KnownColor.GrayText),
- ChildNodeObjects = HydraulicBoundaryDatabaseChildNodeObjects,
- ContextMenuStrip = HydraulicBoundaryDatabaseContextMenuStrip
+ ChildNodeObjects = HydraulicBoundaryDataContextChildNodeObjects,
+ ContextMenuStrip = HydraulicBoundaryDataContextMenuStrip
};
yield return new TreeNodeInfo
@@ -1742,7 +1742,7 @@
return new object[]
{
- new HydraulicBoundaryDatabaseContext(assessmentSection.HydraulicBoundaryData, assessmentSection),
+ new HydraulicBoundaryDataContext(assessmentSection.HydraulicBoundaryData, assessmentSection),
new StabilityStoneCoverHydraulicLoadsStateFailureMechanismContext(assessmentSection.StabilityStoneCover, assessmentSection),
new WaveImpactAsphaltCoverHydraulicLoadsStateFailureMechanismContext(assessmentSection.WaveImpactAsphaltCover, assessmentSection),
new GrassCoverErosionOutwardsHydraulicLoadsStateFailureMechanismContext(assessmentSection.GrassCoverErosionOutwards, assessmentSection),
@@ -2376,7 +2376,7 @@
#region HydraulicBoundaryDatabase TreeNodeInfo
- private static object[] HydraulicBoundaryDatabaseChildNodeObjects(HydraulicBoundaryDatabaseContext nodeData)
+ private static object[] HydraulicBoundaryDataContextChildNodeObjects(HydraulicBoundaryDataContext nodeData)
{
if (nodeData.WrappedData.IsLinked())
{
@@ -2404,7 +2404,7 @@
}
}
- private ContextMenuStrip HydraulicBoundaryDatabaseContextMenuStrip(HydraulicBoundaryDatabaseContext nodeData, object parentData, TreeViewControl treeViewControl)
+ private ContextMenuStrip HydraulicBoundaryDataContextMenuStrip(HydraulicBoundaryDataContext nodeData, object parentData, TreeViewControl treeViewControl)
{
var calculateAllItem = new StrictContextMenuItem(
RiskeerCommonFormsResources.Calculate_All,
Index: Riskeer/Integration/test/Riskeer.Integration.Forms.Test/PresentationObjects/HydraulicBoundaryDataContextTest.cs
===================================================================
diff -u
--- Riskeer/Integration/test/Riskeer.Integration.Forms.Test/PresentationObjects/HydraulicBoundaryDataContextTest.cs (revision 0)
+++ Riskeer/Integration/test/Riskeer.Integration.Forms.Test/PresentationObjects/HydraulicBoundaryDataContextTest.cs (revision 48727c54a1ff6a81a910dca143daeba5530a84a2)
@@ -0,0 +1,61 @@
+// Copyright (C) Stichting Deltares 2022. 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 NUnit.Framework;
+using Riskeer.Common.Data.AssessmentSection;
+using Riskeer.Common.Data.Hydraulics;
+using Riskeer.Integration.Data;
+using Riskeer.Integration.Forms.PresentationObjects;
+
+namespace Riskeer.Integration.Forms.Test.PresentationObjects
+{
+ [TestFixture]
+ public class HydraulicBoundaryDataContextTest
+ {
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+
+ // Call
+ var context = new HydraulicBoundaryDataContext(assessmentSection.HydraulicBoundaryData, assessmentSection);
+
+ // Assert
+ Assert.IsInstanceOf>(context);
+ Assert.AreSame(assessmentSection.HydraulicBoundaryData, context.WrappedData);
+ Assert.AreSame(assessmentSection, context.AssessmentSection);
+ }
+
+ [Test]
+ public void Constructor_AssessmentSectionNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => new HydraulicBoundaryDataContext(new HydraulicBoundaryData(), null);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("assessmentSection", exception.ParamName);
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 48727c54a1ff6a81a910dca143daeba5530a84a2 refers to a dead (removed) revision in file `Riskeer/Integration/test/Riskeer.Integration.Forms.Test/PresentationObjects/HydraulicBoundaryDatabaseContextTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/ExportInfos/HydraulicBoundaryDataContextExportInfoTest.cs
===================================================================
diff -u
--- Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/ExportInfos/HydraulicBoundaryDataContextExportInfoTest.cs (revision 0)
+++ Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/ExportInfos/HydraulicBoundaryDataContextExportInfoTest.cs (revision 48727c54a1ff6a81a910dca143daeba5530a84a2)
@@ -0,0 +1,153 @@
+// Copyright (C) Stichting Deltares 2022. 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.Plugin;
+using NUnit.Framework;
+using Riskeer.Common.Data.AssessmentSection;
+using Riskeer.Common.Data.Hydraulics;
+using Riskeer.Integration.Data;
+using Riskeer.Integration.Forms.PresentationObjects;
+using Riskeer.Integration.IO.Exporters;
+using CoreGuiResources = Core.Gui.Properties.Resources;
+
+namespace Riskeer.Integration.Plugin.Test.ExportInfos
+{
+ [TestFixture]
+ public class HydraulicBoundaryDataContextExportInfoTest
+ {
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ using (var plugin = new RiskeerPlugin())
+ {
+ // Call
+ ExportInfo info = GetExportInfo(plugin);
+
+ // Assert
+ Assert.IsNotNull(info.Name);
+ Assert.AreEqual("zip", 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 Name_Always_ReturnsName()
+ {
+ // Setup
+ using (var plugin = new RiskeerPlugin())
+ {
+ ExportInfo info = GetExportInfo(plugin);
+
+ // Call
+ string name = info.Name(null);
+
+ // Assert
+ Assert.AreEqual("Hydraulische belastingen", name);
+ }
+ }
+
+ [Test]
+ public void CreateFileExporter_Always_ReturnFileExporter()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ HydraulicBoundaryData =
+ {
+ Locations =
+ {
+ new HydraulicBoundaryLocation(1, "test", 0, 0)
+ }
+ }
+ };
+ var context = new HydraulicBoundaryDataContext(assessmentSection.HydraulicBoundaryData, assessmentSection);
+ const string filePath = "test";
+
+ using (var plugin = new RiskeerPlugin())
+ {
+ ExportInfo info = GetExportInfo(plugin);
+
+ // Call
+ IFileExporter fileExporter = info.CreateFileExporter(context, filePath);
+
+ // Assert
+ Assert.IsInstanceOf(fileExporter);
+ }
+ }
+
+ [Test]
+ public void IsEnabled_HydraulicBoundaryDatabaseNotLinked_ReturnFalse()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+ var context = new HydraulicBoundaryDataContext(assessmentSection.HydraulicBoundaryData, assessmentSection);
+
+ using (var plugin = new RiskeerPlugin())
+ {
+ ExportInfo info = GetExportInfo(plugin);
+
+ // Call
+ bool isEnabled = info.IsEnabled(context);
+
+ // Assert
+ Assert.IsFalse(isEnabled);
+ }
+ }
+
+ [Test]
+ public void IsEnabled_HydraulicBoundaryDatabaseLinked_ReturnTrue()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ HydraulicBoundaryData =
+ {
+ FilePath = "databaseFile"
+ }
+ };
+ var context = new HydraulicBoundaryDataContext(assessmentSection.HydraulicBoundaryData, assessmentSection);
+
+ using (var plugin = new RiskeerPlugin())
+ {
+ ExportInfo info = GetExportInfo(plugin);
+
+ // Call
+ bool isEnabled = info.IsEnabled(context);
+
+ // Assert
+ Assert.IsTrue(isEnabled);
+ }
+ }
+
+ private static ExportInfo GetExportInfo(RiskeerPlugin plugin)
+ {
+ return plugin.GetExportInfos().First(ei => ei.DataType == typeof(HydraulicBoundaryDataContext));
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 48727c54a1ff6a81a910dca143daeba5530a84a2 refers to a dead (removed) revision in file `Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/ExportInfos/HydraulicBoundaryDatabaseContextExportInfoTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/ImportInfos/HydraulicBoundaryDataContextImportInfoTest.cs
===================================================================
diff -u
--- Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/ImportInfos/HydraulicBoundaryDataContextImportInfoTest.cs (revision 0)
+++ Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/ImportInfos/HydraulicBoundaryDataContextImportInfoTest.cs (revision 48727c54a1ff6a81a910dca143daeba5530a84a2)
@@ -0,0 +1,132 @@
+// Copyright (C) Stichting Deltares 2022. 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.IO;
+using Core.Common.TestUtil;
+using Core.Common.Util;
+using Core.Gui;
+using Core.Gui.Commands;
+using Core.Gui.Plugin;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Riskeer.Common.Data.AssessmentSection;
+using Riskeer.Common.Data.Hydraulics;
+using Riskeer.Common.Plugin.TestUtil;
+using Riskeer.Integration.Data;
+using Riskeer.Integration.Forms.PresentationObjects;
+using Riskeer.Integration.IO.Importers;
+using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources;
+
+namespace Riskeer.Integration.Plugin.Test.ImportInfos
+{
+ [TestFixture]
+ public class HydraulicBoundaryDataContextImportInfoTest
+ {
+ private MockRepository mocks;
+ private ImportInfo importInfo;
+ private RiskeerPlugin plugin;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks = new MockRepository();
+ IGui gui = StubFactory.CreateGuiStub(mocks);
+ gui.Stub(g => g.ViewCommands).Return(mocks.Stub());
+ mocks.ReplayAll();
+
+ plugin = new RiskeerPlugin
+ {
+ Gui = gui
+ };
+ importInfo = plugin.GetImportInfos().First(i => i.DataType == typeof(HydraulicBoundaryDataContext));
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ plugin.Dispose();
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Name_Always_ReturnExpectedName()
+ {
+ // Call
+ string name = importInfo.Name;
+
+ // Assert
+ Assert.AreEqual("Hydraulische belastingen", 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.DatabaseIcon, image);
+ }
+
+ [Test]
+ public void FileFilterGenerator_Always_ReturnExpectedFileFilter()
+ {
+ // Call
+ FileFilterGenerator fileFilterGenerator = importInfo.FileFilterGenerator;
+
+ // Assert
+ Assert.AreEqual("Hydraulische belastingendatabase (*.sqlite)|*.sqlite", fileFilterGenerator.Filter);
+ }
+
+ [Test]
+ public void CreateFileImporter_Always_ReturnFileImporter()
+ {
+ // Setup
+ mocks = new MockRepository();
+ var gui = mocks.Stub();
+ gui.Stub(g => g.ViewCommands).Return(mocks.Stub());
+ gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+ mocks.ReplayAll();
+
+ var importTarget = new HydraulicBoundaryDataContext(new HydraulicBoundaryData(), new AssessmentSection(AssessmentSectionComposition.Dike));
+
+ // Call
+ IFileImporter importer = importInfo.CreateFileImporter(importTarget, "");
+
+ // Assert
+ Assert.IsInstanceOf(importer);
+ mocks.VerifyAll();
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 48727c54a1ff6a81a910dca143daeba5530a84a2 refers to a dead (removed) revision in file `Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/ImportInfos/HydraulicBoundaryDatabaseContextImportInfoTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/PropertyInfos/HydraulicBoundaryDatabasePropertyInfoTest.cs
===================================================================
diff -u -r8339953df3276b6c7b4a3d9f5a278e4c19e85be3 -r48727c54a1ff6a81a910dca143daeba5530a84a2
--- Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/PropertyInfos/HydraulicBoundaryDatabasePropertyInfoTest.cs (.../HydraulicBoundaryDatabasePropertyInfoTest.cs) (revision 8339953df3276b6c7b4a3d9f5a278e4c19e85be3)
+++ Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/PropertyInfos/HydraulicBoundaryDatabasePropertyInfoTest.cs (.../HydraulicBoundaryDatabasePropertyInfoTest.cs) (revision 48727c54a1ff6a81a910dca143daeba5530a84a2)
@@ -57,7 +57,7 @@
public void Initialized_Always_ExpectedPropertiesSet()
{
// Assert
- Assert.AreEqual(typeof(HydraulicBoundaryDatabaseContext), info.DataType);
+ Assert.AreEqual(typeof(HydraulicBoundaryDataContext), info.DataType);
}
[Test]
@@ -73,7 +73,7 @@
plugin.Gui = gui;
var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
- var context = new HydraulicBoundaryDatabaseContext(assessmentSection.HydraulicBoundaryData, assessmentSection);
+ var context = new HydraulicBoundaryDataContext(assessmentSection.HydraulicBoundaryData, assessmentSection);
// Call
IObjectProperties objectProperties = info.CreateInstance(context);
Index: Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/RiskeerPluginTest.cs
===================================================================
diff -u -r8339953df3276b6c7b4a3d9f5a278e4c19e85be3 -r48727c54a1ff6a81a910dca143daeba5530a84a2
--- Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/RiskeerPluginTest.cs (.../RiskeerPluginTest.cs) (revision 8339953df3276b6c7b4a3d9f5a278e4c19e85be3)
+++ Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/RiskeerPluginTest.cs (.../RiskeerPluginTest.cs) (revision 48727c54a1ff6a81a910dca143daeba5530a84a2)
@@ -234,7 +234,7 @@
PluginTestHelper.AssertPropertyInfoDefined(
propertyInfos,
- typeof(HydraulicBoundaryDatabaseContext),
+ typeof(HydraulicBoundaryDataContext),
typeof(HydraulicBoundaryDatabaseProperties));
PluginTestHelper.AssertPropertyInfoDefined(
@@ -361,7 +361,7 @@
// Assert
Assert.AreEqual(9, exportInfos.Length);
Assert.IsTrue(exportInfos.Any(ei => ei.DataType == typeof(ReferenceLineContext)));
- Assert.IsTrue(exportInfos.Any(ei => ei.DataType == typeof(HydraulicBoundaryDatabaseContext)));
+ Assert.IsTrue(exportInfos.Any(ei => ei.DataType == typeof(HydraulicBoundaryDataContext)));
Assert.IsTrue(exportInfos.Any(ei => ei.DataType == typeof(AssemblyResultsContext)));
Assert.IsTrue(exportInfos.Any(ei => ei.DataType == typeof(WaterLevelCalculationsForUserDefinedTargetProbabilityContext)));
Assert.IsTrue(exportInfos.Any(ei => ei.DataType == typeof(WaveHeightCalculationsForUserDefinedTargetProbabilityContext)));
@@ -589,7 +589,7 @@
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(WaterPressureAsphaltCoverFailureMechanismContext)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(CategoryTreeFolder)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionsContext)));
- Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HydraulicBoundaryDatabaseContext)));
+ Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HydraulicBoundaryDataContext)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(WaterLevelCalculationsForNormTargetProbabilitiesGroupContext)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(WaterLevelCalculationsForNormTargetProbabilityContext)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(WaterLevelCalculationsForUserDefinedTargetProbabilitiesGroupContext)));
@@ -690,7 +690,7 @@
Assert.IsTrue(importInfos.Any(i => i.DataType == typeof(ReferenceLineContext)));
Assert.IsTrue(importInfos.Any(i => i.DataType == typeof(FailureMechanismSectionsContext)));
Assert.IsTrue(importInfos.Any(i => i.DataType == typeof(ForeshoreProfilesContext)));
- Assert.IsTrue(importInfos.Any(i => i.DataType == typeof(HydraulicBoundaryDatabaseContext)));
+ Assert.IsTrue(importInfos.Any(i => i.DataType == typeof(HydraulicBoundaryDataContext)));
}
}
Index: Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/TreeNodeInfos/HydraulicBoundaryDataContextTreeNodeInfoTest.cs
===================================================================
diff -u
--- Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/TreeNodeInfos/HydraulicBoundaryDataContextTreeNodeInfoTest.cs (revision 0)
+++ Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/TreeNodeInfos/HydraulicBoundaryDataContextTreeNodeInfoTest.cs (revision 48727c54a1ff6a81a910dca143daeba5530a84a2)
@@ -0,0 +1,865 @@
+// Copyright (C) Stichting Deltares 2022. 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.Collections.Generic;
+using System.Drawing;
+using System.IO;
+using System.Linq;
+using System.Threading;
+using System.Windows.Forms;
+using Core.Common.Base;
+using Core.Common.Base.Storage;
+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.Forms.ViewHost;
+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.Hydraulics;
+using Riskeer.Common.Data.TestUtil;
+using Riskeer.Common.Data.TestUtil.IllustrationPoints;
+using Riskeer.Common.Forms.PresentationObjects;
+using Riskeer.Common.Plugin.TestUtil;
+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.Integration.Data;
+using Riskeer.Integration.Forms.PresentationObjects;
+using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources;
+
+namespace Riskeer.Integration.Plugin.Test.TreeNodeInfos
+{
+ [TestFixture]
+ public class HydraulicBoundaryDataContextTreeNodeInfoTest : NUnitFormTest
+ {
+ private const int contextMenuImportHydraulicBoundaryDatabaseIndex = 0;
+ private const int contextMenuCalculateAllIndex = 3;
+ private const int contextMenuClearIllustrationPointsIndex = 5;
+
+ private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Integration.Forms, "HydraulicBoundaryDatabase");
+
+ private MockRepository mocks;
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ using (var plugin = new RiskeerPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+
+ // Assert
+ Assert.IsNotNull(info.Text);
+ Assert.IsNotNull(info.ForeColor);
+ Assert.IsNotNull(info.Image);
+ Assert.IsNotNull(info.ContextMenuStrip);
+ Assert.IsNull(info.EnsureVisibleOnCreate);
+ Assert.IsNull(info.ExpandOnCreate);
+ Assert.IsNotNull(info.ChildNodeObjects);
+ Assert.IsNull(info.CanRename);
+ Assert.IsNull(info.OnNodeRenamed);
+ Assert.IsNull(info.CanRemove);
+ Assert.IsNull(info.OnNodeRemoved);
+ Assert.IsNull(info.CanCheck);
+ Assert.IsNull(info.CheckedState);
+ Assert.IsNull(info.OnNodeChecked);
+ Assert.IsNull(info.CanDrag);
+ Assert.IsNull(info.CanDrop);
+ Assert.IsNull(info.CanInsert);
+ Assert.IsNull(info.OnDrop);
+ }
+ }
+
+ [Test]
+ public void Text_Always_ReturnsSetName()
+ {
+ // Setup
+ const string name = "Hydraulische belastingen";
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+
+ var context = new HydraulicBoundaryDataContext(assessmentSection.HydraulicBoundaryData,
+ assessmentSection);
+
+ using (var plugin = new RiskeerPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+
+ // Call
+ string text = info.Text(context);
+
+ // Assert
+ Assert.AreEqual(name, text);
+ }
+ }
+
+ [Test]
+ public void Image_Always_ReturnsGeneralFolderIcon()
+ {
+ // Setup
+ using (var plugin = new RiskeerPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+
+ // Call
+ Image image = info.Image(null);
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.GeneralFolderIcon, image);
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+ var context = new HydraulicBoundaryDataContext(assessmentSection.HydraulicBoundaryData,
+ assessmentSection);
+
+ var menuBuilder = mocks.StrictMock();
+ using (mocks.Ordered())
+ {
+ menuBuilder.Expect(mb => mb.AddImportItem(null, null, null)).IgnoreArguments().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.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())
+ {
+ IGui gui = StubFactory.CreateGuiStub(mocks);
+ gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilder);
+ gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub());
+ mocks.ReplayAll();
+
+ using (var plugin = new RiskeerPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+
+ plugin.Gui = gui;
+
+ // Call
+ info.ContextMenuStrip(context, null, treeViewControl);
+ }
+ }
+
+ // Assert
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ContextMenuStrip_Always_AddImportItem()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+ var context = new HydraulicBoundaryDataContext(assessmentSection.HydraulicBoundaryData,
+ assessmentSection);
+
+ var applicationFeatureCommands = mocks.Stub();
+ var importCommandHandler = mocks.Stub();
+ importCommandHandler.Stub(ich => ich.GetSupportedImportInfos(null)).IgnoreArguments().Return(new[]
+ {
+ new ImportInfo()
+ });
+ var exportCommandHandler = mocks.Stub();
+ var updateCommandHandler = mocks.Stub();
+ var viewCommands = mocks.Stub();
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var builder = new ContextMenuBuilder(applicationFeatureCommands,
+ importCommandHandler,
+ exportCommandHandler,
+ updateCommandHandler,
+ viewCommands,
+ context,
+ treeViewControl);
+
+ IGui gui = StubFactory.CreateGuiStub(mocks);
+ gui.Stub(g => g.Get(context, treeViewControl)).Return(builder);
+ gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub());
+ mocks.ReplayAll();
+
+ using (var plugin = new RiskeerPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+ plugin.Gui = gui;
+
+ // Call
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, assessmentSection, treeViewControl))
+ {
+ TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuImportHydraulicBoundaryDatabaseIndex,
+ "&Koppel aan database...",
+ "Koppel aan hydraulische belastingendatabase.",
+ RiskeerCommonFormsResources.DatabaseIcon);
+ }
+ }
+ }
+
+ // Assert
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ForeColor_HydraulicBoundaryDatabaseNotLinked_ReturnDisabledColor()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+ var hydraulicBoundaryDataContext = new HydraulicBoundaryDataContext(assessmentSection.HydraulicBoundaryData,
+ assessmentSection);
+
+ using (var plugin = new RiskeerPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+
+ // Call
+ Color color = info.ForeColor(hydraulicBoundaryDataContext);
+
+ // Assert
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), color);
+ }
+ }
+
+ [Test]
+ public void ForeColor_HydraulicBoundaryDatabaseLinked_ReturnEnabledColor()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ HydraulicBoundaryData =
+ {
+ FilePath = "databaseFile"
+ }
+ };
+ var hydraulicBoundaryDataContext = new HydraulicBoundaryDataContext(assessmentSection.HydraulicBoundaryData,
+ assessmentSection);
+
+ using (var plugin = new RiskeerPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+
+ // Call
+ Color color = info.ForeColor(hydraulicBoundaryDataContext);
+
+ // Assert
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), color);
+ }
+ }
+
+ [Test]
+ public void ChildNodeObjects_HydraulicBoundaryDatabaseNotLinked_ReturnsEmpty()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+ var hydraulicBoundaryDataContext = new HydraulicBoundaryDataContext(assessmentSection.HydraulicBoundaryData,
+ assessmentSection);
+
+ using (var plugin = new RiskeerPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+
+ // Call
+ object[] objects = info.ChildNodeObjects(hydraulicBoundaryDataContext).ToArray();
+
+ // Assert
+ Assert.AreEqual(0, objects.Length);
+ }
+ }
+
+ [Test]
+ public void ChildNodeObjects_HydraulicBoundaryDatabaseLinked_ReturnsChildrenOfData()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ HydraulicBoundaryData =
+ {
+ FilePath = "databaseFile"
+ }
+ };
+ var hydraulicBoundaryDataContext = new HydraulicBoundaryDataContext(assessmentSection.HydraulicBoundaryData,
+ assessmentSection);
+
+ using (var plugin = new RiskeerPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+
+ // Call
+ object[] objects = info.ChildNodeObjects(hydraulicBoundaryDataContext).ToArray();
+
+ // Assert
+ Assert.AreEqual(3, objects.Length);
+
+ var waterLevelCalculationsForNormTargetProbabilitiesGroupContext = (WaterLevelCalculationsForNormTargetProbabilitiesGroupContext) objects[0];
+ Assert.AreSame(assessmentSection.HydraulicBoundaryData.Locations, waterLevelCalculationsForNormTargetProbabilitiesGroupContext.WrappedData);
+ Assert.AreSame(assessmentSection, waterLevelCalculationsForNormTargetProbabilitiesGroupContext.AssessmentSection);
+
+ var waterLevelCalculationsForUserDefinedTargetProbabilitiesGroupContext = (WaterLevelCalculationsForUserDefinedTargetProbabilitiesGroupContext) objects[1];
+ Assert.AreSame(assessmentSection.WaterLevelCalculationsForUserDefinedTargetProbabilities, waterLevelCalculationsForUserDefinedTargetProbabilitiesGroupContext.WrappedData);
+ Assert.AreSame(assessmentSection, waterLevelCalculationsForUserDefinedTargetProbabilitiesGroupContext.AssessmentSection);
+
+ var waveHeightCalculationsForUserDefinedTargetProbabilitiesGroupContext = (WaveHeightCalculationsForUserDefinedTargetProbabilitiesGroupContext) objects[2];
+ Assert.AreSame(assessmentSection.WaveHeightCalculationsForUserDefinedTargetProbabilities, waveHeightCalculationsForUserDefinedTargetProbabilitiesGroupContext.WrappedData);
+ Assert.AreSame(assessmentSection, waveHeightCalculationsForUserDefinedTargetProbabilitiesGroupContext.AssessmentSection);
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_HydraulicBoundaryDatabaseNotLinked_ContextMenuItemCalculateAllDisabledAndTooltipSet()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+
+ var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation("locationName");
+ assessmentSection.SetHydraulicBoundaryLocationCalculations(new[]
+ {
+ hydraulicBoundaryLocation
+ });
+
+ var nodeData = new HydraulicBoundaryDataContext(assessmentSection.HydraulicBoundaryData, assessmentSection);
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ IGui gui = StubFactory.CreateGuiStub(mocks);
+ gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub());
+ gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
+ mocks.ReplayAll();
+
+ using (var plugin = new RiskeerPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+
+ plugin.Gui = gui;
+
+ // Call
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl))
+ {
+ // Assert
+ ToolStripItem contextMenuItem = contextMenu.Items[contextMenuCalculateAllIndex];
+
+ Assert.AreEqual("Alles be&rekenen", contextMenuItem.Text);
+ StringAssert.Contains("Er is geen hydraulische belastingendatabase geïmporteerd.", contextMenuItem.ToolTipText);
+ TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.CalculateAllIcon, contextMenuItem.Image);
+ Assert.IsFalse(contextMenuItem.Enabled);
+ }
+ }
+ }
+
+ mocks.VerifyAll(); // Expect no calls on arguments
+ }
+
+ [Test]
+ public void ContextMenuStrip_HydraulicBoundaryDatabaseLinkedToInvalidFile_ContextMenuItemCalculateAllDisabledAndTooltipSet()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ HydraulicBoundaryData =
+ {
+ FilePath = "invalidFilePath"
+ }
+ };
+
+ var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation("locationName");
+ assessmentSection.SetHydraulicBoundaryLocationCalculations(new[]
+ {
+ hydraulicBoundaryLocation
+ });
+
+ var nodeData = new HydraulicBoundaryDataContext(assessmentSection.HydraulicBoundaryData, assessmentSection);
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ IGui gui = StubFactory.CreateGuiStub(mocks);
+ gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub());
+ gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
+ mocks.ReplayAll();
+
+ using (var plugin = new RiskeerPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+
+ plugin.Gui = gui;
+
+ // Call
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl))
+ {
+ // Assert
+ ToolStripItem contextMenuItem = contextMenu.Items[contextMenuCalculateAllIndex];
+
+ Assert.AreEqual("Alles be&rekenen", contextMenuItem.Text);
+ StringAssert.Contains("Herstellen van de verbinding met de hydraulische belastingendatabase is mislukt.", contextMenuItem.ToolTipText);
+ TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.CalculateAllIcon, contextMenuItem.Image);
+ Assert.IsFalse(contextMenuItem.Enabled);
+ }
+ }
+ }
+
+ mocks.VerifyAll(); // Expect no calls on arguments
+ }
+
+ [Test]
+ [TestCaseSource(nameof(GetHydraulicBoundaryLocationCalculations))]
+ public void ContextMenuStrip_HydraulicBoundaryLocationCalculationsWithIllustrationPoints_ContextMenuItemClearAllIllustrationPointsEnabledAndTooltipSet(
+ Func getHydraulicBoundaryLocationCalculationFunc)
+ {
+ // Setup
+ var random = new Random(21);
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+
+ SetHydraulicBoundaryLocationCalculationsForUserDefinedTargetProbabilities(assessmentSection);
+
+ assessmentSection.SetHydraulicBoundaryLocationCalculations(new[]
+ {
+ new TestHydraulicBoundaryLocation()
+ });
+
+ HydraulicBoundaryLocationCalculation calculation = getHydraulicBoundaryLocationCalculationFunc(assessmentSection);
+ calculation.Output = new TestHydraulicBoundaryLocationCalculationOutput(random.NextDouble(), new TestGeneralResultSubMechanismIllustrationPoint());
+
+ var nodeData = new HydraulicBoundaryDataContext(assessmentSection.HydraulicBoundaryData, assessmentSection);
+
+ var mockRepository = new MockRepository();
+ using (var treeViewControl = new TreeViewControl())
+ {
+ IGui gui = StubFactory.CreateGuiStub(mocks);
+ gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
+ gui.Stub(cmp => cmp.MainWindow).Return(mockRepository.Stub());
+ mockRepository.ReplayAll();
+
+ using (var plugin = new RiskeerPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+
+ plugin.Gui = gui;
+
+ // Call
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl))
+ {
+ // Assert
+ ToolStripItem contextMenuItem = contextMenu.Items[contextMenuClearIllustrationPointsIndex];
+
+ Assert.AreEqual("Wis alle illustratiepunten...", contextMenuItem.Text);
+ Assert.AreEqual("Wis alle berekende illustratiepunten.", contextMenuItem.ToolTipText);
+ TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.ClearIllustrationPointsIcon, contextMenuItem.Image);
+ Assert.IsTrue(contextMenuItem.Enabled);
+ }
+ }
+ }
+
+ mockRepository.VerifyAll(); // Expect no calls on arguments
+ }
+
+ [Test]
+ public void ContextMenuStrip_HydraulicBoundaryLocationCalculationsWithoutIllustrationPoints_ContextMenuItemClearAllIllustrationPointsDisabled()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+ assessmentSection.SetHydraulicBoundaryLocationCalculations(new[]
+ {
+ new TestHydraulicBoundaryLocation()
+ });
+
+ var nodeData = new HydraulicBoundaryDataContext(assessmentSection.HydraulicBoundaryData, assessmentSection);
+
+ var mockRepository = new MockRepository();
+ using (var treeViewControl = new TreeViewControl())
+ {
+ IGui gui = StubFactory.CreateGuiStub(mocks);
+ gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
+ gui.Stub(cmp => cmp.MainWindow).Return(mockRepository.Stub());
+ mockRepository.ReplayAll();
+
+ using (var plugin = new RiskeerPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+
+ plugin.Gui = gui;
+
+ // Call
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl))
+ {
+ // Assert
+ ToolStripItem contextMenuItem = contextMenu.Items[contextMenuClearIllustrationPointsIndex];
+ Assert.IsFalse(contextMenuItem.Enabled);
+ }
+ }
+ }
+
+ mockRepository.VerifyAll(); // Expect no calls on arguments
+ }
+
+ [Test]
+ [SetCulture("nl-NL")]
+ [Apartment(ApartmentState.STA)]
+ public void GivenValidCalculations_WhenCalculatingAllFromContextMenu_ThenAllCalculationsScheduled()
+ {
+ // Given
+ string validFilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite");
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ HydraulicBoundaryData =
+ {
+ FilePath = validFilePath
+ }
+ };
+ HydraulicBoundaryDataTestHelper.SetHydraulicLocationConfigurationSettings(assessmentSection.HydraulicBoundaryData);
+
+ SetHydraulicBoundaryLocationCalculationsForUserDefinedTargetProbabilities(assessmentSection);
+
+ var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation("locationName");
+ assessmentSection.SetHydraulicBoundaryLocationCalculations(new[]
+ {
+ hydraulicBoundaryLocation
+ });
+
+ var context = new HydraulicBoundaryDataContext(assessmentSection.HydraulicBoundaryData, assessmentSection);
+
+ using (var treeViewControl = new TreeViewControl())
+ using (var plugin = new RiskeerPlugin())
+ {
+ IMainWindow mainWindow = MainWindowTestHelper.CreateMainWindowStub(mocks);
+
+ IGui gui = StubFactory.CreateGuiStub(mocks);
+ gui.Stub(g => g.MainWindow).Return(mainWindow);
+ gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
+ gui.Stub(g => g.DocumentViewController).Return(mocks.Stub());
+ gui.Stub(g => g.ViewCommands).Return(mocks.Stub());
+ gui.Stub(g => g.ProjectStore).Return(mocks.Stub());
+
+ var calculatorFactory = mocks.Stub();
+ var designWaterLevelCalculator = new TestDesignWaterLevelCalculator
+ {
+ Converged = false
+ };
+ var waveHeightCalculator = new TestWaveHeightCalculator
+ {
+ Converged = false
+ };
+
+ HydraulicBoundaryCalculationSettings expectedSettings = HydraulicBoundaryCalculationSettingsFactory.CreateSettings(assessmentSection.HydraulicBoundaryData);
+ calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(Arg.Is.NotNull))
+ .WhenCalled(invocation =>
+ {
+ HydraRingCalculationSettingsTestHelper.AssertHydraRingCalculationSettings(
+ expectedSettings, (HydraRingCalculationSettings) invocation.Arguments[0]);
+ })
+ .Return(designWaterLevelCalculator)
+ .Repeat
+ .Times(4);
+ calculatorFactory.Expect(cf => cf.CreateWaveHeightCalculator(Arg.Is.NotNull))
+ .WhenCalled(invocation =>
+ {
+ HydraRingCalculationSettingsTestHelper.AssertHydraRingCalculationSettings(
+ expectedSettings, (HydraRingCalculationSettings) invocation.Arguments[0]);
+ }).Return(waveHeightCalculator)
+ .Repeat
+ .Times(2);
+ mocks.ReplayAll();
+
+ TreeNodeInfo info = GetInfo(plugin);
+ plugin.Gui = gui;
+ plugin.Activate();
+
+ DialogBoxHandler = (name, wnd) =>
+ {
+ // Expect an activity dialog which is automatically closed
+ };
+
+ using (ContextMenuStrip contextMenuAdapter = info.ContextMenuStrip(context, null, treeViewControl))
+ using (new HydraRingCalculatorFactoryConfig(calculatorFactory))
+ {
+ // When
+ void Call() => contextMenuAdapter.Items[contextMenuCalculateAllIndex].PerformClick();
+
+ // Then
+ TestHelper.AssertLogMessages(Call, messages =>
+ {
+ string[] msgs = messages.ToArray();
+ Assert.AreEqual(48, msgs.Length);
+
+ const string designWaterLevelCalculationTypeDisplayName = "Waterstand";
+ const string designWaterLevelCalculationDisplayName = "Waterstand berekening";
+
+ HydraulicBoundaryLocationCalculationActivityLogTestHelper.AssertHydraulicBoundaryLocationCalculationMessages(
+ hydraulicBoundaryLocation.Name, designWaterLevelCalculationTypeDisplayName, designWaterLevelCalculationDisplayName,
+ "1/30.000",
+ msgs, 0);
+ HydraulicBoundaryLocationCalculationActivityLogTestHelper.AssertHydraulicBoundaryLocationCalculationMessages(
+ hydraulicBoundaryLocation.Name, designWaterLevelCalculationTypeDisplayName, designWaterLevelCalculationDisplayName,
+ "1/30.000 (1)",
+ msgs, 8);
+ HydraulicBoundaryLocationCalculationActivityLogTestHelper.AssertHydraulicBoundaryLocationCalculationMessages(
+ hydraulicBoundaryLocation.Name, designWaterLevelCalculationTypeDisplayName, designWaterLevelCalculationDisplayName,
+ "1/10",
+ msgs, 16);
+ HydraulicBoundaryLocationCalculationActivityLogTestHelper.AssertHydraulicBoundaryLocationCalculationMessages(
+ hydraulicBoundaryLocation.Name, designWaterLevelCalculationTypeDisplayName, designWaterLevelCalculationDisplayName,
+ "1/100",
+ msgs, 24);
+
+ const string waveHeightCalculationTypeDisplayName = "Golfhoogte";
+ const string waveHeightCalculationDisplayName = "Golfhoogte berekening";
+
+ HydraulicBoundaryLocationCalculationActivityLogTestHelper.AssertHydraulicBoundaryLocationCalculationMessages(
+ hydraulicBoundaryLocation.Name, waveHeightCalculationTypeDisplayName, waveHeightCalculationDisplayName,
+ "1/40",
+ msgs, 32);
+ HydraulicBoundaryLocationCalculationActivityLogTestHelper.AssertHydraulicBoundaryLocationCalculationMessages(
+ hydraulicBoundaryLocation.Name, waveHeightCalculationTypeDisplayName, waveHeightCalculationDisplayName,
+ "1/400",
+ msgs, 40);
+ });
+ }
+ }
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [TestCaseSource(nameof(GetHydraulicBoundaryLocationCalculations))]
+ [Apartment(ApartmentState.STA)]
+ public void GivenCalculationsWithIllustrationPoints_WhenClearIllustrationPointsClickedAndDoNotContinue_ThenInquiryAndIllustrationPointsNotCleared(
+ Func getHydraulicLocationCalculationFunc)
+ {
+ // Given
+ var random = new Random(21);
+ AssessmentSection assessmentSection = GetAssessmentSectionWithHydraulicBoundaryLocationCalculationOutputs();
+ HydraulicBoundaryLocationCalculation calculation = getHydraulicLocationCalculationFunc(assessmentSection);
+ calculation.Output = new TestHydraulicBoundaryLocationCalculationOutput(random.NextDouble(), new TestGeneralResultSubMechanismIllustrationPoint());
+
+ HydraulicBoundaryLocationCalculation[] calculationsWithOutput = GetAllHydraulicLocationCalculationsWithOutput(assessmentSection).ToArray();
+
+ var messageBoxText = "";
+ DialogBoxHandler = (name, wnd) =>
+ {
+ var helper = new MessageBoxTester(wnd);
+ messageBoxText = helper.Text;
+
+ helper.ClickCancel();
+ };
+
+ var context = new HydraulicBoundaryDataContext(assessmentSection.HydraulicBoundaryData, assessmentSection);
+
+ var mockRepository = new MockRepository();
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var affectedCalculationObserver = mockRepository.StrictMock();
+
+ IGui gui = StubFactory.CreateGuiStub(mocks);
+ gui.Stub(cmp => cmp.MainWindow).Return(mockRepository.Stub());
+ gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
+ mockRepository.ReplayAll();
+
+ calculation.Attach(affectedCalculationObserver);
+
+ using (var plugin = new RiskeerPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+ plugin.Gui = gui;
+
+ using (ContextMenuStrip contextMenuAdapter = info.ContextMenuStrip(context, null, treeViewControl))
+ {
+ // When
+ contextMenuAdapter.Items[contextMenuClearIllustrationPointsIndex].PerformClick();
+
+ // Then
+ const string expectedMessage = "Weet u zeker dat u alle berekende illustratiepunten bij 'Hydraulische belastingen' wilt wissen?";
+ Assert.AreEqual(expectedMessage, messageBoxText);
+
+ Assert.IsTrue(calculationsWithOutput.All(calc => calc.HasOutput));
+ Assert.IsTrue(calculation.Output.HasGeneralResult);
+ }
+ }
+ }
+
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ [TestCaseSource(nameof(GetHydraulicBoundaryLocationCalculations))]
+ [Apartment(ApartmentState.STA)]
+ public void GivenCalculationsWithIllustrationPoints_WhenClearIllustrationPointsClickedAndContinue_ThenInquiryAndIllustrationPointsCleared(
+ Func getHydraulicLocationCalculationFunc)
+ {
+ // Given
+ var random = new Random(21);
+ AssessmentSection assessmentSection = GetAssessmentSectionWithHydraulicBoundaryLocationCalculationOutputs();
+ HydraulicBoundaryLocationCalculation calculation = getHydraulicLocationCalculationFunc(assessmentSection);
+ calculation.Output = new TestHydraulicBoundaryLocationCalculationOutput(random.NextDouble(), new TestGeneralResultSubMechanismIllustrationPoint());
+
+ HydraulicBoundaryLocationCalculation[] calculationsWithOutput = GetAllHydraulicLocationCalculationsWithOutput(assessmentSection).ToArray();
+ HydraulicBoundaryLocationCalculation unaffectedCalculation = calculationsWithOutput.First(calc => !calc.Output.HasGeneralResult);
+
+ var messageBoxText = "";
+ DialogBoxHandler = (name, wnd) =>
+ {
+ var helper = new MessageBoxTester(wnd);
+ messageBoxText = helper.Text;
+
+ helper.ClickOk();
+ };
+
+ var context = new HydraulicBoundaryDataContext(assessmentSection.HydraulicBoundaryData, assessmentSection);
+
+ var mockRepository = new MockRepository();
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var affectedCalculationObserver = mockRepository.StrictMock();
+ affectedCalculationObserver.Expect(o => o.UpdateObserver());
+ var unAffectedCalculationObserver = mockRepository.StrictMock();
+
+ IGui gui = StubFactory.CreateGuiStub(mocks);
+ gui.Stub(cmp => cmp.MainWindow).Return(mockRepository.Stub());
+ gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
+ mockRepository.ReplayAll();
+
+ calculation.Attach(affectedCalculationObserver);
+ unaffectedCalculation.Attach(unAffectedCalculationObserver);
+
+ using (var plugin = new RiskeerPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+ plugin.Gui = gui;
+
+ using (ContextMenuStrip contextMenuAdapter = info.ContextMenuStrip(context, null, treeViewControl))
+ {
+ // When
+ contextMenuAdapter.Items[contextMenuClearIllustrationPointsIndex].PerformClick();
+
+ // Then
+ const string expectedMessage = "Weet u zeker dat u alle berekende illustratiepunten bij 'Hydraulische belastingen' wilt wissen?";
+ Assert.AreEqual(expectedMessage, messageBoxText);
+
+ Assert.IsTrue(calculationsWithOutput.All(calc => calc.HasOutput));
+ Assert.IsFalse(calculation.Output.HasGeneralResult);
+ }
+ }
+ }
+
+ mockRepository.VerifyAll();
+ }
+
+ private static void SetHydraulicBoundaryLocationCalculationsForUserDefinedTargetProbabilities(IAssessmentSection assessmentSection)
+ {
+ assessmentSection.WaterLevelCalculationsForUserDefinedTargetProbabilities.AddRange(
+ new[]
+ {
+ new HydraulicBoundaryLocationCalculationsForTargetProbability(0.1),
+ new HydraulicBoundaryLocationCalculationsForTargetProbability(0.01)
+ });
+
+ assessmentSection.WaveHeightCalculationsForUserDefinedTargetProbabilities.AddRange(
+ new[]
+ {
+ new HydraulicBoundaryLocationCalculationsForTargetProbability(0.025),
+ new HydraulicBoundaryLocationCalculationsForTargetProbability(0.0025)
+ });
+ }
+
+ private static AssessmentSection GetAssessmentSectionWithHydraulicBoundaryLocationCalculationOutputs()
+ {
+ var random = new Random(21);
+ var assessmentSection = new AssessmentSection(random.NextEnumValue());
+
+ SetHydraulicBoundaryLocationCalculationsForUserDefinedTargetProbabilities(assessmentSection);
+
+ assessmentSection.SetHydraulicBoundaryLocationCalculations(new[]
+ {
+ new TestHydraulicBoundaryLocation(),
+ new TestHydraulicBoundaryLocation()
+ });
+
+ SetHydraulicBoundaryLocationOutput(assessmentSection.WaterLevelCalculationsForSignalFloodingProbability);
+ SetHydraulicBoundaryLocationOutput(assessmentSection.WaterLevelCalculationsForMaximumAllowableFloodingProbability);
+
+ SetHydraulicBoundaryLocationOutput(assessmentSection.WaterLevelCalculationsForUserDefinedTargetProbabilities[0].HydraulicBoundaryLocationCalculations);
+ SetHydraulicBoundaryLocationOutput(assessmentSection.WaterLevelCalculationsForUserDefinedTargetProbabilities[1].HydraulicBoundaryLocationCalculations);
+
+ SetHydraulicBoundaryLocationOutput(assessmentSection.WaveHeightCalculationsForUserDefinedTargetProbabilities[0].HydraulicBoundaryLocationCalculations);
+ SetHydraulicBoundaryLocationOutput(assessmentSection.WaveHeightCalculationsForUserDefinedTargetProbabilities[1].HydraulicBoundaryLocationCalculations);
+
+ return assessmentSection;
+ }
+
+ private static void SetHydraulicBoundaryLocationOutput(IEnumerable calculations)
+ {
+ var random = new Random(21);
+ foreach (HydraulicBoundaryLocationCalculation calculation in calculations)
+ {
+ calculation.Output = new TestHydraulicBoundaryLocationCalculationOutput(random.NextDouble());
+ }
+ }
+
+ public override void Setup()
+ {
+ mocks = new MockRepository();
+ }
+
+ private static IEnumerable GetAllHydraulicLocationCalculationsWithOutput(IAssessmentSection assessmentSection)
+ {
+ return assessmentSection.WaterLevelCalculationsForSignalFloodingProbability
+ .Concat(assessmentSection.WaterLevelCalculationsForMaximumAllowableFloodingProbability)
+ .Concat(assessmentSection.WaterLevelCalculationsForUserDefinedTargetProbabilities.SelectMany(tp => tp.HydraulicBoundaryLocationCalculations))
+ .Concat(assessmentSection.WaveHeightCalculationsForUserDefinedTargetProbabilities.SelectMany(tp => tp.HydraulicBoundaryLocationCalculations))
+ .Where(calc => calc.HasOutput);
+ }
+
+ private static IEnumerable GetHydraulicBoundaryLocationCalculations()
+ {
+ yield return new TestCaseData(new Func(
+ section => section.WaterLevelCalculationsForSignalFloodingProbability.First()));
+ yield return new TestCaseData(new Func(
+ section => section.WaterLevelCalculationsForMaximumAllowableFloodingProbability.First()));
+ yield return new TestCaseData(new Func(
+ section => section.WaterLevelCalculationsForUserDefinedTargetProbabilities[0].HydraulicBoundaryLocationCalculations.First()));
+ yield return new TestCaseData(new Func(
+ section => section.WaterLevelCalculationsForUserDefinedTargetProbabilities[1].HydraulicBoundaryLocationCalculations.First()));
+ yield return new TestCaseData(new Func(
+ section => section.WaveHeightCalculationsForUserDefinedTargetProbabilities[0].HydraulicBoundaryLocationCalculations.First()));
+ yield return new TestCaseData(new Func(
+ section => section.WaveHeightCalculationsForUserDefinedTargetProbabilities[1].HydraulicBoundaryLocationCalculations.First()));
+ }
+
+ private static TreeNodeInfo GetInfo(RiskeerPlugin plugin)
+ {
+ return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(HydraulicBoundaryDataContext));
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 48727c54a1ff6a81a910dca143daeba5530a84a2 refers to a dead (removed) revision in file `Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/TreeNodeInfos/HydraulicBoundaryDatabaseContextTreeNodeInfoTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/TreeNodeInfos/HydraulicLoadsStateRootContextTreeNodeInfoTest.cs
===================================================================
diff -u -r8339953df3276b6c7b4a3d9f5a278e4c19e85be3 -r48727c54a1ff6a81a910dca143daeba5530a84a2
--- Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/TreeNodeInfos/HydraulicLoadsStateRootContextTreeNodeInfoTest.cs (.../HydraulicLoadsStateRootContextTreeNodeInfoTest.cs) (revision 8339953df3276b6c7b4a3d9f5a278e4c19e85be3)
+++ Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/TreeNodeInfos/HydraulicLoadsStateRootContextTreeNodeInfoTest.cs (.../HydraulicLoadsStateRootContextTreeNodeInfoTest.cs) (revision 48727c54a1ff6a81a910dca143daeba5530a84a2)
@@ -167,9 +167,9 @@
// Assert
Assert.AreEqual(5, objects.Length);
- var hydraulicBoundaryDatabaseContext = (HydraulicBoundaryDatabaseContext) objects[0];
- Assert.AreSame(assessmentSection.HydraulicBoundaryData, hydraulicBoundaryDatabaseContext.WrappedData);
- Assert.AreSame(assessmentSection, hydraulicBoundaryDatabaseContext.AssessmentSection);
+ var hydraulicBoundaryDataContext = (HydraulicBoundaryDataContext) objects[0];
+ Assert.AreSame(assessmentSection.HydraulicBoundaryData, hydraulicBoundaryDataContext.WrappedData);
+ Assert.AreSame(assessmentSection, hydraulicBoundaryDataContext.AssessmentSection);
var stabilityStoneCoverFailureMechanismContext = (StabilityStoneCoverFailureMechanismContext) objects[1];
Assert.AreSame(assessmentSection.StabilityStoneCover, stabilityStoneCoverFailureMechanismContext.WrappedData);