Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PresentationObjects/StabilityPointStructuresCalculationGroupContext.cs
===================================================================
diff -u -r065af7e201b59ec19a17c42e9d772f5e86b31338 -r066a3be5face22192c18ef36c33eed0a93953a3c
--- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PresentationObjects/StabilityPointStructuresCalculationGroupContext.cs (.../StabilityPointStructuresCalculationGroupContext.cs) (revision 065af7e201b59ec19a17c42e9d772f5e86b31338)
+++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PresentationObjects/StabilityPointStructuresCalculationGroupContext.cs (.../StabilityPointStructuresCalculationGroupContext.cs) (revision 066a3be5face22192c18ef36c33eed0a93953a3c)
@@ -20,8 +20,10 @@
// All rights reserved.
using System;
+using System.Collections.Generic;
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Common.Data.Calculation;
+using Ringtoets.Common.Data.DikeProfiles;
using Ringtoets.Common.Forms.PresentationObjects;
using Ringtoets.StabilityPointStructures.Data;
@@ -44,6 +46,28 @@
public StabilityPointStructuresCalculationGroupContext(CalculationGroup calculationsGroup,
StabilityPointStructuresFailureMechanism failureMechanism,
IAssessmentSection assessmentSection)
- : base(calculationsGroup, failureMechanism, assessmentSection) {}
+ : base(calculationsGroup, failureMechanism, assessmentSection) { }
+
+ ///
+ /// Gets the available foreshore profiles.
+ ///
+ public IEnumerable AvailableForeshoreProfiles
+ {
+ get
+ {
+ return FailureMechanism.ForeshoreProfiles;
+ }
+ }
+
+ ///
+ /// Gets the available stability point structures.
+ ///
+ public IEnumerable AvailableStructures
+ {
+ get
+ {
+ return FailureMechanism.StabilityPointStructures;
+ }
+ }
}
}
\ No newline at end of file
Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/StabilityPointStructuresPlugin.cs
===================================================================
diff -u -r48eac104ea815699b299e93b512b6498e8cb92ec -r066a3be5face22192c18ef36c33eed0a93953a3c
--- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/StabilityPointStructuresPlugin.cs (.../StabilityPointStructuresPlugin.cs) (revision 48eac104ea815699b299e93b512b6498e8cb92ec)
+++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/StabilityPointStructuresPlugin.cs (.../StabilityPointStructuresPlugin.cs) (revision 066a3be5face22192c18ef36c33eed0a93953a3c)
@@ -38,6 +38,7 @@
using Ringtoets.Common.Forms.ChangeHandlers;
using Ringtoets.Common.Forms.ExportInfos;
using Ringtoets.Common.Forms.Helpers;
+using Ringtoets.Common.Forms.ImportInfos;
using Ringtoets.Common.Forms.PresentationObjects;
using Ringtoets.Common.Forms.TreeNodeInfos;
using Ringtoets.Common.Service;
@@ -196,6 +197,14 @@
RingtoetsCommonIOResources.Shape_file_filter_Description),
IsEnabled = context => context.AssessmentSection.ReferenceLine != null
};
+
+ yield return RingtoetsImportInfoFactory.CreateCalculationConfigurationImportInfo(
+ (context, filePath) => new StabilityPointStructuresCalculationConfigurationImporter(
+ filePath,
+ context.WrappedData,
+ context.AvailableHydraulicBoundaryLocations,
+ context.AvailableForeshoreProfiles,
+ context.AvailableStructures));
}
public override IEnumerable GetExportInfos()
@@ -491,7 +500,8 @@
var builder = new RingtoetsContextMenuBuilder(Gui.Get(context, treeViewControl));
bool isNestedGroup = parentData is StabilityPointStructuresCalculationGroupContext;
- builder.AddExportItem()
+ builder.AddImportItem()
+ .AddExportItem()
.AddSeparator();
if (!isNestedGroup)
Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PresentationObjects/StabilityPointStructuresCalculationGroupContextTest.cs
===================================================================
diff -u -r4eba092cb591f9f164f1e22f5b2bba25b148dda5 -r066a3be5face22192c18ef36c33eed0a93953a3c
--- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PresentationObjects/StabilityPointStructuresCalculationGroupContextTest.cs (.../StabilityPointStructuresCalculationGroupContextTest.cs) (revision 4eba092cb591f9f164f1e22f5b2bba25b148dda5)
+++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PresentationObjects/StabilityPointStructuresCalculationGroupContextTest.cs (.../StabilityPointStructuresCalculationGroupContextTest.cs) (revision 066a3be5face22192c18ef36c33eed0a93953a3c)
@@ -52,6 +52,8 @@
Assert.AreSame(calculationGroup, groupContext.WrappedData);
Assert.AreSame(failureMechanism, groupContext.FailureMechanism);
Assert.AreSame(assessmentSection, groupContext.AssessmentSection);
+ Assert.AreSame(failureMechanism.ForeshoreProfiles, groupContext.AvailableForeshoreProfiles);
+ Assert.AreSame(failureMechanism.StabilityPointStructures, groupContext.AvailableStructures);
mockRepository.VerifyAll();
}
}
Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/ImportInfos/StabilityPointStructuresCalculationGroupContextImportInfoTest.cs
===================================================================
diff -u
--- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/ImportInfos/StabilityPointStructuresCalculationGroupContextImportInfoTest.cs (revision 0)
+++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/ImportInfos/StabilityPointStructuresCalculationGroupContextImportInfoTest.cs (revision 066a3be5face22192c18ef36c33eed0a93953a3c)
@@ -0,0 +1,122 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Linq;
+using Core.Common.Base.IO;
+using Core.Common.Gui;
+using Core.Common.Gui.Plugin;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.Calculation;
+using Ringtoets.StabilityPointStructures.Data;
+using Ringtoets.StabilityPointStructures.Forms.PresentationObjects;
+using Ringtoets.StabilityPointStructures.IO.Configurations;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.StabilityPointStructures.Plugin.Test.ImportInfos
+{
+ [TestFixture]
+ public class StabilityPointStructuresCalculationGroupContextImportInfoTest
+ {
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ using (var plugin = new StabilityPointStructuresPlugin())
+ {
+ // Call
+ ImportInfo info = GetImportInfo(plugin);
+
+ // Assert
+ Assert.IsNotNull(info.CreateFileImporter);
+ Assert.IsNotNull(info.IsEnabled);
+ Assert.AreEqual("Ringtoets berekeningenconfiguratie", info.Name);
+ Assert.AreEqual("Algemeen", info.Category);
+ TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GeneralFolderIcon, info.Image);
+ Assert.IsNotNull(info.FileFilterGenerator);
+ }
+ }
+
+ [Test]
+ public void CreateFileImporter_Always_ReturnFileImporter()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var context = new StabilityPointStructuresCalculationGroupContext(new CalculationGroup(),
+ new StabilityPointStructuresFailureMechanism(),
+ assessmentSection);
+
+ using (var plugin = new StabilityPointStructuresPlugin())
+ {
+ ImportInfo info = GetImportInfo(plugin);
+
+ // Call
+ IFileImporter fileImporter = info.CreateFileImporter(context, "test");
+
+ // Assert
+ Assert.IsInstanceOf(fileImporter);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void FileFilterGenerator_Always_ReturnFileFilter()
+ {
+ // Setup
+ using (var plugin = new StabilityPointStructuresPlugin())
+ {
+ ImportInfo info = GetImportInfo(plugin);
+
+ // Call
+ FileFilterGenerator fileFilterGenerator = info.FileFilterGenerator;
+
+ // Assert
+ Assert.AreEqual("Ringtoets berekeningenconfiguratie (*.xml)|*.xml", fileFilterGenerator.Filter);
+ }
+ }
+
+ [Test]
+ public void IsEnabled_Always_ReturnsTrue()
+ {
+ // Setup
+ using (var plugin = new StabilityPointStructuresPlugin())
+ {
+ ImportInfo info = GetImportInfo(plugin);
+
+ // Call
+ bool isEnabled = info.IsEnabled(null);
+
+ // Assert
+ Assert.IsTrue(isEnabled);
+ }
+ }
+
+ private static ImportInfo GetImportInfo(StabilityPointStructuresPlugin plugin)
+ {
+ return plugin.GetImportInfos().First(ei => ei.DataType == typeof(StabilityPointStructuresCalculationGroupContext));
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/Ringtoets.StabilityPointStructures.Plugin.Test.csproj
===================================================================
diff -u -rd6e6041931d39b07ebb06bd0919a5d338736704e -r066a3be5face22192c18ef36c33eed0a93953a3c
--- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/Ringtoets.StabilityPointStructures.Plugin.Test.csproj (.../Ringtoets.StabilityPointStructures.Plugin.Test.csproj) (revision d6e6041931d39b07ebb06bd0919a5d338736704e)
+++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/Ringtoets.StabilityPointStructures.Plugin.Test.csproj (.../Ringtoets.StabilityPointStructures.Plugin.Test.csproj) (revision 066a3be5face22192c18ef36c33eed0a93953a3c)
@@ -65,6 +65,7 @@
+
Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/StabilityPointStructuresPluginTest.cs
===================================================================
diff -u -rd6e6041931d39b07ebb06bd0919a5d338736704e -r066a3be5face22192c18ef36c33eed0a93953a3c
--- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/StabilityPointStructuresPluginTest.cs (.../StabilityPointStructuresPluginTest.cs) (revision d6e6041931d39b07ebb06bd0919a5d338736704e)
+++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/StabilityPointStructuresPluginTest.cs (.../StabilityPointStructuresPluginTest.cs) (revision 066a3be5face22192c18ef36c33eed0a93953a3c)
@@ -140,8 +140,9 @@
ImportInfo[] importInfos = plugin.GetImportInfos().ToArray();
// Assert
- Assert.AreEqual(1, importInfos.Length);
+ Assert.AreEqual(2, importInfos.Length);
Assert.IsTrue(importInfos.Any(i => i.DataType == typeof(StabilityPointStructuresContext)));
+ Assert.IsTrue(importInfos.Any(i => i.DataType == typeof(StabilityPointStructuresCalculationGroupContext)));
}
}
Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/TreeNodeInfos/StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs
===================================================================
diff -u -rab676d2163511e70dff41634d24a18e86b4248f4 -r066a3be5face22192c18ef36c33eed0a93953a3c
--- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/TreeNodeInfos/StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision ab676d2163511e70dff41634d24a18e86b4248f4)
+++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/TreeNodeInfos/StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision 066a3be5face22192c18ef36c33eed0a93953a3c)
@@ -56,18 +56,18 @@
[TestFixture]
public class StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest : NUnitFormTest
{
- private const int contextMenuGenerateCalculationsIndexRootGroup = 2;
- private const int contextMenuAddCalculationGroupIndexRootGroup = 4;
- private const int contextMenuAddCalculationIndexRootGroup = 5;
- private const int contextMenuValidateAllIndexRootGroup = 7;
- private const int contextMenuCalculateAllIndexRootGroup = 8;
- private const int contextMenuClearAllIndexRootGroup = 10;
+ private const int contextMenuGenerateCalculationsIndexRootGroup = 3;
+ private const int contextMenuAddCalculationGroupIndexRootGroup = 5;
+ private const int contextMenuAddCalculationIndexRootGroup = 6;
+ private const int contextMenuValidateAllIndexRootGroup = 8;
+ private const int contextMenuCalculateAllIndexRootGroup = 9;
+ private const int contextMenuClearAllIndexRootGroup = 11;
- private const int contextMenuAddCalculationGroupIndexNestedGroup = 2;
- private const int contextMenuAddCalculationIndexNestedGroup = 3;
- private const int contextMenuValidateAllIndexNestedGroup = 6;
- private const int contextMenuCalculateAllIndexNestedGroup = 7;
- private const int contextMenuClearAllIndexNestedGroup = 9;
+ private const int contextMenuAddCalculationGroupIndexNestedGroup = 3;
+ private const int contextMenuAddCalculationIndexNestedGroup = 4;
+ private const int contextMenuValidateAllIndexNestedGroup = 7;
+ private const int contextMenuCalculateAllIndexNestedGroup = 8;
+ private const int contextMenuClearAllIndexNestedGroup = 10;
private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, "HydraulicBoundaryDatabaseImporter");
private IGui gui;
@@ -182,6 +182,7 @@
var menuBuilderMock = mocks.StrictMock();
using (mocks.Ordered())
{
+ menuBuilderMock.Expect(mb => mb.AddImportItem()).Return(menuBuilderMock);
menuBuilderMock.Expect(mb => mb.AddExportItem()).Return(menuBuilderMock);
menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock);
@@ -239,7 +240,7 @@
using (ContextMenuStrip menu = info.ContextMenuStrip(groupContext, null, treeViewControl))
{
// Assert
- Assert.AreEqual(17, menu.Items.Count);
+ Assert.AreEqual(18, menu.Items.Count);
TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuGenerateCalculationsIndexRootGroup,
"Genereer &berekeningen...",
@@ -298,7 +299,7 @@
using (ContextMenuStrip menu = info.ContextMenuStrip(groupContext, null, treeViewControl))
{
// Assert
- Assert.AreEqual(17, menu.Items.Count);
+ Assert.AreEqual(18, menu.Items.Count);
TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuGenerateCalculationsIndexRootGroup,
"Genereer &berekeningen...",
@@ -537,6 +538,7 @@
var menuBuilderMock = mocks.StrictMock();
using (mocks.Ordered())
{
+ menuBuilderMock.Expect(mb => mb.AddImportItem()).Return(menuBuilderMock);
menuBuilderMock.Expect(mb => mb.AddExportItem()).Return(menuBuilderMock);
menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock);
@@ -591,7 +593,7 @@
using (ContextMenuStrip menu = info.ContextMenuStrip(groupContext, parentGroupContext, treeViewControl))
{
// Assert
- Assert.AreEqual(16, menu.Items.Count);
+ Assert.AreEqual(17, menu.Items.Count);
TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationGroupIndexNestedGroup,
"&Map toevoegen",