Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Ringtoets.ClosingStructures.Forms.Test.csproj
===================================================================
diff -u -rc53329fe1a36963d7e55abd8882b8eef43a685aa -r2d006ceaaef282af15090fe5505ffeca58a291e0
--- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Ringtoets.ClosingStructures.Forms.Test.csproj (.../Ringtoets.ClosingStructures.Forms.Test.csproj) (revision c53329fe1a36963d7e55abd8882b8eef43a685aa)
+++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Ringtoets.ClosingStructures.Forms.Test.csproj (.../Ringtoets.ClosingStructures.Forms.Test.csproj) (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -10,6 +10,8 @@
Ringtoets.ClosingStructures.Forms.Test
v4.0
512
+
+
true
@@ -72,14 +74,6 @@
-
-
-
-
-
-
-
-
@@ -98,10 +92,6 @@
{3BBFD65B-B277-4E50-AE6D-BD24C3434609}
Core.Common.Base
-
- {1D27F91F-4E62-4EAF-A0A8-A32708B9A9B1}
- Core.Common.Controls.TreeView
-
{9a2d67e6-26ac-4d17-b11a-2b4372f2f572}
Core.Common.Controls
@@ -114,10 +104,6 @@
{F49BD8B2-332A-4C91-A196-8CCE0A2C7D98}
Core.Common.Utils
-
- {26214BD0-DAFB-4CFC-8EB2-80C5D53C859E}
- Core.Common.Gui.TestUtil
-
{D749EE4C-CE50-4C17-BF01-9A953028C126}
Core.Common.TestUtil
@@ -142,10 +128,6 @@
{4D840673-3812-4338-A352-84854E32B8A0}
Ringtoets.Common.Forms
-
- {d951d6da-fe83-4920-9fdb-63bf96480b54}
- Ringtoets.Common.Service
-
{4843D6E5-066F-4795-94F5-1D53932DD03C}
Ringtoets.Common.Data.TestUtil
@@ -154,10 +136,6 @@
{d24fa2f7-28a7-413b-afd3-ee10e985630b}
Ringtoets.Common.Forms.TestUtil
-
- {74CBA865-9338-447F-BAD9-28312446AE84}
- Ringtoets.HydraRing.Calculation.TestUtil
-
{C6309704-D67B-434C-BC98-9F8910BC1D10}
Ringtoets.ClosingStructures.Data
@@ -166,10 +144,6 @@
{22E191F2-B2E3-413C-9511-4C2CDEDB2EFF}
Ringtoets.ClosingStructures.Forms
-
- {7DA0AB85-828D-4B1D-B532-58B89E39BEF5}
- Ringtoets.ClosingStructures.Plugin
-
{f5b43c29-6169-4e9a-859e-09090330b94e}
Ringtoets.ClosingStructures.Data.TestUtil
@@ -179,7 +153,7 @@
- This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
Fisheye: Tag 2d006ceaaef282af15090fe5505ffeca58a291e0 refers to a dead (removed) revision in file `Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructureFailureMechanismContextTreeNodeInfoTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 2d006ceaaef282af15090fe5505ffeca58a291e0 refers to a dead (removed) revision in file `Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructureTreeNodeInfoTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 2d006ceaaef282af15090fe5505ffeca58a291e0 refers to a dead (removed) revision in file `Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructuresCalculationContextTreeNodeInfoTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 2d006ceaaef282af15090fe5505ffeca58a291e0 refers to a dead (removed) revision in file `Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructuresCalculationGroupContextTreeNodeInfoTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 2d006ceaaef282af15090fe5505ffeca58a291e0 refers to a dead (removed) revision in file `Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructuresContextTreeNodeInfoTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 2d006ceaaef282af15090fe5505ffeca58a291e0 refers to a dead (removed) revision in file `Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructuresFailureMechanismSectionResultContextTreeNodeInfoTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 2d006ceaaef282af15090fe5505ffeca58a291e0 refers to a dead (removed) revision in file `Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructuresInputContextTreeNodeInfoTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 2d006ceaaef282af15090fe5505ffeca58a291e0 refers to a dead (removed) revision in file `Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructuresScenariosContextTreeNodeInfoTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/Ringtoets.ClosingStructures.Plugin.Test.csproj
===================================================================
diff -u -r17c09cdafee09f791ab833d426755705dbdcd1a7 -r2d006ceaaef282af15090fe5505ffeca58a291e0
--- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/Ringtoets.ClosingStructures.Plugin.Test.csproj (.../Ringtoets.ClosingStructures.Plugin.Test.csproj) (revision 17c09cdafee09f791ab833d426755705dbdcd1a7)
+++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/Ringtoets.ClosingStructures.Plugin.Test.csproj (.../Ringtoets.ClosingStructures.Plugin.Test.csproj) (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -10,6 +10,8 @@
Ringtoets.ClosingStructures.Plugin.Test
v4.0
512
+
+
true
@@ -42,12 +44,20 @@
..\..\..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll
True
+
+ False
+ ..\..\..\..\lib\NUnitForms.dll
+
..\..\..\..\packages\RhinoMocks.3.6.1\lib\net\Rhino.Mocks.dll
True
+
+ ..\..\..\..\packages\System.Data.SQLite.Core.1.0.99.0\lib\net40\System.Data.SQLite.dll
+ True
+
@@ -58,6 +68,14 @@
+
+
+
+
+
+
+
+
@@ -110,6 +128,10 @@
Ringtoets.Common.IO
True
+
+ {74CBA865-9338-447F-BAD9-28312446AE84}
+ Ringtoets.HydraRing.Calculation.TestUtil
+
{C6309704-D67B-434C-BC98-9F8910BC1D10}
Ringtoets.ClosingStructures.Data
@@ -126,8 +148,19 @@
{7DA0AB85-828D-4B1D-B532-58B89E39BEF5}
Ringtoets.ClosingStructures.Plugin
+
+ {F5B43C29-6169-4E9A-859E-09090330B94E}
+ Ringtoets.ClosingStructures.Data.TestUtil
+
+
+
+
+ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+
+
-
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ExportInfos/HydraulicBoundaryDatabaseContextExportInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ExportInfos/HydraulicBoundaryDatabaseContextExportInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ExportInfos/HydraulicBoundaryDatabaseContextExportInfoTest.cs (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -0,0 +1,126 @@
+// 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.Plugin;
+using NUnit.Framework;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Common.IO.Hydraulics;
+using Ringtoets.Integration.Data;
+using Ringtoets.Integration.Forms.PresentationObjects;
+using RingtoetsCommonIoResources = Ringtoets.Common.IO.Properties.Resources;
+
+namespace Ringtoets.Integration.Plugin.Test.ExportInfos
+{
+ [TestFixture]
+ public class HydraulicBoundaryDatabaseContextExportInfoTest
+ {
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ HydraulicBoundaryDatabase hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase();
+ hydraulicBoundaryDatabase.Locations.Add(new HydraulicBoundaryLocation(1, "test", 0, 0));
+
+ AssessmentSection assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ HydraulicBoundaryDatabase = hydraulicBoundaryDatabase
+ };
+ HydraulicBoundaryDatabaseContext context = new HydraulicBoundaryDatabaseContext(assessmentSection);
+ string filePath = "test";
+
+ using (RingtoetsPlugin plugin = new RingtoetsPlugin())
+ {
+ ExportInfo info = GetInfo(plugin);
+
+ // Call
+ IFileExporter fileExporter = info.CreateFileExporter(context, filePath);
+
+ // Assert
+ Assert.IsInstanceOf(fileExporter);
+ }
+ }
+
+ [Test]
+ public void FileFilter_Always_ReturnsFileFilter()
+ {
+ // Setup
+ using (RingtoetsPlugin plugin = new RingtoetsPlugin())
+ {
+ ExportInfo info = GetInfo(plugin);
+
+ // Call
+ string fileFilter = info.FileFilter;
+
+ // Assert
+ Assert.AreEqual(RingtoetsCommonIoResources.DataTypeDisplayName_shape_file_filter, fileFilter);
+ }
+ }
+
+ [Test]
+ public void IsEnabled_NoHydraulicBoundaryDatabaseSet_ReturnsFalse()
+ {
+ // Setup
+ AssessmentSection assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+ HydraulicBoundaryDatabaseContext context = new HydraulicBoundaryDatabaseContext(assessmentSection);
+
+ using (RingtoetsPlugin plugin = new RingtoetsPlugin())
+ {
+ ExportInfo info = GetInfo(plugin);
+
+ // Call
+ bool isEnabled = info.IsEnabled(context);
+
+ // Assert
+ Assert.IsFalse(isEnabled);
+ }
+ }
+
+ [Test]
+ public void IsEnabled_HydraulicBoundaryDatabaseSet_ReturnsTrue()
+ {
+ // Setup
+ AssessmentSection assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase()
+ };
+ HydraulicBoundaryDatabaseContext context = new HydraulicBoundaryDatabaseContext(assessmentSection);
+
+ using (RingtoetsPlugin plugin = new RingtoetsPlugin())
+ {
+ ExportInfo info = GetInfo(plugin);
+
+ // Call
+ bool isEnabled = info.IsEnabled(context);
+
+ // Assert
+ Assert.IsTrue(isEnabled);
+ }
+ }
+
+ private static ExportInfo GetInfo(RingtoetsPlugin plugin)
+ {
+ return plugin.GetExportInfos().First(ei => ei.DataType == typeof(HydraulicBoundaryDatabaseContext));
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ExportInfos/ReferenceLineContextExportInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ExportInfos/ReferenceLineContextExportInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ExportInfos/ReferenceLineContextExportInfoTest.cs (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -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.Plugin;
+using NUnit.Framework;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Forms.PresentationObjects;
+using Ringtoets.Common.IO.ReferenceLines;
+using Ringtoets.Integration.Data;
+using RingtoetsCommonIoResources = Ringtoets.Common.IO.Properties.Resources;
+
+namespace Ringtoets.Integration.Plugin.Test.ExportInfos
+{
+ [TestFixture]
+ public class ReferenceLineContextExportInfoTest
+ {
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ AssessmentSection assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ ReferenceLine = new ReferenceLine()
+ };
+ ReferenceLineContext context = new ReferenceLineContext(assessmentSection);
+ string filePath = "test";
+
+ using (RingtoetsPlugin plugin = new RingtoetsPlugin())
+ {
+ ExportInfo info = GetExportInfo(plugin);
+
+ // Call
+ IFileExporter fileExporter = info.CreateFileExporter(context, filePath);
+
+ // Assert
+ Assert.IsInstanceOf(fileExporter);
+ }
+ }
+
+ [Test]
+ public void FileFilter_Always_ReturnsFileFilter()
+ {
+ // Setup
+ using (RingtoetsPlugin plugin = new RingtoetsPlugin())
+ {
+ ExportInfo info = GetExportInfo(plugin);
+
+ // Call
+ string fileFilter = info.FileFilter;
+
+ // Assert
+ Assert.AreEqual("Shapebestand (*.shp)|*.shp", fileFilter);
+ }
+ }
+
+ [Test]
+ public void IsEnabled_NoReferenceLineSet_ReturnsFalse()
+ {
+ // Setup
+ AssessmentSection assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+ ReferenceLineContext context = new ReferenceLineContext(assessmentSection);
+
+ using (RingtoetsPlugin plugin = new RingtoetsPlugin())
+ {
+ ExportInfo info = GetExportInfo(plugin);
+
+ // Call
+ bool isEnabled = info.IsEnabled(context);
+
+ // Assert
+ Assert.IsFalse(isEnabled);
+ }
+ }
+
+ [Test]
+ public void IsEnabled_ReferenceLineSet_ReturnsTrue()
+ {
+ // Setup
+ AssessmentSection assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ ReferenceLine = new ReferenceLine()
+ };
+ ReferenceLineContext context = new ReferenceLineContext(assessmentSection);
+
+ using (RingtoetsPlugin plugin = new RingtoetsPlugin())
+ {
+ ExportInfo info = GetExportInfo(plugin);
+
+ // Call
+ bool isEnabled = info.IsEnabled(context);
+
+ // Assert
+ Assert.IsTrue(isEnabled);
+ }
+ }
+
+ private static ExportInfo GetExportInfo(RingtoetsPlugin plugin)
+ {
+ return plugin.GetExportInfos().First(ei => ei.DataType == typeof(ReferenceLineContext));
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ExportInfos/StabilityStoneCoverWaveConditionsCalculationContextExportInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ExportInfos/StabilityStoneCoverWaveConditionsCalculationContextExportInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ExportInfos/StabilityStoneCoverWaveConditionsCalculationContextExportInfoTest.cs (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -0,0 +1,149 @@
+// 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.Plugin;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Revetment.IO;
+using Ringtoets.Revetment.TestUtil;
+using Ringtoets.StabilityStoneCover.Data;
+using Ringtoets.StabilityStoneCover.Forms.PresentationObjects;
+using Ringtoets.StabilityStoneCover.Plugin;
+
+namespace Ringtoets.Integration.Plugin.Test.ExportInfos
+{
+ [TestFixture]
+ public class StabilityStoneCoverWaveConditionsCalculationContextExportInfoTest
+ {
+ [Test]
+ public void CreateFileExporter_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+
+ var context = new StabilityStoneCoverWaveConditionsCalculationContext(new StabilityStoneCoverWaveConditionsCalculation(),
+ failureMechanism, assessmentSection);
+ using (StabilityStoneCoverPlugin plugin = new StabilityStoneCoverPlugin())
+ {
+ ExportInfo exportInfo = GetExportInfo(plugin);
+
+ // Call
+ IFileExporter fileExporter = exportInfo.CreateFileExporter(context, "test");
+
+ // Assert
+ Assert.IsInstanceOf(fileExporter);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void FileFilter_Always_ReturnsFileFilter()
+ {
+ // Setup
+ using (StabilityStoneCoverPlugin plugin = new StabilityStoneCoverPlugin())
+ {
+ ExportInfo exportInfo = GetExportInfo(plugin);
+
+ // Call
+ string fileFilter = exportInfo.FileFilter;
+
+ // Assert
+ Assert.AreEqual("Kommagescheiden bestand (*.csv)|*.csv", fileFilter);
+ }
+ }
+
+ [Test]
+ public void IsEnabled_StabilityStoneCoverWaveConditionsCalculationHasOutputFalse_ReturnsFalse()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+
+ var context = new StabilityStoneCoverWaveConditionsCalculationContext(new StabilityStoneCoverWaveConditionsCalculation(),
+ failureMechanism, assessmentSection);
+ using (StabilityStoneCoverPlugin plugin = new StabilityStoneCoverPlugin())
+ {
+ ExportInfo exportInfo = GetExportInfo(plugin);
+
+ // Call
+ bool isEnabled = exportInfo.IsEnabled(context);
+
+ // Assert
+ Assert.IsFalse(isEnabled);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void IsEnabled_StabilityStoneCoverWaveConditionsCalculationHasOutputTrue_ReturnsTrue()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ var columnsOutput = new[]
+ {
+ new TestWaveConditionsOutput()
+ };
+
+ var blocksOutput = new[]
+ {
+ new TestWaveConditionsOutput()
+ };
+
+ var context = new StabilityStoneCoverWaveConditionsCalculationContext(
+ new StabilityStoneCoverWaveConditionsCalculation
+ {
+ Output = new StabilityStoneCoverWaveConditionsOutput(columnsOutput, blocksOutput)
+ },
+ failureMechanism, assessmentSection);
+
+ using (StabilityStoneCoverPlugin plugin = new StabilityStoneCoverPlugin())
+ {
+ ExportInfo exportInfo = GetExportInfo(plugin);
+
+ // Call
+ bool isEnabled = exportInfo.IsEnabled(context);
+
+ // Assert
+ Assert.IsTrue(isEnabled);
+ }
+ mocks.VerifyAll();
+ }
+
+ private static ExportInfo GetExportInfo(StabilityStoneCoverPlugin plugin)
+ {
+ return Enumerable.First(plugin.GetExportInfos(), ei => ei.DataType == typeof(StabilityStoneCoverWaveConditionsCalculationContext));
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ExportInfos/StabilityStoneCoverWaveConditionsCalculationGroupContextExportInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ExportInfos/StabilityStoneCoverWaveConditionsCalculationGroupContextExportInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ExportInfos/StabilityStoneCoverWaveConditionsCalculationGroupContextExportInfoTest.cs (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -0,0 +1,229 @@
+// 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.Plugin;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.Calculation;
+using Ringtoets.Revetment.IO;
+using Ringtoets.Revetment.TestUtil;
+using Ringtoets.StabilityStoneCover.Data;
+using Ringtoets.StabilityStoneCover.Forms.PresentationObjects;
+using Ringtoets.StabilityStoneCover.Plugin;
+
+namespace Ringtoets.Integration.Plugin.Test.ExportInfos
+{
+ [TestFixture]
+ public class StabilityStoneCoverWaveConditionsCalculationGroupContextExportInfoTest
+ {
+ [Test]
+ public void CreateFileExporter_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ var calculationGroup = new CalculationGroup();
+
+ var context = new StabilityStoneCoverWaveConditionsCalculationGroupContext(calculationGroup, failureMechanism, assessmentSection);
+ using (StabilityStoneCoverPlugin plugin = new StabilityStoneCoverPlugin())
+ {
+ ExportInfo exportInfo = GetExportInfo(plugin);
+
+ // Call
+ IFileExporter fileExporter = exportInfo.CreateFileExporter(context, "test");
+
+ // Assert
+ Assert.IsInstanceOf(fileExporter);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void FileFilter_Always_ReturnsFileFilter()
+ {
+ // Setup
+ using (StabilityStoneCoverPlugin plugin = new StabilityStoneCoverPlugin())
+ {
+ ExportInfo exportInfo = GetExportInfo(plugin);
+
+ // Call
+ string fileFilter = exportInfo.FileFilter;
+
+ // Assert
+ Assert.AreEqual("Kommagescheiden bestand (*.csv)|*.csv", fileFilter);
+ }
+ }
+
+ [Test]
+ public void IsEnabled_NoStabilityStoneCoverWaveConditionsCalculation_ReturnsFalse()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ var calculationGroup = new CalculationGroup();
+
+ var context = new StabilityStoneCoverWaveConditionsCalculationGroupContext(calculationGroup, failureMechanism, assessmentSection);
+ using (StabilityStoneCoverPlugin plugin = new StabilityStoneCoverPlugin())
+ {
+ ExportInfo exportInfo = GetExportInfo(plugin);
+
+ // Call
+ bool isEnabled = exportInfo.IsEnabled(context);
+
+ // Assert
+ Assert.IsFalse(isEnabled);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void IsEnabled_StabilityStoneCoverWaveConditionsCalculationHasOutputFalse_ReturnsFalse()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ var calculationGroup = new CalculationGroup();
+ calculationGroup.Children.Add(new StabilityStoneCoverWaveConditionsCalculation());
+
+ var context = new StabilityStoneCoverWaveConditionsCalculationGroupContext(calculationGroup, failureMechanism, assessmentSection);
+ using (StabilityStoneCoverPlugin plugin = new StabilityStoneCoverPlugin())
+ {
+ ExportInfo exportInfo = GetExportInfo(plugin);
+
+ // Call
+ bool isEnabled = exportInfo.IsEnabled(context);
+
+ // Assert
+ Assert.IsFalse(isEnabled);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void IsEnabled_StabilityStoneCoverWaveConditionsCalculationHasOutputTrue_ReturnsTrue()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ var calculationGroup = new CalculationGroup();
+ var columnsOutput = new[]
+ {
+ new TestWaveConditionsOutput()
+ };
+
+ var blocksOutput = new[]
+ {
+ new TestWaveConditionsOutput()
+ };
+ calculationGroup.Children.Add(new StabilityStoneCoverWaveConditionsCalculation
+ {
+ Output = new StabilityStoneCoverWaveConditionsOutput(columnsOutput, blocksOutput)
+ });
+
+ var context = new StabilityStoneCoverWaveConditionsCalculationGroupContext(calculationGroup, failureMechanism, assessmentSection);
+ using (StabilityStoneCoverPlugin plugin = new StabilityStoneCoverPlugin())
+ {
+ ExportInfo exportInfo = GetExportInfo(plugin);
+
+ // Call
+ bool isEnabled = exportInfo.IsEnabled(context);
+
+ // Assert
+ Assert.IsTrue(isEnabled);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void IsEnabled_StabilityStoneCoverWaveConditionsCalculationInSubFolder_ReturnsTrueIfHasOutput(bool hasOutput)
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ var calculationGroup = new CalculationGroup();
+
+ StabilityStoneCoverWaveConditionsOutput stabilityStoneCoverWaveConditionsOutput = null;
+ if (hasOutput)
+ {
+ var columnsOutput = new[]
+ {
+ new TestWaveConditionsOutput()
+ };
+
+ var blocksOutput = new[]
+ {
+ new TestWaveConditionsOutput()
+ };
+
+ stabilityStoneCoverWaveConditionsOutput = new StabilityStoneCoverWaveConditionsOutput(columnsOutput, blocksOutput);
+ }
+ calculationGroup.Children.Add(
+ new CalculationGroup
+ {
+ Children =
+ {
+ new StabilityStoneCoverWaveConditionsCalculation
+ {
+ Output = stabilityStoneCoverWaveConditionsOutput
+ }
+ }
+ });
+
+ var context = new StabilityStoneCoverWaveConditionsCalculationGroupContext(calculationGroup, failureMechanism, assessmentSection);
+ using (StabilityStoneCoverPlugin plugin = new StabilityStoneCoverPlugin())
+ {
+ ExportInfo exportInfo = GetExportInfo(plugin);
+
+ // Call
+ bool isEnabled = exportInfo.IsEnabled(context);
+
+ // Assert
+ Assert.AreEqual(hasOutput, isEnabled);
+ }
+ mocks.VerifyAll();
+ }
+
+ private static ExportInfo GetExportInfo(StabilityStoneCoverPlugin plugin)
+ {
+ return Enumerable.First(plugin.GetExportInfos(), ei => ei.DataType == typeof(StabilityStoneCoverWaveConditionsCalculationGroupContext));
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ExportInfos/WaveImpactAsphaltCoverWaveConditionsCalculationContextExportInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ExportInfos/WaveImpactAsphaltCoverWaveConditionsCalculationContextExportInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ExportInfos/WaveImpactAsphaltCoverWaveConditionsCalculationContextExportInfoTest.cs (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -0,0 +1,144 @@
+// 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.Plugin;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Revetment.IO;
+using Ringtoets.Revetment.TestUtil;
+using Ringtoets.WaveImpactAsphaltCover.Data;
+using Ringtoets.WaveImpactAsphaltCover.Forms.PresentationObjects;
+using Ringtoets.WaveImpactAsphaltCover.Plugin;
+
+namespace Ringtoets.Integration.Plugin.Test.ExportInfos
+{
+ [TestFixture]
+ public class WaveImpactAsphaltCoverWaveConditionsCalculationContextExportInfoTest
+ {
+ [Test]
+ public void CreateFileExporter_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism();
+
+ var context = new WaveImpactAsphaltCoverWaveConditionsCalculationContext(new WaveImpactAsphaltCoverWaveConditionsCalculation(),
+ failureMechanism, assessmentSection);
+ using (WaveImpactAsphaltCoverPlugin plugin = new WaveImpactAsphaltCoverPlugin())
+ {
+ ExportInfo exportInfo = GetExportInfo(plugin);
+
+ // Call
+ IFileExporter fileExporter = exportInfo.CreateFileExporter(context, "test");
+
+ // Assert
+ Assert.IsInstanceOf(fileExporter);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void FileFilter_Always_ReturnsFileFilter()
+ {
+ // Setup
+ using (WaveImpactAsphaltCoverPlugin plugin = new WaveImpactAsphaltCoverPlugin())
+ {
+ ExportInfo exportInfo = GetExportInfo(plugin);
+
+ // Call
+ string fileFilter = exportInfo.FileFilter;
+
+ // Assert
+ Assert.AreEqual("Kommagescheiden bestand (*.csv)|*.csv", fileFilter);
+ }
+ }
+
+ [Test]
+ public void IsEnabled_WaveImpactAsphaltCoverWaveConditionsCalculationHasOutputFalse_ReturnsFalse()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism();
+
+ var context = new WaveImpactAsphaltCoverWaveConditionsCalculationContext(new WaveImpactAsphaltCoverWaveConditionsCalculation(),
+ failureMechanism, assessmentSection);
+ using (WaveImpactAsphaltCoverPlugin plugin = new WaveImpactAsphaltCoverPlugin())
+ {
+ ExportInfo exportInfo = GetExportInfo(plugin);
+
+ // Call
+ bool isEnabled = exportInfo.IsEnabled(context);
+
+ // Assert
+ Assert.IsFalse(isEnabled);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void IsEnabled_WaveImpactAsphaltCoverWaveConditionsCalculationHasOutputTrue_ReturnsTrue()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism();
+ var output = new[]
+ {
+ new TestWaveConditionsOutput()
+ };
+
+ var context = new WaveImpactAsphaltCoverWaveConditionsCalculationContext(
+ new WaveImpactAsphaltCoverWaveConditionsCalculation
+ {
+ Output = new WaveImpactAsphaltCoverWaveConditionsOutput(output)
+ },
+ failureMechanism, assessmentSection);
+
+ using (WaveImpactAsphaltCoverPlugin plugin = new WaveImpactAsphaltCoverPlugin())
+ {
+ ExportInfo exportInfo = GetExportInfo(plugin);
+
+ // Call
+ bool isEnabled = exportInfo.IsEnabled(context);
+
+ // Assert
+ Assert.IsTrue(isEnabled);
+ }
+ mocks.VerifyAll();
+ }
+
+ private static ExportInfo GetExportInfo(WaveImpactAsphaltCoverPlugin plugin)
+ {
+ return Enumerable.First(plugin.GetExportInfos(), ei => ei.DataType == typeof(WaveImpactAsphaltCoverWaveConditionsCalculationContext));
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ExportInfos/WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextExportInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ExportInfos/WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextExportInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ExportInfos/WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextExportInfoTest.cs (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -0,0 +1,219 @@
+// 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.Plugin;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.Calculation;
+using Ringtoets.Revetment.IO;
+using Ringtoets.Revetment.TestUtil;
+using Ringtoets.WaveImpactAsphaltCover.Data;
+using Ringtoets.WaveImpactAsphaltCover.Forms.PresentationObjects;
+using Ringtoets.WaveImpactAsphaltCover.Plugin;
+
+namespace Ringtoets.Integration.Plugin.Test.ExportInfos
+{
+ [TestFixture]
+ public class WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextExportInfoTest
+ {
+ [Test]
+ public void CreateFileExporter_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism();
+ var calculationGroup = new CalculationGroup();
+
+ var context = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(calculationGroup, failureMechanism, assessmentSection);
+ using (WaveImpactAsphaltCoverPlugin plugin = new WaveImpactAsphaltCoverPlugin())
+ {
+ ExportInfo exportInfo = GetExportInfo(plugin);
+
+ // Call
+ IFileExporter fileExporter = exportInfo.CreateFileExporter(context, "test");
+
+ // Assert
+ Assert.IsInstanceOf(fileExporter);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void FileFilter_Always_ReturnsFileFilter()
+ {
+ // Setup
+ using (WaveImpactAsphaltCoverPlugin plugin = new WaveImpactAsphaltCoverPlugin())
+ {
+ ExportInfo exportInfo = GetExportInfo(plugin);
+
+ // Call
+ string fileFilter = exportInfo.FileFilter;
+
+ // Assert
+ Assert.AreEqual("Kommagescheiden bestand (*.csv)|*.csv", fileFilter);
+ }
+ }
+
+ [Test]
+ public void IsEnabled_NoWaveImpactAsphaltCoverWaveConditionsCalculation_ReturnsFalse()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism();
+ var calculationGroup = new CalculationGroup();
+
+ var context = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(calculationGroup, failureMechanism, assessmentSection);
+ using (WaveImpactAsphaltCoverPlugin plugin = new WaveImpactAsphaltCoverPlugin())
+ {
+ ExportInfo exportInfo = GetExportInfo(plugin);
+
+ // Call
+ bool isEnabled = exportInfo.IsEnabled(context);
+
+ // Assert
+ Assert.IsFalse(isEnabled);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void IsEnabled_WaveImpactAsphaltCoverWaveConditionsCalculationHasOutputFalse_ReturnsFalse()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism();
+ var calculationGroup = new CalculationGroup();
+ calculationGroup.Children.Add(new WaveImpactAsphaltCoverWaveConditionsCalculation());
+
+ var context = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(calculationGroup, failureMechanism, assessmentSection);
+ using (WaveImpactAsphaltCoverPlugin plugin = new WaveImpactAsphaltCoverPlugin())
+ {
+ ExportInfo exportInfo = GetExportInfo(plugin);
+
+ // Call
+ bool isEnabled = exportInfo.IsEnabled(context);
+
+ // Assert
+ Assert.IsFalse(isEnabled);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void IsEnabled_WaveImpactAsphaltCoverWaveConditionsCalculationHasOutputTrue_ReturnsTrue()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism();
+ var calculationGroup = new CalculationGroup();
+ var output = new[]
+ {
+ new TestWaveConditionsOutput()
+ };
+
+ calculationGroup.Children.Add(new WaveImpactAsphaltCoverWaveConditionsCalculation
+ {
+ Output = new WaveImpactAsphaltCoverWaveConditionsOutput(output)
+ });
+
+ var context = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(calculationGroup, failureMechanism, assessmentSection);
+ using (WaveImpactAsphaltCoverPlugin plugin = new WaveImpactAsphaltCoverPlugin())
+ {
+ ExportInfo exportInfo = GetExportInfo(plugin);
+
+ // Call
+ bool isEnabled = exportInfo.IsEnabled(context);
+
+ // Assert
+ Assert.IsTrue(isEnabled);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void IsEnabled_WaveImpactAsphaltCoverWaveConditionsCalculationInSubFolder_ReturnsTrueIfHasOutput(bool hasOutput)
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism();
+ var calculationGroup = new CalculationGroup();
+
+ WaveImpactAsphaltCoverWaveConditionsOutput waveImpactAsphaltCoverWaveConditionsOutput = null;
+ if (hasOutput)
+ {
+ var output = new[]
+ {
+ new TestWaveConditionsOutput()
+ };
+ waveImpactAsphaltCoverWaveConditionsOutput = new WaveImpactAsphaltCoverWaveConditionsOutput(output);
+ }
+ calculationGroup.Children.Add(
+ new CalculationGroup
+ {
+ Children =
+ {
+ new WaveImpactAsphaltCoverWaveConditionsCalculation
+ {
+ Output = waveImpactAsphaltCoverWaveConditionsOutput
+ }
+ }
+ });
+
+ var context = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(calculationGroup, failureMechanism, assessmentSection);
+ using (WaveImpactAsphaltCoverPlugin plugin = new WaveImpactAsphaltCoverPlugin())
+ {
+ ExportInfo exportInfo = GetExportInfo(plugin);
+
+ // Call
+ bool isEnabled = exportInfo.IsEnabled(context);
+
+ // Assert
+ Assert.AreEqual(hasOutput, isEnabled);
+ }
+ mocks.VerifyAll();
+ }
+
+ private static ExportInfo GetExportInfo(WaveImpactAsphaltCoverPlugin plugin)
+ {
+ return Enumerable.First(plugin.GetExportInfos(), ei => ei.DataType == typeof(WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext));
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/DesignWaterLevelLocationsContextPropertyInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/DesignWaterLevelLocationsContextPropertyInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/DesignWaterLevelLocationsContextPropertyInfoTest.cs (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -0,0 +1,83 @@
+// 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;
+using System.Linq;
+using Core.Common.Gui.Plugin;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Integration.Forms.PresentationObjects;
+using Ringtoets.Integration.Forms.PropertyClasses;
+
+namespace Ringtoets.Integration.Plugin.Test.PropertyInfos
+{
+ [TestFixture]
+ public class DesignWaterLevelLocationsContextPropertyInfoTest
+ {
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ using (RingtoetsPlugin plugin = new RingtoetsPlugin())
+ {
+ PropertyInfo info = GetInfo(plugin);
+
+ // Call
+ Type propertyObjectType = info.PropertyObjectType;
+
+ // Assert
+ Assert.AreEqual(typeof(DesignWaterLevelLocationsContextProperties), propertyObjectType);
+ }
+ }
+
+ [Test]
+ public void CreateInstance_Always_SetsHydraulicBoundaryDatabaseAsData()
+ {
+ // Setup
+ MockRepository mockRepository = new MockRepository();
+ var assessmentSectionMock = mockRepository.Stub();
+ var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase();
+ assessmentSectionMock.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase;
+ mockRepository.ReplayAll();
+
+ DesignWaterLevelLocationsContext context = new DesignWaterLevelLocationsContext(assessmentSectionMock);
+
+ using (RingtoetsPlugin plugin = new RingtoetsPlugin())
+ {
+ PropertyInfo info = GetInfo(plugin);
+
+ // Call
+ var objectProperties = info.CreateInstance(context);
+
+ // Assert
+ Assert.AreSame(hydraulicBoundaryDatabase, objectProperties.Data);
+ }
+ mockRepository.VerifyAll();
+ }
+
+ private static PropertyInfo GetInfo(RingtoetsPlugin plugin)
+ {
+ return plugin.GetPropertyInfos().First(pi => pi.DataType == typeof(DesignWaterLevelLocationsContext));
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/WaveHeightLocationsContextPropertyInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/WaveHeightLocationsContextPropertyInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/WaveHeightLocationsContextPropertyInfoTest.cs (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -0,0 +1,83 @@
+// 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;
+using System.Linq;
+using Core.Common.Gui.Plugin;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Integration.Forms.PresentationObjects;
+using Ringtoets.Integration.Forms.PropertyClasses;
+
+namespace Ringtoets.Integration.Plugin.Test.PropertyInfos
+{
+ [TestFixture]
+ public class WaveHeightLocationsContextPropertyInfoTest
+ {
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ using (RingtoetsPlugin plugin = new RingtoetsPlugin())
+ {
+ PropertyInfo info = GetInfo(plugin);
+
+ // Call
+ Type propertyObjectType = info.PropertyObjectType;
+
+ // Assert
+ Assert.AreEqual(typeof(WaveHeightLocationsContextProperties), propertyObjectType);
+ }
+ }
+
+ [Test]
+ public void CreateInstance_Always_SetsHydraulicBoundaryDatabaseAsData()
+ {
+ // Setup
+ MockRepository mockRepository = new MockRepository();
+ var assessmentSectionMock = mockRepository.Stub();
+ var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase();
+ assessmentSectionMock.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase;
+ mockRepository.ReplayAll();
+
+ WaveHeightLocationsContext context = new WaveHeightLocationsContext(assessmentSectionMock);
+
+ using (RingtoetsPlugin plugin = new RingtoetsPlugin())
+ {
+ PropertyInfo info = GetInfo(plugin);
+
+ // Call
+ var objectProperties = info.CreateInstance(context);
+
+ // Assert
+ Assert.AreSame(hydraulicBoundaryDatabase, objectProperties.Data);
+ }
+ mockRepository.VerifyAll();
+ }
+
+ private static PropertyInfo GetInfo(RingtoetsPlugin plugin)
+ {
+ return plugin.GetPropertyInfos().First(pi => pi.DataType == typeof(WaveHeightLocationsContext));
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj
===================================================================
diff -u -r26e6c71dacff987569f34296db2987aabf6d4b84 -r2d006ceaaef282af15090fe5505ffeca58a291e0
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision 26e6c71dacff987569f34296db2987aabf6d4b84)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -67,6 +67,12 @@
Properties\GlobalAssembly.cs
+
+
+
+
+
+
@@ -75,9 +81,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -111,6 +144,10 @@
{30e4c2ae-719e-4d70-9fa9-668a9767fbfa}
Core.Common.Gui
+
+ {F49BD8B2-332A-4C91-A196-8CCE0A2C7D98}
+ Core.Common.Utils
+
{26214bd0-dafb-4cfc-8eb2-80c5d53c859e}
Core.Common.Gui.TestUtil
@@ -127,6 +164,10 @@
{c6309704-d67b-434c-bc98-9f8910bc1d10}
Ringtoets.ClosingStructures.Data
+
+ {22E191F2-B2E3-413C-9511-4C2CDEDB2EFF}
+ Ringtoets.ClosingStructures.Forms
+
{d4200f43-3f72-4f42-af0a-8ced416a38ec}
Ringtoets.Common.Data
@@ -167,30 +208,86 @@
{e7225477-577f-4a17-b7ec-6721158e1543}
Ringtoets.GrassCoverErosionOutwards.Data
+
+ {41B829C1-630F-40B0-8BEE-B1C4C94EC8C4}
+ Ringtoets.GrassCoverErosionOutwards.Forms
+
{1c0017d8-35b5-4ca0-8fc7-a83f46dbdc99}
Ringtoets.HeightStructures.Data
+
+ {F0BCF06A-3D01-4D65-A249-E2A14AEC6EFD}
+ Ringtoets.HeightStructures.Forms
+
+
+ {74CBA865-9338-447F-BAD9-28312446AE84}
+ Ringtoets.HydraRing.Calculation.TestUtil
+
{CE994CC9-6F6A-48AC-B4BE-02C30A21F4DB}
Ringtoets.Piping.Data
+
+ {7CD038E1-E111-4969-ACED-22C5BD2974E1}
+ Ringtoets.Piping.Forms
+
{14c6f716-64e2-4bc4-a1ef-05865fcefa4c}
Ringtoets.Piping.Primitives
+
+ {955E574D-67CE-4347-AA6B-7DF8A04ED754}
+ Ringtoets.Piping.Data.TestUtil
+
+
+ {27E0A5C9-3ABF-426A-A3DA-7D0B83A218C8}
+ Ringtoets.Piping.KernelWrapper.TestUtil
+
+
+ {87c2c553-c0bc-40bf-b1ea-b83bff357f27}
+ Ringtoets.Revetment.Data
+
+
+ {E3347B16-BB18-41C1-8D34-FBCBF20DB695}
+ Ringtoets.Revetment.IO
+
+
+ {3706200E-48C6-4B86-B48C-4E45C69ABE95}
+ Ringtoets.Revetment.Data.TestUtil
+
{3d4b9740-8348-4434-8d77-b611fc6ee57f}
Ringtoets.StabilityPointStructures.Data
+
+ {D5F0A6B0-8710-4345-ABA1-D934C8E6783D}
+ Ringtoets.StabilityPointStructures.Forms
+
{b479e3af-7c34-488c-bb73-d324100d36c9}
Ringtoets.StabilityStoneCover.Data
+
+ {8E4E1877-697A-45D3-81CF-169EFDF65AA0}
+ Ringtoets.StabilityStoneCover.Forms
+
+
+ {9DDC42CC-A2CC-4900-A711-AA1DD6D3A94A}
+ Ringtoets.StabilityStoneCover.Plugin
+
{567e0b69-5280-41ce-add6-443725a61c86}
Ringtoets.WaveImpactAsphaltCover.Data
+
+ {1AC97B51-88C2-437D-89E6-65C69AB3CCAD}
+ Ringtoets.WaveImpactAsphaltCover.Forms
+
+
+ {83A782F1-BA78-4D5C-B213-39066605AFD8}
+ Ringtoets.WaveImpactAsphaltCover.Plugin
+
{11f1f874-45af-43e4-8ae5-15a5c9593e28}
Ringtoets.Integration.Data
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/AssessmentSectionTreeNodeInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/AssessmentSectionTreeNodeInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/AssessmentSectionTreeNodeInfoTest.cs (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -0,0 +1,366 @@
+// 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;
+using Core.Common.Controls.TreeView;
+using Core.Common.Gui;
+using Core.Common.Gui.ContextMenu;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.ClosingStructures.Forms.PresentationObjects;
+using Ringtoets.Common.Data;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Forms.PresentationObjects;
+using Ringtoets.DuneErosion.Forms.PresentationObjects;
+using Ringtoets.GrassCoverErosionInwards.Forms.PresentationObjects;
+using Ringtoets.GrassCoverErosionOutwards.Forms.PresentationObjects;
+using Ringtoets.HeightStructures.Forms.PresentationObjects;
+using Ringtoets.Integration.Data;
+using Ringtoets.Integration.Forms.PresentationObjects;
+using Ringtoets.Piping.Forms.PresentationObjects;
+using Ringtoets.StabilityPointStructures.Forms.PresentationObjects;
+using Ringtoets.StabilityStoneCover.Forms.PresentationObjects;
+using Ringtoets.WaveImpactAsphaltCover.Forms.PresentationObjects;
+using RingtoetsIntegrationFormsResources = Ringtoets.Integration.Forms.Properties.Resources;
+
+namespace Ringtoets.Integration.Plugin.Test.TreeNodeInfos
+{
+ [TestFixture]
+ public class AssessmentSectionTreeNodeInfoTest
+ {
+ private MockRepository mocks;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks = new MockRepository();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Assert
+ Assert.AreEqual(typeof(AssessmentSection), info.TagType);
+ Assert.IsNull(info.ForeColor);
+ Assert.IsNull(info.CanCheck);
+ Assert.IsNull(info.IsChecked);
+ Assert.IsNull(info.OnNodeChecked);
+ Assert.IsNull(info.CanDrag);
+ Assert.IsNull(info.CanDrop);
+ Assert.IsNull(info.CanInsert);
+ Assert.IsNull(info.OnDrop);
+ }
+ }
+
+ [Test]
+ public void Text_Always_ReturnsName()
+ {
+ // Setup
+ var testName = "ttt";
+
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ Name = testName
+ };
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Call
+ var text = info.Text(assessmentSection);
+
+ // Assert
+ Assert.AreEqual(testName, text);
+ }
+ }
+
+ [Test]
+ public void Image_Always_ReturnsSetImage()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Call
+ var image = info.Image(assessmentSection);
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(RingtoetsIntegrationFormsResources.AssessmentSectionFolderIcon, image);
+ }
+ }
+
+ [Test]
+ public void EnsureVisibleOnCreate_Always_ReturnsTrue()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Call
+ var result = info.EnsureVisibleOnCreate(null, null);
+
+ // Assert
+ Assert.IsTrue(result);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ChildNodeObjects_Always_ReturnsChildrenOfData()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+ // Call
+ var objects = info.ChildNodeObjects(assessmentSection).ToArray();
+
+ // Assert
+ Assert.AreEqual(22, objects.Length);
+ var referenceLineContext = (ReferenceLineContext) objects[0];
+ Assert.AreSame(assessmentSection, referenceLineContext.WrappedData);
+
+ var contributionContext = (FailureMechanismContributionContext) objects[1];
+ Assert.AreSame(assessmentSection.FailureMechanismContribution, contributionContext.WrappedData);
+ Assert.AreSame(assessmentSection, contributionContext.Parent);
+
+ var context = (HydraulicBoundaryDatabaseContext) objects[2];
+ Assert.AreSame(assessmentSection.HydraulicBoundaryDatabase, context.WrappedData.HydraulicBoundaryDatabase);
+ Assert.AreSame(assessmentSection, context.WrappedData);
+
+ var comment = (Comment) objects[3];
+ Assert.AreSame(assessmentSection.Comments, comment);
+
+ var pipingFailureMechanismContext = (PipingFailureMechanismContext) objects[4];
+ Assert.AreSame(assessmentSection.PipingFailureMechanism, pipingFailureMechanismContext.WrappedData);
+ Assert.AreSame(assessmentSection, pipingFailureMechanismContext.Parent);
+
+ var grassCoverErosionInwardsFailureMechanismContext = (GrassCoverErosionInwardsFailureMechanismContext) objects[5];
+ Assert.AreSame(assessmentSection.GrassCoverErosionInwards, grassCoverErosionInwardsFailureMechanismContext.WrappedData);
+ Assert.AreSame(assessmentSection, grassCoverErosionInwardsFailureMechanismContext.Parent);
+
+ var macrostabilityInwardsFailureMechanismContext = (FailureMechanismContext) objects[6];
+ Assert.AreSame(assessmentSection.MacrostabilityInwards, macrostabilityInwardsFailureMechanismContext.WrappedData);
+ Assert.AreSame(assessmentSection, macrostabilityInwardsFailureMechanismContext.Parent);
+ var macrostabilityOutwardsFailureMechanismContext = (FailureMechanismContext) objects[7];
+ Assert.AreSame(assessmentSection.MacrostabilityOutwards, macrostabilityOutwardsFailureMechanismContext.WrappedData);
+ Assert.AreSame(assessmentSection, macrostabilityOutwardsFailureMechanismContext.Parent);
+ var microstabilityFailureMechanismContext = (FailureMechanismContext) objects[8];
+ Assert.AreSame(assessmentSection.Microstability, microstabilityFailureMechanismContext.WrappedData);
+ Assert.AreSame(assessmentSection, microstabilityFailureMechanismContext.Parent);
+
+ var stabilityStoneCoverFailureMechanismContext = (StabilityStoneCoverFailureMechanismContext) objects[9];
+ Assert.AreSame(assessmentSection.StabilityStoneCover, stabilityStoneCoverFailureMechanismContext.WrappedData);
+ Assert.AreSame(assessmentSection, stabilityStoneCoverFailureMechanismContext.Parent);
+
+ var waveImpactAsphaltCoverFailureMechanismContext = (WaveImpactAsphaltCoverFailureMechanismContext) objects[10];
+ Assert.AreSame(assessmentSection.WaveImpactAsphaltCover, waveImpactAsphaltCoverFailureMechanismContext.WrappedData);
+ Assert.AreSame(assessmentSection, waveImpactAsphaltCoverFailureMechanismContext.Parent);
+
+ var waterPressureAsphaltCoverFailureMechanismContext = (FailureMechanismContext) objects[11];
+ Assert.AreSame(assessmentSection.WaterPressureAsphaltCover, waterPressureAsphaltCoverFailureMechanismContext.WrappedData);
+ Assert.AreSame(assessmentSection, waterPressureAsphaltCoverFailureMechanismContext.Parent);
+
+ var grassCoverErosionOutwardsFailureMechanismContext = (GrassCoverErosionOutwardsFailureMechanismContext) objects[12];
+ Assert.AreSame(assessmentSection.GrassCoverErosionOutwards, grassCoverErosionOutwardsFailureMechanismContext.WrappedData);
+ Assert.AreSame(assessmentSection, grassCoverErosionOutwardsFailureMechanismContext.Parent);
+
+ var grassCoverSlipOffOutwardsFailureMechanismContext = (FailureMechanismContext) objects[13];
+ Assert.AreSame(assessmentSection.GrassCoverSlipOffOutwards, grassCoverSlipOffOutwardsFailureMechanismContext.WrappedData);
+ Assert.AreSame(assessmentSection, grassCoverSlipOffOutwardsFailureMechanismContext.Parent);
+ var grassCoverSlipOffInwardsFailureMechanismContext = (FailureMechanismContext) objects[14];
+ Assert.AreSame(assessmentSection.GrassCoverSlipOffInwards, grassCoverSlipOffInwardsFailureMechanismContext.WrappedData);
+ Assert.AreSame(assessmentSection, grassCoverSlipOffInwardsFailureMechanismContext.Parent);
+
+ var heightStructuresFailureMechanismContext = (HeightStructuresFailureMechanismContext) objects[15];
+ Assert.AreSame(assessmentSection.HeightStructures, heightStructuresFailureMechanismContext.WrappedData);
+ Assert.AreSame(assessmentSection, heightStructuresFailureMechanismContext.Parent);
+
+ var closingStructuresFailureMechanismContext = (ClosingStructuresFailureMechanismContext) objects[16];
+ Assert.AreSame(assessmentSection.ClosingStructures, closingStructuresFailureMechanismContext.WrappedData);
+ Assert.AreSame(assessmentSection, closingStructuresFailureMechanismContext.Parent);
+ var pipingStructureFailureMechanismContext = (FailureMechanismContext) objects[17];
+ Assert.AreSame(assessmentSection.PipingStructure, pipingStructureFailureMechanismContext.WrappedData);
+ Assert.AreSame(assessmentSection, pipingStructureFailureMechanismContext.Parent);
+ var stabilityPointStructuresFailureMechanismContext = (StabilityPointStructuresFailureMechanismContext) objects[18];
+ Assert.AreSame(assessmentSection.StabilityPointStructures, stabilityPointStructuresFailureMechanismContext.WrappedData);
+ Assert.AreSame(assessmentSection, stabilityPointStructuresFailureMechanismContext.Parent);
+ var strengthStabilityLengthwiseConstructionFailureMechanismContext = (FailureMechanismContext) objects[19];
+ Assert.AreSame(assessmentSection.StrengthStabilityLengthwiseConstruction, strengthStabilityLengthwiseConstructionFailureMechanismContext.WrappedData);
+ Assert.AreSame(assessmentSection, strengthStabilityLengthwiseConstructionFailureMechanismContext.Parent);
+ var duneErosionFailureMechanismContext = (DuneErosionFailureMechanismContext) objects[20];
+ Assert.AreSame(assessmentSection.DuneErosion, duneErosionFailureMechanismContext.WrappedData);
+ Assert.AreSame(assessmentSection, duneErosionFailureMechanismContext.Parent);
+ var technicalInnovationFailureMechanismContext = (FailureMechanismContext) objects[21];
+ Assert.AreSame(assessmentSection.TechnicalInnovation, technicalInnovationFailureMechanismContext.WrappedData);
+ Assert.AreSame(assessmentSection, technicalInnovationFailureMechanismContext.Parent);
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_Always_CallsBuilder()
+ {
+ // Setup
+ var menuBuilderMock = mocks.StrictMock();
+ menuBuilderMock.Expect(mb => mb.AddOpenItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddRenameItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddDeleteItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.Build()).Return(null);
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var gui = mocks.Stub();
+ gui.Stub(g => g.Get(null, treeViewControl)).Return(menuBuilderMock);
+ gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+ mocks.ReplayAll();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+ plugin.Gui = gui;
+
+ // Call
+ info.ContextMenuStrip(null, null, treeViewControl);
+ }
+ }
+ // Assert
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void CanRename_Always_ReturnsTrue()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Call
+ var canRename = info.CanRename(null, null);
+
+ // Assert
+ Assert.IsTrue(canRename);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void OnNodeRenamed_WithData_SetProjectNameWithNotification()
+ {
+ // Setup
+ var observer = mocks.Stub();
+ observer.Expect(o => o.UpdateObserver());
+ mocks.ReplayAll();
+
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+ assessmentSection.Attach(observer);
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+ // Call
+ const string newName = "New Name";
+ info.OnNodeRenamed(assessmentSection, newName);
+
+ // Assert
+ Assert.AreEqual(newName, assessmentSection.Name);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void CanRemove_Always_ReturnsTrue()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+ // Call
+ var canRemove = info.CanRemove(null, null);
+
+ // Assert
+ Assert.IsTrue(canRemove);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void RemoveNodeData_ProjectWithAssessmentSection_ReturnTrueAndRemoveAssessmentSection()
+ {
+ // Setup
+ var observerMock = mocks.StrictMock();
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+
+ observerMock.Expect(o => o.UpdateObserver());
+
+ mocks.ReplayAll();
+
+ var project = new RingtoetsProject();
+ project.AssessmentSections.Add(assessmentSection);
+ project.Attach(observerMock);
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Call
+ info.OnNodeRemoved(assessmentSection, project);
+
+ // Assert
+ CollectionAssert.DoesNotContain(project.AssessmentSections, assessmentSection);
+ }
+ mocks.VerifyAll();
+ }
+
+ private TreeNodeInfo GetInfo(RingtoetsPlugin plugin)
+ {
+ return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(AssessmentSection));
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/CategoryTreeFolderTreeNodeInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/CategoryTreeFolderTreeNodeInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/CategoryTreeFolderTreeNodeInfoTest.cs (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -0,0 +1,226 @@
+// 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.Controls.TreeView;
+using Core.Common.Gui;
+using Core.Common.Gui.ContextMenu;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Forms.PresentationObjects;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.Integration.Plugin.Test.TreeNodeInfos
+{
+ [TestFixture]
+ public class CategoryTreeFolderTreeNodeInfoTest
+ {
+ private MockRepository mocks;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks = new MockRepository();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Assert
+ Assert.AreEqual(typeof(CategoryTreeFolder), info.TagType);
+ Assert.IsNull(info.EnsureVisibleOnCreate);
+ Assert.IsNull(info.CanRename);
+ Assert.IsNull(info.OnNodeRenamed);
+ Assert.IsNull(info.CanRemove);
+ Assert.IsNull(info.OnNodeRemoved);
+ Assert.IsNull(info.CanCheck);
+ Assert.IsNull(info.IsChecked);
+ Assert.IsNull(info.OnNodeChecked);
+ Assert.IsNull(info.CanDrag);
+ Assert.IsNull(info.CanDrop);
+ Assert.IsNull(info.CanInsert);
+ Assert.IsNull(info.OnDrop);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Text_Always_ReturnsName()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ var testname = "testName";
+ var categoryTreeFolder = new CategoryTreeFolder(testname, new object[0]);
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Call
+ var text = info.Text(categoryTreeFolder);
+
+ // Assert
+ Assert.AreEqual(testname, text);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Image_TreeFolderOfCategoryGeneral_ReturnsGeneralFolderIcon()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ var categoryTreeFolder = new CategoryTreeFolder("", new object[0]);
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Call
+ var image = info.Image(categoryTreeFolder);
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GeneralFolderIcon, image);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Image_TreeFolderOfCategoryInput_ReturnsInputFolderIcon()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ var categoryTreeFolder = new CategoryTreeFolder("", new object[0], TreeFolderCategory.Input);
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Call
+ var image = info.Image(categoryTreeFolder);
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.InputFolderIcon, image);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Image_TreeFolderOfCategoryOutput_ReturnsOutputFolderIcon()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ var categoryTreeFolder = new CategoryTreeFolder("", new object[0], TreeFolderCategory.Output);
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Call
+ var image = info.Image(categoryTreeFolder);
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.OutputFolderIcon, image);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ChildNodeObjects_Always_ReturnsChildrenOfData()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ var object1 = new object();
+ var object2 = new object();
+ var categoryTreeFolder = new CategoryTreeFolder("", new[]
+ {
+ object1,
+ object2
+ });
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Call
+ var objects = info.ChildNodeObjects(categoryTreeFolder);
+
+ // Assert
+ CollectionAssert.AreEqual(new[]
+ {
+ object1,
+ object2
+ }, objects);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods()
+ {
+ // Setup
+ var gui = mocks.StrictMock();
+ var menuBuilderMock = mocks.StrictMock();
+
+ menuBuilderMock.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.Build()).Return(null);
+ gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ gui.Expect(cmp => cmp.Get(null, treeViewControl)).Return(menuBuilderMock);
+ mocks.ReplayAll();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ plugin.Gui = gui;
+
+ // Call
+ info.ContextMenuStrip(null, null, treeViewControl);
+ }
+ }
+ // Assert
+ mocks.VerifyAll();
+ }
+
+ private TreeNodeInfo GetInfo(RingtoetsPlugin plugin)
+ {
+ return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(CategoryTreeFolder));
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/CommentContextTreeNodeInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/CommentContextTreeNodeInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/CommentContextTreeNodeInfoTest.cs (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -0,0 +1,147 @@
+// 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.Controls.TreeView;
+using Core.Common.Gui;
+using Core.Common.Gui.ContextMenu;
+using Core.Common.Gui.Plugin;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.Integration.Plugin.Test.TreeNodeInfos
+{
+ [TestFixture]
+ public class CommentContextTreeNodeInfoTest
+ {
+ private MockRepository mocks;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks = new MockRepository();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Assert
+ Assert.AreEqual(typeof(Comment), info.TagType);
+ Assert.IsNull(info.EnsureVisibleOnCreate);
+ Assert.IsNull(info.ChildNodeObjects);
+ Assert.IsNull(info.CanRename);
+ Assert.IsNull(info.OnNodeRenamed);
+ Assert.IsNull(info.CanRemove);
+ Assert.IsNull(info.OnNodeRemoved);
+ Assert.IsNull(info.CanCheck);
+ Assert.IsNull(info.IsChecked);
+ Assert.IsNull(info.OnNodeChecked);
+ Assert.IsNull(info.CanDrag);
+ Assert.IsNull(info.CanDrop);
+ Assert.IsNull(info.CanInsert);
+ Assert.IsNull(info.OnDrop);
+ Assert.IsNull(info.ForeColor);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Text_Always_ReturnsName()
+ {
+ // Setup
+ var comment = new Comment();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Call
+ var text = info.Text(comment);
+
+ // Assert
+ Assert.AreEqual("Opmerkingen", text);
+ }
+ }
+
+ [Test]
+ public void Image_Always_ReturnsSetImage()
+ {
+ // Setup
+ var comment = new Comment();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Call
+ var image = info.Image(comment);
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.EditDocumentIcon, image);
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_Always_CallsBuilder()
+ {
+ // Setup
+ using (var plugin = new RingtoetsPlugin())
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var menuBuilderMock = mocks.StrictMock();
+ menuBuilderMock.Expect(mb => mb.AddOpenItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.Build()).Return(null);
+
+ var gui = mocks.StrictMock();
+ gui.Expect(g => g.Get(null, treeViewControl)).Return(menuBuilderMock);
+ gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+
+ var info = GetInfo(plugin);
+
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ // Call
+ info.ContextMenuStrip(null, null, treeViewControl);
+ }
+
+ // Assert
+ mocks.VerifyAll();
+ }
+
+ private TreeNodeInfo GetInfo(PluginBase gui)
+ {
+ return gui.GetTreeNodeInfos().First(tni => tni.TagType == typeof(Comment));
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/DesignWaterLevelLocationsContextTreeNodeInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/DesignWaterLevelLocationsContextTreeNodeInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/DesignWaterLevelLocationsContextTreeNodeInfoTest.cs (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -0,0 +1,423 @@
+// 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;
+using System.Drawing;
+using System.IO;
+using System.Linq;
+using System.Windows.Forms;
+using Core.Common.Base.Data;
+using Core.Common.Controls.TreeView;
+using Core.Common.Gui;
+using Core.Common.Gui.ContextMenu;
+using Core.Common.Gui.Forms.MainWindow;
+using Core.Common.Gui.Forms.ViewHost;
+using Core.Common.Gui.TestUtil.ContextMenu;
+using Core.Common.TestUtil;
+using NUnit.Extensions.Forms;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.HydraRing.Calculation.TestUtil.Calculator;
+using Ringtoets.Integration.Data;
+using Ringtoets.Integration.Forms.PresentationObjects;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.Integration.Plugin.Test.TreeNodeInfos
+{
+ [TestFixture]
+ public class DesignWaterLevelLocationsContextTreeNodeInfoTest : NUnitFormTest
+ {
+ private const int contextMenuRunAssessmentLevelCalculationsIndex = 2;
+ private MockRepository mockRepository;
+ private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Service, "HydraRingCalculation");
+
+ [SetUp]
+ public void SetUp()
+ {
+ mockRepository = new MockRepository();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Assert
+ Assert.AreEqual(typeof(DesignWaterLevelLocationsContext), info.TagType);
+ Assert.IsNull(info.CanCheck);
+ Assert.IsNull(info.IsChecked);
+ Assert.IsNull(info.OnNodeChecked);
+ Assert.IsNull(info.CanDrag);
+ Assert.IsNull(info.CanDrop);
+ Assert.IsNull(info.CanInsert);
+ Assert.IsNull(info.OnDrop);
+ Assert.IsNull(info.EnsureVisibleOnCreate);
+ Assert.IsNull(info.ChildNodeObjects);
+ Assert.IsNull(info.CanRename);
+ Assert.IsNull(info.OnNodeRenamed);
+ Assert.IsNull(info.CanRemove);
+ Assert.IsNull(info.OnNodeRemoved);
+ }
+ }
+
+ [Test]
+ public void Text_Always_ReturnsSetName()
+ {
+ // Setup
+ using (var plugin = new RingtoetsPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+
+ // Call
+ var text = info.Text(null);
+
+ // Assert
+ Assert.AreEqual("Toetspeilen", text);
+ }
+ }
+
+ [Test]
+ public void Image_Always_ReturnsGenericIcon()
+ {
+ // Setup
+ using (var plugin = new RingtoetsPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+
+ // Call
+ var image = info.Image(null);
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, image);
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods()
+ {
+ // Setup
+ var guiMock = mockRepository.StrictMock();
+ var menuBuilderMock = mockRepository.StrictMock();
+ var assessmentSectionMock = mockRepository.Stub();
+
+ var nodeData = new DesignWaterLevelLocationsContext(assessmentSectionMock);
+
+ menuBuilderMock.Expect(mb => mb.AddOpenItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.Build()).Return(null);
+ guiMock.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ guiMock.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ guiMock.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilderMock);
+
+ mockRepository.ReplayAll();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+
+ plugin.Gui = guiMock;
+
+ // Call
+ info.ContextMenuStrip(nodeData, null, treeViewControl);
+ }
+ }
+ // Assert
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void ContextMenuStrip_NoHydraulicBoundaryDatabaseSet_ContextMenuItemBerekenenDisabled()
+ {
+ // Setup
+ var guiMock = mockRepository.StrictMock();
+ var assessmentSectionMock = mockRepository.Stub();
+
+ var nodeData = new DesignWaterLevelLocationsContext(assessmentSectionMock);
+
+ guiMock.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ guiMock.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ guiMock.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
+ mockRepository.ReplayAll();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+
+ plugin.Gui = guiMock;
+
+ // Call
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl))
+ {
+ // Assert
+ const string expectedItemText = "Alles be&rekenen";
+ const string expectedItemTooltip = "Er is geen hydraulische randvoorwaardendatabase beschikbaar om de toetspeilen te berekenen.";
+
+ TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuRunAssessmentLevelCalculationsIndex,
+ expectedItemText, expectedItemTooltip, RingtoetsCommonFormsResources.CalculateAllIcon, false);
+ }
+ }
+ }
+
+ mockRepository.VerifyAll(); // Expect no calls on arguments
+ }
+
+ [Test]
+ public void ContextMenuStrip_HydraulicBoundaryDatabaseSet_ContextMenuItemBerekenenEnabled()
+ {
+ // Setup
+ var assessmentSectionMock = mockRepository.Stub();
+
+ var nodeData = new DesignWaterLevelLocationsContext(assessmentSectionMock)
+ {
+ WrappedData =
+ {
+ HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase()
+ }
+ };
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var guiMock = mockRepository.StrictMock();
+ guiMock.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ guiMock.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+ guiMock.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
+ mockRepository.ReplayAll();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+
+ plugin.Gui = guiMock;
+
+ // Call
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl))
+ {
+ // Assert
+ const string expectedItemText = @"Alles be&rekenen";
+ const string expectedItemTooltip = @"Alle toetspeilen berekenen.";
+
+ TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuRunAssessmentLevelCalculationsIndex,
+ expectedItemText, expectedItemTooltip, RingtoetsCommonFormsResources.CalculateAllIcon);
+ }
+ }
+ }
+
+ mockRepository.VerifyAll(); // Expect no calls on arguments
+ }
+
+ [Test]
+ [RequiresSTA]
+ public void GivenHydraulicBoundaryDatabaseWithNonExistingFilePath_WhenCalculatingAssessmentLevelFromContextMenu_ThenLogMessagesAddedPreviousOutputNotAffected()
+ {
+ // Given
+ var guiMock = mockRepository.DynamicMock();
+ RoundedDouble designWaterLevel = (RoundedDouble) 4.2;
+
+ var hydraulicBoundaryLocation1 = new HydraulicBoundaryLocation(100001, "", 1.1, 2.2);
+ var hydraulicBoundaryLocation2 = new HydraulicBoundaryLocation(100002, "", 3.3, 4.4)
+ {
+ DesignWaterLevelOutput = new TestHydraulicBoundaryLocationOutput(designWaterLevel)
+ };
+
+ var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase
+ {
+ Locations =
+ {
+ hydraulicBoundaryLocation1,
+ hydraulicBoundaryLocation2
+ },
+ FilePath = "D:/nonExistingDirectory/nonExistingFile",
+ Version = "random"
+ };
+
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ HydraulicBoundaryDatabase = hydraulicBoundaryDatabase
+ };
+ var context = new DesignWaterLevelLocationsContext(assessmentSection);
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ guiMock.Expect(g => g.Get(context, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
+ guiMock.Expect(g => g.MainWindow).Return(mockRepository.Stub());
+ guiMock.Expect(g => g.DocumentViewController).Return(mockRepository.Stub());
+
+ mockRepository.ReplayAll();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+ plugin.Gui = guiMock;
+ plugin.Activate();
+
+ using (ContextMenuStrip contextMenuAdapter = info.ContextMenuStrip(context, null, treeViewControl))
+ {
+ // When
+ Action action = () => contextMenuAdapter.Items[contextMenuRunAssessmentLevelCalculationsIndex].PerformClick();
+
+ // Then
+ string message = string.Format("Berekeningen konden niet worden gestart. Fout bij het lezen van bestand '{0}': het bestand bestaat niet.",
+ hydraulicBoundaryDatabase.FilePath);
+ TestHelper.AssertLogMessageWithLevelIsGenerated(action, new Tuple(message, LogLevelConstant.Error));
+
+ Assert.IsNaN(hydraulicBoundaryLocation1.DesignWaterLevel); // No result set
+
+ // Previous result not cleared
+ Assert.AreEqual(designWaterLevel, hydraulicBoundaryLocation2.DesignWaterLevel, hydraulicBoundaryLocation2.DesignWaterLevel.GetAccuracy());
+ }
+ }
+ }
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ [RequiresSTA]
+ public void GivenHydraulicBoundaryLocationThatSucceeds_CalculatingAssessmentLevelFromContextMenu_ThenLogMessagesAddedOutputSet()
+ {
+ // Given
+ var guiMock = mockRepository.DynamicMock();
+
+ var location = new HydraulicBoundaryLocation(1, "locationName", 1.1, 2.2);
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase
+ {
+ Locations =
+ {
+ location
+ },
+ FilePath = Path.Combine(testDataPath, "HRD ijsselmeer.sqlite")
+ }
+ };
+
+ var context = new DesignWaterLevelLocationsContext(assessmentSection);
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ guiMock.Expect(g => g.Get(context, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
+ guiMock.Expect(g => g.MainWindow).Return(mockRepository.Stub());
+ guiMock.Expect(g => g.DocumentViewController).Return(mockRepository.Stub());
+ mockRepository.ReplayAll();
+
+ DialogBoxHandler = (name, wnd) =>
+ {
+ // Expect an activity dialog which is automatically closed
+ };
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+ plugin.Gui = guiMock;
+ plugin.Activate();
+
+ using (ContextMenuStrip contextMenuAdapter = info.ContextMenuStrip(context, null, treeViewControl))
+ using (new HydraRingCalculatorFactoryConfig())
+ {
+ // When
+ Action call = () => contextMenuAdapter.Items[contextMenuRunAssessmentLevelCalculationsIndex].PerformClick();
+
+ // Then
+ TestHelper.AssertLogMessages(call, messages =>
+ {
+ var msgs = messages.ToArray();
+ Assert.AreEqual(7, msgs.Length);
+ StringAssert.StartsWith(string.Format("Validatie van 'Toetspeil berekenen voor locatie '{0}'' gestart om:", location.Name), msgs[0]);
+ StringAssert.StartsWith(string.Format("Validatie van 'Toetspeil berekenen voor locatie '{0}'' beëindigd om:", location.Name), msgs[1]);
+ StringAssert.StartsWith(string.Format("Berekening van 'Toetspeil berekenen voor locatie '{0}'' gestart om:", location.Name), msgs[2]);
+ StringAssert.StartsWith(string.Format("Toetspeil berekening voor locatie {0} is niet geconvergeerd.", location.Name), msgs[3]);
+ StringAssert.StartsWith("Toetspeil berekening is uitgevoerd op de tijdelijke locatie", msgs[4]);
+ StringAssert.StartsWith(string.Format("Berekening van 'Toetspeil berekenen voor locatie '{0}'' beëindigd om:", location.Name), msgs[5]);
+ StringAssert.StartsWith(string.Format("Uitvoeren van 'Toetspeil berekenen voor locatie '{0}'' is gelukt.", location.Name), msgs[6]);
+ });
+ Assert.AreEqual(0, location.DesignWaterLevel, location.DesignWaterLevel.GetAccuracy());
+ Assert.AreEqual(CalculationConvergence.CalculatedNotConverged, location.DesignWaterLevelCalculationConvergence);
+ }
+ }
+ }
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void ForeColor_ContextHasNoHydraulicBoundaryDatabase_ReturnDisabledColor()
+ {
+ // Setup
+ var assessmentSectionMock = mockRepository.Stub();
+ mockRepository.ReplayAll();
+
+ var context = new DesignWaterLevelLocationsContext(assessmentSectionMock);
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+
+ // Call
+ Color color = info.ForeColor(context);
+
+ // Assert
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), color);
+ }
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void ForeColor_ContextHasHydraulicBoundaryDatabase_ReturnControlColor()
+ {
+ // Setup
+ var assessmentSectionMock = mockRepository.Stub();
+ assessmentSectionMock.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase();
+ mockRepository.ReplayAll();
+
+ var context = new DesignWaterLevelLocationsContext(assessmentSectionMock);
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+
+ // Call
+ Color color = info.ForeColor(context);
+
+ // Assert
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), color);
+ }
+ mockRepository.VerifyAll();
+ }
+
+ private static TreeNodeInfo GetInfo(RingtoetsPlugin plugin)
+ {
+ return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(DesignWaterLevelLocationsContext));
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/DikeProfileTreeNodeInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/DikeProfileTreeNodeInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/DikeProfileTreeNodeInfoTest.cs (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -0,0 +1,264 @@
+// 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.Drawing;
+using System.Linq;
+using Core.Common.Base;
+using Core.Common.Base.Geometry;
+using Core.Common.Controls.TreeView;
+using Core.Common.Gui;
+using Core.Common.Gui.ContextMenu;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.DikeProfiles;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.GrassCoverErosionInwards.Data;
+using Ringtoets.GrassCoverErosionInwards.Forms.PresentationObjects;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.Integration.Plugin.Test.TreeNodeInfos
+{
+ [TestFixture]
+ public class DikeProfileTreeNodeInfoTest
+ {
+ private RingtoetsPlugin plugin;
+ private TreeNodeInfo info;
+
+ [SetUp]
+ public void SetUp()
+ {
+ plugin = new RingtoetsPlugin();
+ info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(DikeProfile));
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ plugin.Dispose();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Assert
+ Assert.AreEqual(typeof(DikeProfile), info.TagType);
+ Assert.IsNotNull(info.Text);
+ Assert.IsNotNull(info.Image);
+ Assert.IsNotNull(info.ContextMenuStrip);
+ Assert.IsNull(info.ForeColor);
+ Assert.IsNull(info.ChildNodeObjects);
+ Assert.IsNull(info.EnsureVisibleOnCreate);
+ Assert.IsNull(info.CanRename);
+ Assert.IsNull(info.OnNodeRenamed);
+ Assert.IsNull(info.CanCheck);
+ Assert.IsNull(info.IsChecked);
+ Assert.IsNull(info.OnNodeChecked);
+ Assert.IsNull(info.CanDrag);
+ Assert.IsNull(info.CanDrop);
+ Assert.IsNull(info.CanInsert);
+ Assert.IsNull(info.OnDrop);
+ }
+
+ [Test]
+ public void Text_Always_ReturnDikeProfileName()
+ {
+ // Setup
+ const string profileName = "Random profile name";
+ DikeProfile dikeProfile = new TestDikeProfile(profileName);
+
+ // Call
+ string text = info.Text(dikeProfile);
+
+ // Assert
+ Assert.AreEqual(profileName, text);
+ }
+
+ [Test]
+ public void Image_Always_ReturnExpectedImage()
+ {
+ // Call
+ Image image = info.Image(null);
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.DikeProfile, image);
+ }
+
+ [Test]
+ public void CanRemove_ParentIsDikeProfilesContext_ReturnTrue()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();
+
+ var parentData = new DikeProfilesContext(failureMechanism.DikeProfiles, failureMechanism, assessmentSection);
+
+ // Call
+ bool canRemove = info.CanRemove(null, parentData);
+
+ // Assert
+ Assert.IsTrue(canRemove);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void CanRemove_ParentIsNotDikeProfilesContext_ReturnFalse()
+ {
+ // Call
+ bool canRemove = info.CanRemove(null, null);
+
+ // Assert
+ Assert.IsFalse(canRemove);
+ }
+
+ [Test]
+ public void OnNodeRemoved_RemovingProfileAssignedToCalculationOfSectionResult_ProfileRemovedFromFailureMechanismAndCalculationProfileClearedAndSectionResultCalculationCleared()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ var observer = mocks.StrictMock();
+ observer.Expect(o => o.UpdateObserver());
+ var calculation1Observer = mocks.StrictMock();
+ calculation1Observer.Expect(o => o.UpdateObserver());
+ var calculation2Observer = mocks.StrictMock();
+ calculation2Observer.Expect(o => o.UpdateObserver()).Repeat.Never();
+ var calculation3Observer = mocks.StrictMock();
+ calculation3Observer.Expect(o => o.UpdateObserver()).Repeat.Never();
+ mocks.ReplayAll();
+
+ DikeProfile nodeData = new TestDikeProfile(new Point2D(1, 0));
+ DikeProfile otherProfile1 = new TestDikeProfile(new Point2D(2, 0));
+ DikeProfile otherProfile2 = new TestDikeProfile(new Point2D(7, 0));
+
+ var calculation1 = new GrassCoverErosionInwardsCalculation
+ {
+ InputParameters =
+ {
+ DikeProfile = nodeData
+ }
+ };
+ calculation1.InputParameters.Attach(calculation1Observer);
+ var calculation2 = new GrassCoverErosionInwardsCalculation
+ {
+ InputParameters =
+ {
+ DikeProfile = otherProfile1
+ }
+ };
+ calculation2.InputParameters.Attach(calculation2Observer);
+ var calculation3 = new GrassCoverErosionInwardsCalculation
+ {
+ InputParameters =
+ {
+ DikeProfile = otherProfile2
+ }
+ };
+ calculation3.InputParameters.Attach(calculation3Observer);
+
+ var failureMechanism = new GrassCoverErosionInwardsFailureMechanism
+ {
+ DikeProfiles =
+ {
+ nodeData,
+ otherProfile1,
+ otherProfile2
+ },
+ CalculationsGroup =
+ {
+ Children =
+ {
+ calculation1,
+ calculation2
+ }
+ }
+ };
+ failureMechanism.AddSection(new FailureMechanismSection("A", new[]
+ {
+ new Point2D(0, 0),
+ new Point2D(4, 0)
+ }));
+ failureMechanism.AddSection(new FailureMechanismSection("B", new[]
+ {
+ new Point2D(4, 0),
+ new Point2D(9, 0)
+ }));
+ failureMechanism.DikeProfiles.Attach(observer);
+ failureMechanism.SectionResults.ElementAt(0).Calculation = calculation1;
+ failureMechanism.SectionResults.ElementAt(1).Calculation = calculation3;
+
+ var parentData = new DikeProfilesContext(failureMechanism.DikeProfiles, failureMechanism, assessmentSection);
+
+ // Call
+ info.OnNodeRemoved(nodeData, parentData);
+
+ // Assert
+ CollectionAssert.DoesNotContain(failureMechanism.DikeProfiles, nodeData);
+
+ Assert.IsNull(calculation1.InputParameters.DikeProfile);
+ Assert.IsNotNull(calculation2.InputParameters.DikeProfile);
+
+ Assert.AreSame(calculation2, failureMechanism.SectionResults.ElementAt(0).Calculation);
+ Assert.AreSame(calculation3, failureMechanism.SectionResults.ElementAt(1).Calculation);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ContextMenuStrip_Always_CallsBuilder()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var menuBuilderMock = mocks.StrictMock();
+ menuBuilderMock.Expect(mb => mb.AddDeleteItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.Build()).Return(null);
+
+ var gui = mocks.Stub();
+ gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ gui.Stub(g => g.Get(null, treeViewControl)).Return(menuBuilderMock);
+
+ mocks.ReplayAll();
+
+ using (var p = new RingtoetsPlugin())
+ {
+ p.Gui = gui;
+ var i = p.GetTreeNodeInfos().First(tni => tni.TagType == typeof(DikeProfile));
+
+ // Call
+ i.ContextMenuStrip(null, null, treeViewControl);
+ }
+ }
+
+ // Assert
+ mocks.VerifyAll();
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/EmptyProbabilityAssessmentOutputTreeNodeInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/EmptyProbabilityAssessmentOutputTreeNodeInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/EmptyProbabilityAssessmentOutputTreeNodeInfoTest.cs (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -0,0 +1,80 @@
+// 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.Controls.TreeView;
+using Core.Common.Gui;
+using Core.Common.Gui.ContextMenu;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.Probability;
+
+namespace Ringtoets.Integration.Plugin.Test.TreeNodeInfos
+{
+ [TestFixture]
+ public class EmptyProbabilityAssessmentOutputTreeNodeInfoTest
+ {
+ private MockRepository mocksRepository;
+ private RingtoetsPlugin plugin;
+ private TreeNodeInfo info;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocksRepository = new MockRepository();
+ plugin = new RingtoetsPlugin();
+ info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(EmptyProbabilityAssessmentOutput));
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ plugin.Dispose();
+ mocksRepository.VerifyAll();
+ }
+
+ [Test]
+ public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods()
+ {
+ // Setup
+ var guiMock = mocksRepository.StrictMock();
+ var menuBuilderMock = mocksRepository.StrictMock();
+
+ menuBuilderMock.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.Build()).Return(null);
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ guiMock.Expect(cmp => cmp.Get(null, treeViewControl)).Return(menuBuilderMock);
+ guiMock.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ guiMock.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+ mocksRepository.ReplayAll();
+
+ plugin.Gui = guiMock;
+
+ // Call
+ info.ContextMenuStrip(null, null, treeViewControl);
+ }
+ // Assert
+ // Assert expectancies are called in TearDown()
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/FailureMechanismContextTreeNodeInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/FailureMechanismContextTreeNodeInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/FailureMechanismContextTreeNodeInfoTest.cs (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -0,0 +1,530 @@
+// 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;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Reflection;
+using System.Windows.Forms;
+using Core.Common.Base;
+using Core.Common.Base.Geometry;
+using Core.Common.Controls.TreeView;
+using Core.Common.Gui;
+using Core.Common.Gui.Commands;
+using Core.Common.Gui.ContextMenu;
+using Core.Common.Gui.TestUtil.ContextMenu;
+using Core.Common.TestUtil;
+using Core.Common.Utils.Reflection;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.Common.Forms.PresentationObjects;
+using Ringtoets.DuneErosion.Data;
+using Ringtoets.Integration.Data.StandAlone.SectionResults;
+using Ringtoets.StabilityStoneCover.Data;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.Integration.Plugin.Test.TreeNodeInfos
+{
+ [TestFixture]
+ public class FailureMechanismContextTreeNodeInfoTest
+ {
+ private const int contextMenuRelevancyIndexWhenNotRelevant = 0;
+ private const int contextMenuRelevancyIndexWhenRelevant = 2;
+ private MockRepository mocks;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks = new MockRepository();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Assert
+ Assert.AreEqual(typeof(FailureMechanismContext), info.TagType);
+ Assert.IsNull(info.EnsureVisibleOnCreate);
+ Assert.IsNull(info.CanRename);
+ Assert.IsNull(info.OnNodeRenamed);
+ Assert.IsNull(info.CanRemove);
+ Assert.IsNull(info.OnNodeRemoved);
+ Assert.IsNull(info.CanCheck);
+ Assert.IsNull(info.IsChecked);
+ Assert.IsNull(info.OnNodeChecked);
+ Assert.IsNull(info.CanDrag);
+ Assert.IsNull(info.CanDrop);
+ Assert.IsNull(info.CanInsert);
+ Assert.IsNull(info.OnDrop);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Text_Always_ReturnsName()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new TestFailureMechanism("name", "code");
+ var failureMechanismContext = new FailureMechanismContext(failureMechanism, assessmentSection);
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Call
+ var text = info.Text(failureMechanismContext);
+
+ // Assert
+ Assert.AreEqual(failureMechanism.Name, text);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Image_Always_ReturnsSetImage()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Call
+ var image = info.Image(null);
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.FailureMechanismIcon, image);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ForeColor_Always_ReturnsControlText()
+ {
+ // Setup
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new TestFailureMechanism("C", "C");
+ var context = new FailureMechanismContext(failureMechanism, assessmentSection);
+
+ // Call
+ var textColor = info.ForeColor(context);
+
+ // Assert
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), textColor);
+
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void ChildNodeObjects_FailureMechanismIsRelevant_ReturnFoldersWithInputAndOutput()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ var failureMechanism = new TestFailureMechanism("test", "C");
+ var failureMechanismContext = mocks.Stub>(failureMechanism, assessmentSection);
+
+ mocks.ReplayAll();
+
+ // Call
+ object[] children = info.ChildNodeObjects(failureMechanismContext).ToArray();
+
+ // Assert
+ Assert.AreEqual(2, children.Length);
+ var inputFolder = (CategoryTreeFolder) children[0];
+ Assert.AreEqual("Invoer", inputFolder.Name);
+ Assert.AreEqual(TreeFolderCategory.Input, inputFolder.Category);
+
+ var failureMechanismSectionsContext = (FailureMechanismSectionsContext) inputFolder.Contents[0];
+ Assert.AreSame(failureMechanism, failureMechanismSectionsContext.WrappedData);
+ Assert.AreSame(assessmentSection, failureMechanismSectionsContext.ParentAssessmentSection);
+
+ var inputComment = (Comment) inputFolder.Contents[1];
+ Assert.AreSame(failureMechanism.InputComments, inputComment);
+
+ var outputFolder = (CategoryTreeFolder) children[1];
+ Assert.AreEqual("Oordeel", outputFolder.Name);
+ Assert.AreEqual(TreeFolderCategory.Output, outputFolder.Category);
+
+ var outputComment = (Comment) outputFolder.Contents[0];
+ Assert.AreSame(failureMechanism.OutputComments, outputComment);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [TestCase(typeof(DuneErosionFailureMechanismSectionResult),
+ TestName = "ChildNodeObjects_FailureMechanismIsRelevant_OutputNodeAddedForResult(DuneErosionFailureMechanismSectionResult)")]
+ [TestCase(typeof(GrassCoverSlipOffInwardsFailureMechanismSectionResult),
+ TestName = "ChildNodeObjects_FailureMechanismIsRelevant_OutputNodeAddedForResult(GrassCoverSlipOffInwardsFailureMechanismSectionResult)")]
+ [TestCase(typeof(GrassCoverSlipOffOutwardsFailureMechanismSectionResult),
+ TestName = "ChildNodeObjects_FailureMechanismIsRelevant_OutputNodeAddedForResult(GrassCoverSlipOffOutwardsFailureMechanismSectionResult)")]
+ [TestCase(typeof(MicrostabilityFailureMechanismSectionResult),
+ TestName = "ChildNodeObjects_FailureMechanismIsRelevant_OutputNodeAddedForResult(MicrostabilityFailureMechanismSectionResult)")]
+ [TestCase(typeof(PipingStructureFailureMechanismSectionResult),
+ TestName = "ChildNodeObjects_FailureMechanismIsRelevant_OutputNodeAddedForResult(PipingStructureFailureMechanismSectionResult)")]
+ [TestCase(typeof(StabilityStoneCoverFailureMechanismSectionResult),
+ TestName = "ChildNodeObjects_FailureMechanismIsRelevant_OutputNodeAddedForResult(StabilityStoneCoverFailureMechanismSectionResult)")]
+ [TestCase(typeof(TechnicalInnovationFailureMechanismSectionResult),
+ TestName = "ChildNodeObjects_FailureMechanismIsRelevant_OutputNodeAddedForResult(TechnicalInnovationFailureMechanismSectionResult)")]
+ [TestCase(typeof(StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult),
+ TestName = "ChildNodeObjects_FailureMechanismIsRelevant_OutputNodeAddedForResult(StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult)")]
+ [TestCase(typeof(WaterPressureAsphaltCoverFailureMechanismSectionResult),
+ TestName = "ChildNodeObjects_FailureMechanismIsRelevant_OutputNodeAddedForResult(WaterPressureAsphaltCoverFailureMechanismSectionResult)")]
+ [TestCase(typeof(MacrostabilityInwardsFailureMechanismSectionResult),
+ TestName = "ChildNodeObjects_FailureMechanismIsRelevant_OutputNodeAddedForResult(MacrostabilityInwardsFailureMechanismSectionResult)")]
+ [TestCase(typeof(MacrostabilityOutwardsFailureMechanismSectionResult),
+ TestName = "ChildNodeObjects_FailureMechanismIsRelevant_OutputNodeAddedForResult(MacrostabilityOutwardsFailureMechanismSectionResult)")]
+ public void ChildNodeObjects_FailureMechanismIsRelevant_OutputNodeAddedForResult(Type t)
+ {
+ // Delegate actual test
+ MethodInfo method = GetType().GetMethod(
+ TypeUtils.GetMemberName(
+ s => s.ChildNodeObjects_FailureMechanismIsRelevantWithSectionResults_OutputNodeAdded()),
+ BindingFlags.NonPublic | BindingFlags.Instance);
+ MethodInfo genericMethod = method.MakeGenericMethod(t);
+ genericMethod.Invoke(this, null);
+ }
+
+ [Test]
+ public void ChildNodeObjects_FailureMechanismIsNotRelevant_ReturnOnlyFailureMechanismNotRelevantComments()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ var failureMechanism = new TestFailureMechanism("test", "C")
+ {
+ IsRelevant = false
+ };
+ failureMechanism.AddSection(new FailureMechanismSection("A", new[]
+ {
+ new Point2D(1, 2),
+ new Point2D(5, 6)
+ }));
+ var failureMechanismContext = new FailureMechanismContext(failureMechanism, assessmentSection);
+
+ // Call
+ object[] children = info.ChildNodeObjects(failureMechanismContext).ToArray();
+
+ // Assert
+ Assert.AreEqual(1, children.Length);
+ var comment = (Comment) children[0];
+ Assert.AreSame(failureMechanism.NotRelevantComments, comment);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ContextMenuStrip_FailureMechanismIsRelevant_CallsContextMenuBuilderMethods()
+ {
+ // Setup
+ using (var treeView = new TreeViewControl())
+ {
+ var failureMechanism = new TestFailureMechanism("A", "C");
+ var assessmentSection = mocks.Stub();
+ var context = new FailureMechanismContext(failureMechanism, assessmentSection);
+
+ var gui = mocks.StrictMock();
+ var menuBuilderMock = mocks.StrictMock();
+
+ menuBuilderMock.Expect(mb => mb.AddOpenItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.Build()).Return(null);
+
+ gui.Expect(cmp => cmp.Get(context, treeView)).Return(menuBuilderMock);
+ gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+
+ mocks.ReplayAll();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ plugin.Gui = gui;
+
+ // Call
+ info.ContextMenuStrip(context, assessmentSection, treeView);
+ }
+ // Assert
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_FailureMechanismIsNotRelevant_CallsContextMenuBuilderMethods()
+ {
+ // Setup
+ using (var treeView = new TreeViewControl())
+ {
+ var failureMechanism = new TestFailureMechanism("A", "C")
+ {
+ IsRelevant = false
+ };
+ var assessmentSection = mocks.Stub();
+ var context = new FailureMechanismContext(failureMechanism, assessmentSection);
+
+ var gui = mocks.StrictMock();
+ var menuBuilderMock = mocks.StrictMock();
+
+ menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.Build()).Return(null);
+
+ gui.Expect(cmp => cmp.Get(context, treeView)).Return(menuBuilderMock);
+ gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+
+ mocks.ReplayAll();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ plugin.Gui = gui;
+
+ // Call
+ info.ContextMenuStrip(context, assessmentSection, treeView);
+ }
+ // Assert
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_FailureMechanismIsRelevant_IsRelevantEnabled()
+ {
+ // Setup
+ using (var treeView = new TreeViewControl())
+ {
+ var assessmentSection = mocks.Stub();
+ var failureMechanism = new TestFailureMechanism("A", "C");
+ var context = new FailureMechanismContext(failureMechanism, assessmentSection);
+
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+
+ var gui = mocks.StrictMock();
+ gui.Expect(cmp => cmp.Get(context, treeView)).Return(menuBuilder);
+ gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+
+ mocks.ReplayAll();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ plugin.Gui = gui;
+
+ var info = GetInfo(plugin);
+
+ // Call
+ using (ContextMenuStrip menu = info.ContextMenuStrip(context, assessmentSection, treeView))
+ {
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuRelevancyIndexWhenRelevant,
+ RingtoetsCommonFormsResources.FailureMechanismContextMenuStrip_Is_relevant,
+ RingtoetsCommonFormsResources.FailureMechanismContextMenuStrip_Is_relevant_Tooltip,
+ RingtoetsCommonFormsResources.Checkbox_ticked);
+ }
+ }
+
+ // Assert
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_FailureMechanismIsRelevantAndClickOnIsRelevantItem_MakeFailureMechanismNotRelevant()
+ {
+ // Setup
+ var failureMechanismObserver = mocks.Stub();
+ failureMechanismObserver.Expect(o => o.UpdateObserver());
+
+ var failureMechanism = new TestFailureMechanism("A", "C")
+ {
+ IsRelevant = true
+ };
+ failureMechanism.Attach(failureMechanismObserver);
+
+ var assessmentSection = mocks.Stub();
+ var failureMechanismContext = new FailureMechanismContext(failureMechanism, assessmentSection);
+
+ var viewCommands = mocks.StrictMock();
+ viewCommands.Expect(vs => vs.RemoveAllViewsForItem(failureMechanismContext));
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+
+ var gui = mocks.StrictMock();
+ gui.Stub(g => g.ViewCommands).Return(viewCommands);
+ gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+ gui.Expect(g => g.Get(failureMechanismContext, treeViewControl)).Return(menuBuilder);
+
+ mocks.ReplayAll();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ plugin.Gui = gui;
+
+ var info = GetInfo(plugin);
+
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(failureMechanismContext, null, treeViewControl))
+ {
+ // Call
+ contextMenu.Items[contextMenuRelevancyIndexWhenRelevant].PerformClick();
+
+ // Assert
+ Assert.IsFalse(failureMechanism.IsRelevant);
+ }
+ }
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ContextMenuStrip_FailureMechanismIsNotRelevantAndClickOnIsRelevantItem_MakeFailureMechanismRelevant()
+ {
+ // Setup
+ var failureMechanismObserver = mocks.Stub();
+ failureMechanismObserver.Expect(o => o.UpdateObserver());
+
+ var failureMechanism = new TestFailureMechanism("A", "C")
+ {
+ IsRelevant = false
+ };
+ failureMechanism.Attach(failureMechanismObserver);
+
+ var assessmentSection = mocks.Stub();
+ var failureMechanismContext = new FailureMechanismContext(failureMechanism, assessmentSection);
+
+ var viewCommands = mocks.StrictMock();
+ viewCommands.Expect(vs => vs.RemoveAllViewsForItem(failureMechanismContext));
+
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+
+ var gui = mocks.StrictMock();
+ gui.Stub(g => g.ViewCommands).Return(viewCommands);
+ gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ gui.Expect(g => g.Get(failureMechanismContext, treeViewControl)).Return(menuBuilder);
+
+ mocks.ReplayAll();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ plugin.Gui = gui;
+
+ var info = GetInfo(plugin);
+
+ using (var contextMenu = info.ContextMenuStrip(failureMechanismContext, null, treeViewControl))
+ {
+ // Call
+ contextMenu.Items[contextMenuRelevancyIndexWhenNotRelevant].PerformClick();
+
+ // Assert
+ Assert.IsTrue(failureMechanism.IsRelevant);
+ }
+ }
+ }
+ mocks.VerifyAll();
+ }
+
+ ///
+ /// Used in ChildNodeObjects_FailureMechanismIsRelevant_OutputNodeAddedForResult(Type)
+ ///
+ private void ChildNodeObjects_FailureMechanismIsRelevantWithSectionResults_OutputNodeAdded() where T : FailureMechanismSectionResult
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ var failureMechanism = mocks.StrictMultiMock>(typeof(IFailureMechanism));
+ failureMechanism.Expect(fm => ((IFailureMechanism) fm).IsRelevant).Return(true);
+ failureMechanism.Expect(fm => fm.SectionResults).Return(new List()).Repeat.Any();
+ failureMechanism.Expect(fm => ((IFailureMechanism) fm).InputComments).Return(new Comment());
+ failureMechanism.Expect(fm => ((IFailureMechanism) fm).OutputComments).Return(new Comment());
+ var failureMechanismContext = mocks.Stub>(failureMechanism, assessmentSection);
+
+ mocks.ReplayAll();
+
+ // Call
+ object[] children = info.ChildNodeObjects(failureMechanismContext).ToArray();
+
+ // Assert
+ var outputFolder = (CategoryTreeFolder) children[1];
+
+ var failureMechanismResultsContext = (FailureMechanismSectionResultContext) outputFolder.Contents[0];
+ Assert.AreSame(failureMechanism, failureMechanismResultsContext.FailureMechanism);
+ Assert.AreSame(failureMechanism.SectionResults, failureMechanismResultsContext.WrappedData);
+ }
+ mocks.VerifyAll();
+ }
+
+ private TreeNodeInfo GetInfo(RingtoetsPlugin plugin)
+ {
+ return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(FailureMechanismContext));
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/FailureMechanismContributionContextTreeNodeInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/FailureMechanismContributionContextTreeNodeInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/FailureMechanismContributionContextTreeNodeInfoTest.cs (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -0,0 +1,157 @@
+// 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.Controls.TreeView;
+using Core.Common.Gui;
+using Core.Common.Gui.ContextMenu;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.Contribution;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Forms.PresentationObjects;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.Integration.Plugin.Test.TreeNodeInfos
+{
+ [TestFixture]
+ public class FailureMechanismContributionContextTreeNodeInfoTest
+ {
+ private MockRepository mocks;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks = new MockRepository();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Assert
+ Assert.AreEqual(typeof(FailureMechanismContributionContext), info.TagType);
+ Assert.IsNull(info.ForeColor);
+ Assert.IsNull(info.EnsureVisibleOnCreate);
+ Assert.IsNull(info.ChildNodeObjects);
+ Assert.IsNull(info.CanRename);
+ Assert.IsNull(info.OnNodeRenamed);
+ Assert.IsNull(info.CanRemove);
+ Assert.IsNull(info.OnNodeRemoved);
+ Assert.IsNull(info.CanCheck);
+ Assert.IsNull(info.IsChecked);
+ Assert.IsNull(info.OnNodeChecked);
+ Assert.IsNull(info.CanDrag);
+ Assert.IsNull(info.CanDrop);
+ Assert.IsNull(info.CanInsert);
+ Assert.IsNull(info.OnDrop);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Text_Always_ReturnsTextFromResource()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Call
+ var text = info.Text(null);
+
+ // Assert
+ Assert.AreEqual("Faalkansbegroting", text);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Image_Always_ReturnsSetImage()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Call
+ var image = info.Image(null);
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.FailureMechanismContributionIcon, image);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods()
+ {
+ // Setup
+ var contribution = new FailureMechanismContribution(Enumerable.Empty(), 100.0, 1.0/150000);
+
+ var assessmentSection = mocks.Stub();
+ var context = new FailureMechanismContributionContext(contribution, assessmentSection);
+
+ var menuBuilderMock = mocks.StrictMock();
+ menuBuilderMock.Expect(mb => mb.AddOpenItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.Build()).Return(null);
+
+ var gui = mocks.StrictMock();
+ gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ gui.Expect(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilderMock);
+ mocks.ReplayAll();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ plugin.Gui = gui;
+
+ // Call
+ info.ContextMenuStrip(context, null, treeViewControl);
+ }
+ }
+ // Assert
+ mocks.VerifyAll();
+ }
+
+ private TreeNodeInfo GetInfo(RingtoetsPlugin plugin)
+ {
+ return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(FailureMechanismContributionContext));
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/FailureMechanismSectionsContextTreeNodeInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/FailureMechanismSectionsContextTreeNodeInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/FailureMechanismSectionsContextTreeNodeInfoTest.cs (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -0,0 +1,211 @@
+// 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.Drawing;
+using System.Linq;
+using Core.Common.Base.Geometry;
+using Core.Common.Controls.TreeView;
+using Core.Common.Gui;
+using Core.Common.Gui.ContextMenu;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Forms.PresentationObjects;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.Integration.Plugin.Test.TreeNodeInfos
+{
+ [TestFixture]
+ public class FailureMechanismSectionsContextTreeNodeInfoTest
+ {
+ private MockRepository mocks;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks = new MockRepository();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Assert
+ Assert.AreEqual(typeof(FailureMechanismSectionsContext), info.TagType);
+ Assert.IsNull(info.EnsureVisibleOnCreate);
+ Assert.IsNull(info.CanRename);
+ Assert.IsNull(info.OnNodeRenamed);
+ Assert.IsNull(info.CanRemove);
+ Assert.IsNull(info.OnNodeRemoved);
+ Assert.IsNull(info.ChildNodeObjects);
+ Assert.IsNull(info.CanCheck);
+ Assert.IsNull(info.IsChecked);
+ Assert.IsNull(info.OnNodeChecked);
+ Assert.IsNull(info.CanDrag);
+ Assert.IsNull(info.CanDrop);
+ Assert.IsNull(info.CanInsert);
+ Assert.IsNull(info.OnDrop);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Text_Always_ReturnsName()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Call
+ var text = info.Text(null);
+
+ // Assert
+ Assert.AreEqual("Vakindeling", text);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Image_Always_ReturnSectionsIcon()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Call
+ var image = info.Image(null);
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.SectionsIcon, image);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods()
+ {
+ // Setup
+ var menuBuilderMock = mocks.StrictMock();
+ menuBuilderMock.Expect(mb => mb.AddImportItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.Build()).Return(null);
+
+ var failureMechanism = mocks.Stub();
+ var assessmentSection = mocks.Stub();
+ var context = new FailureMechanismSectionsContext(failureMechanism, assessmentSection);
+
+ var gui = mocks.StrictMock();
+ gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ gui.Expect(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilderMock);
+ mocks.ReplayAll();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ plugin.Gui = gui;
+
+ // Call
+ info.ContextMenuStrip(context, null, treeViewControl);
+ }
+ }
+ // Assert
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ForeColor_NoSectionsOnFailureMechanism_ReturnGrayText()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ var failureMechanism = mocks.Stub();
+ failureMechanism.Stub(fm => fm.Sections).Return(Enumerable.Empty());
+ mocks.ReplayAll();
+
+ var context = new FailureMechanismSectionsContext(failureMechanism, assessmentSection);
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Call
+ Color color = info.ForeColor(context);
+
+ // Assert
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), color);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ForeColor_HasSectionsOnFailureMechanism_ReturnControlText()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ var failureMechanism = mocks.Stub();
+ failureMechanism.Stub(fm => fm.Sections).Return(new[]
+ {
+ new FailureMechanismSection("A", new[]
+ {
+ new Point2D(3, 4),
+ new Point2D(5, 6)
+ }),
+ });
+ mocks.ReplayAll();
+
+ var context = new FailureMechanismSectionsContext(failureMechanism, assessmentSection);
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Call
+ Color color = info.ForeColor(context);
+
+ // Assert
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), color);
+ }
+ mocks.VerifyAll();
+ }
+
+ private TreeNodeInfo GetInfo(RingtoetsPlugin plugin)
+ {
+ return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(FailureMechanismSectionsContext));
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/ForeshoreProfileTreeNodeInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/ForeshoreProfileTreeNodeInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/ForeshoreProfileTreeNodeInfoTest.cs (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -0,0 +1,787 @@
+// 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.Drawing;
+using System.Linq;
+using Core.Common.Base;
+using Core.Common.Controls.TreeView;
+using Core.Common.Gui;
+using Core.Common.Gui.ContextMenu;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.ClosingStructures.Data;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.Calculation;
+using Ringtoets.Common.Data.DikeProfiles;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Data.Structures;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.Common.Forms.PresentationObjects;
+using Ringtoets.GrassCoverErosionOutwards.Data;
+using Ringtoets.HeightStructures.Data;
+using Ringtoets.Integration.Plugin.Properties;
+using Ringtoets.StabilityPointStructures.Data;
+using Ringtoets.StabilityStoneCover.Data;
+using Ringtoets.WaveImpactAsphaltCover.Data;
+
+namespace Ringtoets.Integration.Plugin.Test.TreeNodeInfos
+{
+ [TestFixture]
+ public class ForeshoreProfileTreeNodeInfoTest
+ {
+ private RingtoetsPlugin plugin;
+ private TreeNodeInfo info;
+
+ [SetUp]
+ public void SetUp()
+ {
+ plugin = new RingtoetsPlugin();
+ info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(ForeshoreProfile));
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ plugin.Dispose();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Assert
+ Assert.AreEqual(typeof(ForeshoreProfile), info.TagType);
+ Assert.IsNotNull(info.Text);
+ Assert.IsNotNull(info.Image);
+ Assert.IsNotNull(info.ContextMenuStrip);
+ Assert.IsNull(info.ForeColor);
+ Assert.IsNull(info.ChildNodeObjects);
+ Assert.IsNull(info.EnsureVisibleOnCreate);
+ Assert.IsNull(info.CanRename);
+ Assert.IsNull(info.OnNodeRenamed);
+ Assert.IsNull(info.CanCheck);
+ Assert.IsNull(info.IsChecked);
+ Assert.IsNull(info.OnNodeChecked);
+ Assert.IsNull(info.CanDrag);
+ Assert.IsNull(info.CanDrop);
+ Assert.IsNull(info.CanInsert);
+ Assert.IsNull(info.OnDrop);
+ }
+
+ [Test]
+ public void Text_Always_ReturnForeshoreProfileName()
+ {
+ // Setup
+ const string profileName = "Random profile name";
+ ForeshoreProfile foreshoreProfile = new TestForeshoreProfile(profileName);
+
+ // Call
+ string text = info.Text(foreshoreProfile);
+
+ // Assert
+ Assert.AreEqual(profileName, text);
+ }
+
+ [Test]
+ public void Image_Always_ReturnExpectedImage()
+ {
+ // Call
+ Image image = info.Image(null);
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(Resources.Foreshore, image);
+ }
+
+ [Test]
+ public void CanRemove_ParentFailureMechanismIsStabilityStoneCover_ReturnTrue()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+
+ var parentData = new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection);
+
+ // Call
+ bool canRemove = info.CanRemove(null, parentData);
+
+ // Assert
+ Assert.IsTrue(canRemove);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void CanRemove_ParentFailureMechanismIsWaveImpactAsphaltCover_ReturnTrue()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism();
+
+ var parentData = new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection);
+
+ // Call
+ bool canRemove = info.CanRemove(null, parentData);
+
+ // Assert
+ Assert.IsTrue(canRemove);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void CanRemove_ParentFailureMechanismIsGrassCoverErosionOutwards_ReturnTrue()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism();
+
+ var parentData = new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection);
+
+ // Call
+ bool canRemove = info.CanRemove(null, parentData);
+
+ // Assert
+ Assert.IsTrue(canRemove);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void CanRemove_ParentFailureMechanismIsHeightStructures_ReturnTrue()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new HeightStructuresFailureMechanism();
+
+ var parentData = new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection);
+
+ // Call
+ bool canRemove = info.CanRemove(null, parentData);
+
+ // Assert
+ Assert.IsTrue(canRemove);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void CanRemove_ParentFailureMechanismIsClosingStructures_ReturnTrue()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new ClosingStructuresFailureMechanism();
+
+ var parentData = new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection);
+
+ // Call
+ bool canRemove = info.CanRemove(null, parentData);
+
+ // Assert
+ Assert.IsTrue(canRemove);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void CanRemove_ParentFailureMechanismIsStabilityPointStructures_ReturnTrue()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+
+ var parentData = new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection);
+
+ // Call
+ bool canRemove = info.CanRemove(null, parentData);
+
+ // Assert
+ Assert.IsTrue(canRemove);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void CanRemove_UnsupportedFailureMechanism_ReturnFalse()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ var failureMechanism = mocks.Stub();
+ mocks.ReplayAll();
+
+ var list = new ObservableList();
+
+ var parentData = new ForeshoreProfilesContext(list, failureMechanism, assessmentSection);
+
+ // Call
+ bool canRemove = info.CanRemove(null, parentData);
+
+ // Assert
+ Assert.IsFalse(canRemove);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void OnNodeRemoved_ForeshoreProfileOfStabilityStoneCoverWaveConditionsCalculation_ForeshoreProfileRemovedFromFailureMechanismAndCalculationForeshoreProfileCleared()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ var observer = mocks.Stub();
+ observer.Expect(o => o.UpdateObserver());
+ var calculation1Observer = mocks.StrictMock();
+ calculation1Observer.Expect(o => o.UpdateObserver());
+ var calculation2Observer = mocks.StrictMock();
+ calculation2Observer.Expect(o => o.UpdateObserver());
+ var calculation3Observer = mocks.StrictMock();
+ calculation3Observer.Expect(o => o.UpdateObserver()).Repeat.Never();
+ mocks.ReplayAll();
+
+ ForeshoreProfile nodeData = new TestForeshoreProfile("A");
+ ForeshoreProfile otherProfile = new TestForeshoreProfile("B");
+
+ var calculation1 = new StabilityStoneCoverWaveConditionsCalculation
+ {
+ InputParameters =
+ {
+ ForeshoreProfile = nodeData
+ }
+ };
+ calculation1.InputParameters.Attach(calculation1Observer);
+ var calculation2 = new StabilityStoneCoverWaveConditionsCalculation
+ {
+ InputParameters =
+ {
+ ForeshoreProfile = nodeData
+ }
+ };
+ calculation2.InputParameters.Attach(calculation2Observer);
+ var calculation3 = new StabilityStoneCoverWaveConditionsCalculation
+ {
+ InputParameters =
+ {
+ ForeshoreProfile = otherProfile
+ }
+ };
+ calculation3.InputParameters.Attach(calculation3Observer);
+
+ var failureMechanism = new StabilityStoneCoverFailureMechanism
+ {
+ ForeshoreProfiles =
+ {
+ nodeData,
+ otherProfile
+ },
+ WaveConditionsCalculationGroup =
+ {
+ Children =
+ {
+ calculation1,
+ new CalculationGroup("A", true)
+ {
+ Children =
+ {
+ calculation2
+ }
+ },
+ calculation3
+ }
+ }
+ };
+ failureMechanism.ForeshoreProfiles.Attach(observer);
+
+ var parentData = new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection);
+
+ // Call
+ info.OnNodeRemoved(nodeData, parentData);
+
+ // Assert
+ CollectionAssert.DoesNotContain(failureMechanism.ForeshoreProfiles, nodeData);
+
+ Assert.IsNull(calculation1.InputParameters.ForeshoreProfile);
+ Assert.IsNull(calculation2.InputParameters.ForeshoreProfile);
+ Assert.AreSame(otherProfile, calculation3.InputParameters.ForeshoreProfile);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void OnNodeRemoved_ForeshoreProfileOfWaveImpactAsphaltCoverWaveConditionsCalculation_ForeshoreProfileRemovedFromFailureMechanismAndCalculationForeshoreProfileCleared()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ var observer = mocks.Stub();
+ observer.Expect(o => o.UpdateObserver());
+ var calculation1Observer = mocks.StrictMock();
+ calculation1Observer.Expect(o => o.UpdateObserver());
+ var calculation2Observer = mocks.StrictMock();
+ calculation2Observer.Expect(o => o.UpdateObserver());
+ var calculation3Observer = mocks.StrictMock();
+ calculation3Observer.Expect(o => o.UpdateObserver()).Repeat.Never();
+ mocks.ReplayAll();
+
+ ForeshoreProfile nodeData = new TestForeshoreProfile("A");
+ ForeshoreProfile otherProfile = new TestForeshoreProfile("B");
+
+ var calculation1 = new WaveImpactAsphaltCoverWaveConditionsCalculation
+ {
+ InputParameters =
+ {
+ ForeshoreProfile = nodeData
+ }
+ };
+ calculation1.InputParameters.Attach(calculation1Observer);
+ var calculation2 = new WaveImpactAsphaltCoverWaveConditionsCalculation
+ {
+ InputParameters =
+ {
+ ForeshoreProfile = nodeData
+ }
+ };
+ calculation2.InputParameters.Attach(calculation2Observer);
+ var calculation3 = new WaveImpactAsphaltCoverWaveConditionsCalculation
+ {
+ InputParameters =
+ {
+ ForeshoreProfile = otherProfile
+ }
+ };
+ calculation3.InputParameters.Attach(calculation3Observer);
+
+ var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism
+ {
+ ForeshoreProfiles =
+ {
+ nodeData,
+ otherProfile
+ },
+ WaveConditionsCalculationGroup =
+ {
+ Children =
+ {
+ calculation1,
+ new CalculationGroup("A", true)
+ {
+ Children =
+ {
+ calculation2
+ }
+ },
+ calculation3
+ }
+ }
+ };
+ failureMechanism.ForeshoreProfiles.Attach(observer);
+
+ var parentData = new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection);
+
+ // Call
+ info.OnNodeRemoved(nodeData, parentData);
+
+ // Assert
+ CollectionAssert.DoesNotContain(failureMechanism.ForeshoreProfiles, nodeData);
+
+ Assert.IsNull(calculation1.InputParameters.ForeshoreProfile);
+ Assert.IsNull(calculation2.InputParameters.ForeshoreProfile);
+ Assert.AreSame(otherProfile, calculation3.InputParameters.ForeshoreProfile);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void OnNodeRemoved_ForeshoreProfileOfGrassCoverErosionOutwardsWaveConditionsCalculation_ForeshoreProfileRemovedFromFailureMechanismAndCalculationForeshoreProfileCleared()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ var observer = mocks.Stub();
+ observer.Expect(o => o.UpdateObserver());
+ var calculation1Observer = mocks.StrictMock();
+ calculation1Observer.Expect(o => o.UpdateObserver());
+ var calculation2Observer = mocks.StrictMock();
+ calculation2Observer.Expect(o => o.UpdateObserver());
+ var calculation3Observer = mocks.StrictMock();
+ calculation3Observer.Expect(o => o.UpdateObserver()).Repeat.Never();
+ mocks.ReplayAll();
+
+ ForeshoreProfile nodeData = new TestForeshoreProfile("A");
+ ForeshoreProfile otherProfile = new TestForeshoreProfile("B");
+
+ var calculation1 = new GrassCoverErosionOutwardsWaveConditionsCalculation
+ {
+ InputParameters =
+ {
+ ForeshoreProfile = nodeData
+ }
+ };
+ calculation1.InputParameters.Attach(calculation1Observer);
+ var calculation2 = new GrassCoverErosionOutwardsWaveConditionsCalculation
+ {
+ InputParameters =
+ {
+ ForeshoreProfile = nodeData
+ }
+ };
+ calculation2.InputParameters.Attach(calculation2Observer);
+ var calculation3 = new GrassCoverErosionOutwardsWaveConditionsCalculation
+ {
+ InputParameters =
+ {
+ ForeshoreProfile = otherProfile
+ }
+ };
+ calculation3.InputParameters.Attach(calculation3Observer);
+
+ var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism
+ {
+ ForeshoreProfiles =
+ {
+ nodeData,
+ otherProfile
+ },
+ WaveConditionsCalculationGroup =
+ {
+ Children =
+ {
+ calculation1,
+ new CalculationGroup("A", true)
+ {
+ Children =
+ {
+ calculation2
+ }
+ },
+ calculation3
+ }
+ }
+ };
+ failureMechanism.ForeshoreProfiles.Attach(observer);
+
+ var parentData = new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection);
+
+ // Call
+ info.OnNodeRemoved(nodeData, parentData);
+
+ // Assert
+ CollectionAssert.DoesNotContain(failureMechanism.ForeshoreProfiles, nodeData);
+
+ Assert.IsNull(calculation1.InputParameters.ForeshoreProfile);
+ Assert.IsNull(calculation2.InputParameters.ForeshoreProfile);
+ Assert.AreSame(otherProfile, calculation3.InputParameters.ForeshoreProfile);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void OnNodeRemoved_ForeshoreProfileOfHeightStructuresWaveConditionsCalculation_ForeshoreProfileRemovedFromFailureMechanismAndCalculationForeshoreProfileCleared()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ var observer = mocks.Stub();
+ observer.Expect(o => o.UpdateObserver());
+ var calculation1Observer = mocks.StrictMock();
+ calculation1Observer.Expect(o => o.UpdateObserver());
+ var calculation2Observer = mocks.StrictMock();
+ calculation2Observer.Expect(o => o.UpdateObserver());
+ var calculation3Observer = mocks.StrictMock();
+ calculation3Observer.Expect(o => o.UpdateObserver()).Repeat.Never();
+ mocks.ReplayAll();
+
+ ForeshoreProfile nodeData = new TestForeshoreProfile("A");
+ ForeshoreProfile otherProfile = new TestForeshoreProfile("B");
+
+ var calculation1 = new StructuresCalculation
+ {
+ InputParameters =
+ {
+ ForeshoreProfile = nodeData
+ }
+ };
+ calculation1.InputParameters.Attach(calculation1Observer);
+ var calculation2 = new StructuresCalculation
+ {
+ InputParameters =
+ {
+ ForeshoreProfile = nodeData
+ }
+ };
+ calculation2.InputParameters.Attach(calculation2Observer);
+ var calculation3 = new StructuresCalculation
+ {
+ InputParameters =
+ {
+ ForeshoreProfile = otherProfile
+ }
+ };
+ calculation3.InputParameters.Attach(calculation3Observer);
+
+ var failureMechanism = new HeightStructuresFailureMechanism
+ {
+ ForeshoreProfiles =
+ {
+ nodeData,
+ otherProfile
+ },
+ CalculationsGroup =
+ {
+ Children =
+ {
+ calculation1,
+ new CalculationGroup("A", true)
+ {
+ Children =
+ {
+ calculation2
+ }
+ },
+ calculation3
+ }
+ }
+ };
+ failureMechanism.ForeshoreProfiles.Attach(observer);
+
+ var parentData = new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection);
+
+ // Call
+ info.OnNodeRemoved(nodeData, parentData);
+
+ // Assert
+ CollectionAssert.DoesNotContain(failureMechanism.ForeshoreProfiles, nodeData);
+
+ Assert.IsNull(calculation1.InputParameters.ForeshoreProfile);
+ Assert.IsNull(calculation2.InputParameters.ForeshoreProfile);
+ Assert.AreSame(otherProfile, calculation3.InputParameters.ForeshoreProfile);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void OnNodeRemoved_ForeshoreProfileOfClosingStructuresWaveConditionsCalculation_ForeshoreProfileRemovedFromFailureMechanismAndCalculationForeshoreProfileCleared()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ var observer = mocks.Stub();
+ observer.Expect(o => o.UpdateObserver());
+ var calculation1Observer = mocks.StrictMock();
+ calculation1Observer.Expect(o => o.UpdateObserver());
+ var calculation2Observer = mocks.StrictMock();
+ calculation2Observer.Expect(o => o.UpdateObserver());
+ var calculation3Observer = mocks.StrictMock();
+ calculation3Observer.Expect(o => o.UpdateObserver()).Repeat.Never();
+ mocks.ReplayAll();
+
+ ForeshoreProfile nodeData = new TestForeshoreProfile("A");
+ ForeshoreProfile otherProfile = new TestForeshoreProfile("B");
+
+ var calculation1 = new StructuresCalculation
+ {
+ InputParameters =
+ {
+ ForeshoreProfile = nodeData
+ }
+ };
+ calculation1.InputParameters.Attach(calculation1Observer);
+ var calculation2 = new StructuresCalculation
+ {
+ InputParameters =
+ {
+ ForeshoreProfile = nodeData
+ }
+ };
+ calculation2.InputParameters.Attach(calculation2Observer);
+ var calculation3 = new StructuresCalculation
+ {
+ InputParameters =
+ {
+ ForeshoreProfile = otherProfile
+ }
+ };
+ calculation3.InputParameters.Attach(calculation3Observer);
+
+ var failureMechanism = new ClosingStructuresFailureMechanism
+ {
+ ForeshoreProfiles =
+ {
+ nodeData,
+ otherProfile
+ },
+ CalculationsGroup =
+ {
+ Children =
+ {
+ calculation1,
+ new CalculationGroup("A", true)
+ {
+ Children =
+ {
+ calculation2
+ }
+ },
+ calculation3
+ }
+ }
+ };
+ failureMechanism.ForeshoreProfiles.Attach(observer);
+
+ var parentData = new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection);
+
+ // Call
+ info.OnNodeRemoved(nodeData, parentData);
+
+ // Assert
+ CollectionAssert.DoesNotContain(failureMechanism.ForeshoreProfiles, nodeData);
+
+ Assert.IsNull(calculation1.InputParameters.ForeshoreProfile);
+ Assert.IsNull(calculation2.InputParameters.ForeshoreProfile);
+ Assert.AreSame(otherProfile, calculation3.InputParameters.ForeshoreProfile);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void OnNodeRemoved_ForeshoreProfileOfStabilityPointStructuresWaveConditionsCalculation_ForeshoreProfileRemovedFromFailureMechanismAndCalculationForeshoreProfileCleared()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ var observer = mocks.Stub();
+ observer.Expect(o => o.UpdateObserver());
+ var calculation1Observer = mocks.StrictMock();
+ calculation1Observer.Expect(o => o.UpdateObserver());
+ var calculation2Observer = mocks.StrictMock();
+ calculation2Observer.Expect(o => o.UpdateObserver());
+ var calculation3Observer = mocks.StrictMock();
+ calculation3Observer.Expect(o => o.UpdateObserver()).Repeat.Never();
+ mocks.ReplayAll();
+
+ ForeshoreProfile nodeData = new TestForeshoreProfile("A");
+ ForeshoreProfile otherProfile = new TestForeshoreProfile("B");
+
+ var calculation1 = new StructuresCalculation
+ {
+ InputParameters =
+ {
+ ForeshoreProfile = nodeData
+ }
+ };
+ calculation1.InputParameters.Attach(calculation1Observer);
+ var calculation2 = new StructuresCalculation
+ {
+ InputParameters =
+ {
+ ForeshoreProfile = nodeData
+ }
+ };
+ calculation2.InputParameters.Attach(calculation2Observer);
+ var calculation3 = new StructuresCalculation
+ {
+ InputParameters =
+ {
+ ForeshoreProfile = otherProfile
+ }
+ };
+ calculation3.InputParameters.Attach(calculation3Observer);
+
+ var failureMechanism = new StabilityPointStructuresFailureMechanism
+ {
+ ForeshoreProfiles =
+ {
+ nodeData,
+ otherProfile
+ },
+ CalculationsGroup =
+ {
+ Children =
+ {
+ calculation1,
+ new CalculationGroup("A", true)
+ {
+ Children =
+ {
+ calculation2
+ }
+ },
+ calculation3
+ }
+ }
+ };
+ failureMechanism.ForeshoreProfiles.Attach(observer);
+
+ var parentData = new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, failureMechanism, assessmentSection);
+
+ // Call
+ info.OnNodeRemoved(nodeData, parentData);
+
+ // Assert
+ CollectionAssert.DoesNotContain(failureMechanism.ForeshoreProfiles, nodeData);
+
+ Assert.IsNull(calculation1.InputParameters.ForeshoreProfile);
+ Assert.IsNull(calculation2.InputParameters.ForeshoreProfile);
+ Assert.AreSame(otherProfile, calculation3.InputParameters.ForeshoreProfile);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ContextMenuStrip_Always_CallsBuilder()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var menuBuilderMock = mocks.StrictMock();
+ menuBuilderMock.Expect(mb => mb.AddDeleteItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.Build()).Return(null);
+
+ var gui = mocks.Stub();
+ gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ gui.Stub(g => g.Get(null, treeViewControl)).Return(menuBuilderMock);
+
+ mocks.ReplayAll();
+
+ using (var p = new RingtoetsPlugin())
+ {
+ p.Gui = gui;
+ var i = p.GetTreeNodeInfos().First(tni => tni.TagType == typeof(ForeshoreProfile));
+
+ // Call
+ i.ContextMenuStrip(null, null, treeViewControl);
+ }
+ }
+
+ // Assert
+ mocks.VerifyAll();
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/ForeshoreProfilesContextTreeNodeInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/ForeshoreProfilesContextTreeNodeInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/ForeshoreProfilesContextTreeNodeInfoTest.cs (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -0,0 +1,214 @@
+// 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.Drawing;
+using System.Linq;
+using Core.Common.Base;
+using Core.Common.Base.Geometry;
+using Core.Common.Controls.TreeView;
+using Core.Common.Gui;
+using Core.Common.Gui.ContextMenu;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.DikeProfiles;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Forms.PresentationObjects;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.Integration.Plugin.Test.TreeNodeInfos
+{
+ [TestFixture]
+ public class ForeshoreProfilesContextTreeNodeInfoTest
+ {
+ private RingtoetsPlugin plugin;
+ private TreeNodeInfo info;
+
+ [SetUp]
+ public void SetUp()
+ {
+ plugin = new RingtoetsPlugin();
+ info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(ForeshoreProfilesContext));
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ plugin.Dispose();
+ info = null;
+ }
+
+ [Test]
+ public void Initialized_ExpectedValues()
+ {
+ // Assert
+ Assert.IsNull(info.CanCheck);
+ Assert.IsNull(info.CanDrag);
+ Assert.IsNull(info.CanDrop);
+ Assert.IsNull(info.CanInsert);
+ Assert.IsNull(info.CanRemove);
+ Assert.IsNull(info.CanRename);
+ Assert.IsNull(info.EnsureVisibleOnCreate);
+ Assert.IsNull(info.IsChecked);
+ Assert.IsNull(info.OnDrop);
+ Assert.IsNull(info.OnNodeChecked);
+ Assert.IsNull(info.OnNodeRemoved);
+ Assert.IsNull(info.OnNodeRenamed);
+ }
+
+ [Test]
+ public void Text_Always_ReturnText()
+ {
+ // Call
+ string text = info.Text(null);
+
+ // Assert
+ Assert.AreEqual("Voorlandprofielen", text);
+ }
+
+ [Test]
+ public void Image_Always_ReturnFolderIcon()
+ {
+ // Call
+ Image icon = info.Image(null);
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GeneralFolderIcon, icon);
+ }
+
+ [Test]
+ public void ForeColor_CollectionIsEmpty_ReturnGrayText()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ var failureMechanism = mocks.Stub();
+ mocks.ReplayAll();
+
+ var emptyCollection = new ObservableList();
+ var context = new ForeshoreProfilesContext(emptyCollection, failureMechanism, assessmentSection);
+
+ // Call
+ Color color = info.ForeColor(context);
+
+ // Assert
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), color);
+ mocks.ReplayAll();
+ }
+
+ [Test]
+ public void ForeColor_CollectionHasElements_ReturnControlText()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ var failureMechanism = mocks.Stub();
+ mocks.ReplayAll();
+
+ var emptyCollection = new ObservableList
+ {
+ new ForeshoreProfile(new Point2D(0, 0), new Point2D[0], null, new ForeshoreProfile.ConstructionProperties())
+ };
+ var context = new ForeshoreProfilesContext(emptyCollection, failureMechanism, assessmentSection);
+
+ // Call
+ Color color = info.ForeColor(context);
+
+ // Assert
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), color);
+ mocks.ReplayAll();
+ }
+
+ [Test]
+ public void ChildNodeObjects_Always_ReturnChildrenOfCollection()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ var failureMechanism = mocks.Stub();
+ mocks.ReplayAll();
+
+ var profile1 = new ForeshoreProfile(new Point2D(0, 0), new Point2D[0], null, new ForeshoreProfile.ConstructionProperties());
+ var profile2 = new ForeshoreProfile(new Point2D(1, 1), new Point2D[0], null, new ForeshoreProfile.ConstructionProperties());
+ var profile3 = new ForeshoreProfile(new Point2D(2, 2), new Point2D[0], null, new ForeshoreProfile.ConstructionProperties());
+ var emptyCollection = new ObservableList
+ {
+ profile1,
+ profile2,
+ profile3,
+ };
+ var context = new ForeshoreProfilesContext(emptyCollection, failureMechanism, assessmentSection);
+
+ // Call
+ object[] children = info.ChildNodeObjects(context);
+
+ // Assert
+ var expectedChildren = new[]
+ {
+ profile1,
+ profile2,
+ profile3
+ };
+ CollectionAssert.AreEqual(expectedChildren, children);
+ mocks.ReplayAll();
+ }
+
+ [Test]
+ public void ContextMenuStrip_Always_ReturnContextMenuStrip()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var assessmentSection = mocks.Stub();
+ var failureMechanism = mocks.Stub();
+
+ var emptyCollection = new ObservableList();
+ var context = new ForeshoreProfilesContext(emptyCollection, failureMechanism, assessmentSection);
+
+ var contextMenuBuilder = mocks.Stub();
+ contextMenuBuilder.Expect(b => b.AddDeleteChildrenItem()).Return(contextMenuBuilder);
+ contextMenuBuilder.Expect(b => b.AddSeparator()).Return(contextMenuBuilder);
+ contextMenuBuilder.Expect(b => b.AddImportItem()).Return(contextMenuBuilder);
+ contextMenuBuilder.Expect(b => b.AddSeparator()).Return(contextMenuBuilder);
+ contextMenuBuilder.Expect(b => b.AddCollapseAllItem()).Return(contextMenuBuilder);
+ contextMenuBuilder.Expect(b => b.AddExpandAllItem()).Return(contextMenuBuilder);
+ contextMenuBuilder.Expect(b => b.Build()).Return(null);
+
+ var gui = mocks.Stub();
+ gui.Stub(g => g.Get(context, treeViewControl)).Return(contextMenuBuilder);
+ gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ // Call
+ info.ContextMenuStrip(context, null, treeViewControl);
+
+ // Assert
+ plugin.Dispose();
+ mocks.VerifyAll();
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/GrassCoverSlipOffInwardsFailureMechanismSectionResultContextTreeNodeInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/GrassCoverSlipOffInwardsFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/GrassCoverSlipOffInwardsFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -0,0 +1,138 @@
+// 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.Controls.TreeView;
+using Core.Common.Gui;
+using Core.Common.Gui.ContextMenu;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Forms.PresentationObjects;
+using Ringtoets.Integration.Data.StandAlone;
+using Ringtoets.Integration.Data.StandAlone.SectionResults;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.Integration.Plugin.Test.TreeNodeInfos
+{
+ [TestFixture]
+ public class GrassCoverSlipOffInwardsFailureMechanismSectionResultContextTreeNodeInfoTest
+ {
+ private MockRepository mocks;
+ private RingtoetsPlugin plugin;
+ private TreeNodeInfo info;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks = new MockRepository();
+ plugin = new RingtoetsPlugin();
+ info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(FailureMechanismSectionResultContext));
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ plugin.Dispose();
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ // Assert
+ Assert.AreEqual(typeof(FailureMechanismSectionResultContext), info.TagType);
+
+ Assert.IsNull(info.ChildNodeObjects);
+ Assert.IsNull(info.ForeColor);
+ Assert.IsNull(info.EnsureVisibleOnCreate);
+ Assert.IsNull(info.CanRename);
+ Assert.IsNull(info.OnNodeRenamed);
+ Assert.IsNull(info.CanRemove);
+ Assert.IsNull(info.OnNodeRemoved);
+ Assert.IsNull(info.CanCheck);
+ Assert.IsNull(info.IsChecked);
+ Assert.IsNull(info.OnNodeChecked);
+ Assert.IsNull(info.CanDrag);
+ Assert.IsNull(info.CanDrop);
+ Assert.IsNull(info.CanInsert);
+ Assert.IsNull(info.OnDrop);
+ }
+
+ [Test]
+ public void Text_Always_ReturnsName()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ var mechanism = new GrassCoverSlipOffInwardsFailureMechanism();
+ var context = new FailureMechanismSectionResultContext(mechanism.SectionResults, mechanism);
+
+ // Call
+ var text = info.Text(context);
+
+ // Assert
+ Assert.AreEqual("Resultaat", text);
+ }
+
+ [Test]
+ public void Image_Always_ReturnsGenericInputOutputIcon()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ // Call
+ var image = info.Image(null);
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.FailureMechanismSectionResultIcon, image);
+ }
+
+ [Test]
+ public void ContextMenuStrip_Always_CallsBuilder()
+ {
+ // Setup
+ var menuBuilderMock = mocks.StrictMock();
+ menuBuilderMock.Expect(mb => mb.AddOpenItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.Build()).Return(null);
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var gui = mocks.Stub();
+ gui.Stub(g => g.Get(null, treeViewControl)).Return(menuBuilderMock);
+ gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ // Call
+ info.ContextMenuStrip(null, null, treeViewControl);
+ }
+ // Assert
+ // Assert expectancies are called in TearDown()
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/GrassCoverSlipOffOutwardsFailureMechanismSectionResultContextTreeNodeInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/GrassCoverSlipOffOutwardsFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/GrassCoverSlipOffOutwardsFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -0,0 +1,138 @@
+// 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.Controls.TreeView;
+using Core.Common.Gui;
+using Core.Common.Gui.ContextMenu;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Forms.PresentationObjects;
+using Ringtoets.Integration.Data.StandAlone;
+using Ringtoets.Integration.Data.StandAlone.SectionResults;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.Integration.Plugin.Test.TreeNodeInfos
+{
+ [TestFixture]
+ public class GrassCoverSlipOffOutwardsFailureMechanismSectionResultContextTreeNodeInfoTest
+ {
+ private MockRepository mocks;
+ private RingtoetsPlugin plugin;
+ private TreeNodeInfo info;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks = new MockRepository();
+ plugin = new RingtoetsPlugin();
+ info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(FailureMechanismSectionResultContext));
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ plugin.Dispose();
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ // Assert
+ Assert.AreEqual(typeof(FailureMechanismSectionResultContext), info.TagType);
+
+ Assert.IsNull(info.ChildNodeObjects);
+ Assert.IsNull(info.ForeColor);
+ Assert.IsNull(info.EnsureVisibleOnCreate);
+ Assert.IsNull(info.CanRename);
+ Assert.IsNull(info.OnNodeRenamed);
+ Assert.IsNull(info.CanRemove);
+ Assert.IsNull(info.OnNodeRemoved);
+ Assert.IsNull(info.CanCheck);
+ Assert.IsNull(info.IsChecked);
+ Assert.IsNull(info.OnNodeChecked);
+ Assert.IsNull(info.CanDrag);
+ Assert.IsNull(info.CanDrop);
+ Assert.IsNull(info.CanInsert);
+ Assert.IsNull(info.OnDrop);
+ }
+
+ [Test]
+ public void Text_Always_ReturnsName()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ var mechanism = new GrassCoverSlipOffOutwardsFailureMechanism();
+ var context = new FailureMechanismSectionResultContext(mechanism.SectionResults, mechanism);
+
+ // Call
+ var text = info.Text(context);
+
+ // Assert
+ Assert.AreEqual("Resultaat", text);
+ }
+
+ [Test]
+ public void Image_Always_ReturnsGenericInputOutputIcon()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ // Call
+ var image = info.Image(null);
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.FailureMechanismSectionResultIcon, image);
+ }
+
+ [Test]
+ public void ContextMenuStrip_Always_CallsBuilder()
+ {
+ // Setup
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var menuBuilderMock = mocks.StrictMock();
+ menuBuilderMock.Expect(mb => mb.AddOpenItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.Build()).Return(null);
+
+ var gui = mocks.Stub();
+ gui.Stub(g => g.Get(null, treeViewControl)).Return(menuBuilderMock);
+ gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ // Call
+ info.ContextMenuStrip(null, null, treeViewControl);
+ }
+ // Assert
+ // Assert expectancies are called in TearDown()
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/HydraulicBoundaryDatabaseContextTreeNodeInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/HydraulicBoundaryDatabaseContextTreeNodeInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/HydraulicBoundaryDatabaseContextTreeNodeInfoTest.cs (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -0,0 +1,583 @@
+// 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;
+using System.Drawing;
+using System.IO;
+using System.Linq;
+using System.Windows.Forms;
+using Core.Common.Base;
+using Core.Common.Controls.TreeView;
+using Core.Common.Gui;
+using Core.Common.Gui.ContextMenu;
+using Core.Common.Gui.TestUtil.ContextMenu;
+using Core.Common.TestUtil;
+using NUnit.Extensions.Forms;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Common.IO.FileImporters;
+using Ringtoets.Common.IO.HydraRing;
+using Ringtoets.GrassCoverErosionOutwards.Data;
+using Ringtoets.Integration.Data;
+using Ringtoets.Integration.Forms.PresentationObjects;
+using Ringtoets.Piping.Data;
+using Ringtoets.Piping.Data.TestUtil;
+using Ringtoets.Piping.KernelWrapper.TestUtil;
+using RingtoetsFormsResources = Ringtoets.Integration.Forms.Properties.Resources;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.Integration.Plugin.Test.TreeNodeInfos
+{
+ [TestFixture]
+ public class HydraulicBoundaryDatabaseContextTreeNodeInfoTest : NUnitFormTest
+ {
+ private MockRepository mocks;
+
+ private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Forms, "HydraulicBoundaryDatabase");
+ private readonly string testDataPathNoHlcd = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Forms, "HydraulicBoundaryDatabaseNoHLCD");
+ private readonly string testDataPathNoSettings = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Forms, "HydraulicBoundaryDatabaseNoSettings");
+ private readonly string testDataPathInvalidSettings = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Forms, "HydraulicBoundaryDatabaseSettingsInvalid");
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks = new MockRepository();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Assert
+ Assert.AreEqual(typeof(HydraulicBoundaryDatabaseContext), info.TagType);
+ Assert.IsNull(info.CanCheck);
+ Assert.IsNull(info.IsChecked);
+ Assert.IsNull(info.OnNodeChecked);
+ Assert.IsNull(info.CanDrag);
+ Assert.IsNull(info.CanDrop);
+ Assert.IsNull(info.CanInsert);
+ Assert.IsNull(info.OnDrop);
+ Assert.IsNull(info.EnsureVisibleOnCreate);
+ Assert.IsNull(info.CanRename);
+ Assert.IsNull(info.OnNodeRemoved);
+ Assert.IsNull(info.CanRemove);
+ Assert.IsNull(info.OnNodeRemoved);
+ }
+ }
+
+ [Test]
+ public void Text_Always_ReturnsSetName()
+ {
+ // Setup
+ const string name = "Hydraulische randvoorwaarden";
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+
+ var context = new HydraulicBoundaryDatabaseContext(assessmentSection);
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Call
+ var text = info.Text(context);
+
+ // Assert
+ Assert.AreEqual(name, text);
+ }
+ }
+
+ [Test]
+ public void Image_Always_ReturnsGenericIcon()
+ {
+ // Setup
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Call
+ var image = info.Image(null);
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, image);
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+ var nodeData = new HydraulicBoundaryDatabaseContext(assessmentSection);
+
+ var menuBuilderMock = mocks.StrictMock();
+ menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddExportItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.Build()).Return(null);
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var guiMock = mocks.StrictMock();
+ guiMock.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ guiMock.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+ guiMock.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilderMock);
+
+ mocks.ReplayAll();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ plugin.Gui = guiMock;
+
+ // Call
+ info.ContextMenuStrip(nodeData, null, treeViewControl);
+ }
+ }
+ // Assert
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ForeColor_ContextHasNoReferenceLine_ReturnDisabledColor()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+ var hydraulicBoundaryDatabaseContext = new HydraulicBoundaryDatabaseContext(assessmentSection);
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+ // Call
+ Color color = info.ForeColor(hydraulicBoundaryDatabaseContext);
+
+ // Assert
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), color);
+ }
+ }
+
+ [Test]
+ public void ForeColor_ContextHasReferenceLineData_ReturnControlText()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase()
+ };
+
+ var hydraulicBoundaryDatabaseContext = new HydraulicBoundaryDatabaseContext(assessmentSection);
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Call
+ Color color = info.ForeColor(hydraulicBoundaryDatabaseContext);
+
+ // Assert
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), color);
+ }
+ }
+
+ [Test]
+ public void ChildNodeObjects_NoHydraulicBoundaryDatabaseSet_ReturnsEmpty()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+ var hydraulicBoundaryDatabaseContext = new HydraulicBoundaryDatabaseContext(assessmentSection);
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Call
+ var objects = info.ChildNodeObjects(hydraulicBoundaryDatabaseContext).ToArray();
+
+ // Assert
+ Assert.AreEqual(0, objects.Length);
+ }
+ }
+
+ [Test]
+ public void ChildNodeObjects_HydraulicBoundaryDatabaseSet_ReturnsChildrenOfData()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase()
+ };
+
+ var hydraulicBoundaryDatabaseContext = new HydraulicBoundaryDatabaseContext(assessmentSection);
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Call
+ var objects = info.ChildNodeObjects(hydraulicBoundaryDatabaseContext).ToArray();
+
+ // Assert
+ Assert.AreEqual(2, objects.Length);
+ var designWaterLevelLocationsContext = (DesignWaterLevelLocationsContext) objects[0];
+ Assert.AreSame(assessmentSection, designWaterLevelLocationsContext.WrappedData);
+
+ var waveHeightLocationsContext = (WaveHeightLocationsContext) objects[1];
+ Assert.AreSame(assessmentSection, waveHeightLocationsContext.WrappedData);
+ }
+ }
+
+ [Test]
+ [RequiresSTA]
+ public void GivenNoFilePathIsSet_WhenOpeningValidFileFromContextMenu_ThenPathWillBeSetAndNotifiesObserverAndLogMessageAdded()
+ {
+ // Given
+ var assessmentSectionObserver = mocks.StrictMock();
+ assessmentSectionObserver.Expect(o => o.UpdateObserver());
+
+ var grassCoverErosionOutwardsLocationsObserver = mocks.StrictMock();
+ grassCoverErosionOutwardsLocationsObserver.Expect(o => o.UpdateObserver());
+
+ string testFile = Path.Combine(testDataPath, "HRD dutch coast south.sqlite");
+
+ int contextMenuImportHydraulicBoundaryDatabaseIndex = 0;
+
+ AssessmentSection assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+ HydraulicBoundaryDatabaseContext hydraulicBoundaryDatabaseContext = new HydraulicBoundaryDatabaseContext(assessmentSection);
+
+ using (TreeViewControl treeViewControl = new TreeViewControl())
+ using (RingtoetsPlugin plugin = new RingtoetsPlugin())
+ {
+ IGui gui = mocks.DynamicMock();
+ gui.Expect(cmp => cmp.Get(hydraulicBoundaryDatabaseContext, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
+ mocks.ReplayAll();
+
+ assessmentSection.Attach(assessmentSectionObserver);
+ assessmentSection.GrassCoverErosionOutwards.HydraulicBoundaryLocations.Attach(grassCoverErosionOutwardsLocationsObserver);
+
+ DialogBoxHandler = (name, wnd) =>
+ {
+ OpenFileDialogTester tester = new OpenFileDialogTester(wnd);
+ tester.OpenFile(testFile);
+ };
+
+ TreeNodeInfo info = GetInfo(plugin);
+ plugin.Gui = gui;
+
+ using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(hydraulicBoundaryDatabaseContext, null, treeViewControl))
+ {
+ // When
+ Action action = () => contextMenuStrip.Items[contextMenuImportHydraulicBoundaryDatabaseIndex].PerformClick();
+
+ // Then
+ TestHelper.AssertLogMessages(action, messages =>
+ {
+ string[] msgs = messages.ToArray();
+ Assert.AreEqual(2, msgs.Length);
+ Assert.AreEqual("De hydraulische randvoorwaardenlocaties zijn ingelezen.", msgs[0]);
+ Assert.AreEqual(string.Format("Database op pad '{0}' gekoppeld.", testFile), msgs[1]);
+ });
+
+ Assert.IsNotNull(assessmentSection.HydraulicBoundaryDatabase);
+ Assert.IsNotEmpty(assessmentSection.GrassCoverErosionOutwards.HydraulicBoundaryLocations);
+ }
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [RequiresSTA]
+ public void GivenNoFilePathIsSet_WhenOpeneningInvalidFileFromContextMenu_ThenPathWillNotBeSetAndLogMessageAdded()
+ {
+ // Given
+ string testFile = Path.Combine(testDataPath, "empty.sqlite");
+
+ int contextMenuImportHydraulicBoundaryDatabaseIndex = 0;
+
+ AssessmentSection assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+ HydraulicBoundaryDatabaseContext hydraulicBoundaryDatabaseContext = new HydraulicBoundaryDatabaseContext(assessmentSection);
+
+ using (TreeViewControl treeViewControl = new TreeViewControl())
+ using (RingtoetsPlugin plugin = new RingtoetsPlugin())
+ {
+ IGui gui = mocks.DynamicMock();
+ gui.Expect(cmp => cmp.Get(hydraulicBoundaryDatabaseContext, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
+ mocks.ReplayAll();
+
+ DialogBoxHandler = (name, wnd) =>
+ {
+ OpenFileDialogTester tester = new OpenFileDialogTester(wnd);
+ tester.OpenFile(testFile);
+ };
+
+ TreeNodeInfo info = GetInfo(plugin);
+ plugin.Gui = gui;
+
+ using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(hydraulicBoundaryDatabaseContext, null, treeViewControl))
+ {
+ // When
+ Action action = () => contextMenuStrip.Items[contextMenuImportHydraulicBoundaryDatabaseIndex].PerformClick();
+
+ // Then
+ string expectedMessage = string.Format("Fout bij het lezen van bestand '{0}': kon geen locaties verkrijgen van de database. Het bestand wordt overgeslagen.",
+ testFile);
+ TestHelper.AssertLogMessageIsGenerated(action, expectedMessage);
+
+ Assert.IsNull(assessmentSection.HydraulicBoundaryDatabase);
+ }
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [RequiresSTA]
+ public void GivenNoFilePathIsSet_WhenOpeneningValidFileWithoutHLCDFromContextMenu_ThenPathWillNotBeSetAndLogMessageAdded()
+ {
+ // Given
+ string testFile = Path.Combine(testDataPathNoHlcd, "HRD dutch coast south.sqlite");
+
+ int contextMenuImportHydraulicBoundaryDatabaseIndex = 0;
+
+ AssessmentSection assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+ HydraulicBoundaryDatabaseContext hydraulicBoundaryDatabaseContext = new HydraulicBoundaryDatabaseContext(assessmentSection);
+
+ using (TreeViewControl treeViewControl = new TreeViewControl())
+ using (RingtoetsPlugin plugin = new RingtoetsPlugin())
+ {
+ IGui gui = mocks.DynamicMock();
+ gui.Expect(cmp => cmp.Get(hydraulicBoundaryDatabaseContext, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
+ mocks.ReplayAll();
+
+ DialogBoxHandler = (name, wnd) =>
+ {
+ OpenFileDialogTester tester = new OpenFileDialogTester(wnd);
+ tester.OpenFile(testFile);
+ };
+
+ TreeNodeInfo info = GetInfo(plugin);
+ plugin.Gui = gui;
+
+ using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(hydraulicBoundaryDatabaseContext, null, treeViewControl))
+ {
+ // When
+ Action action = () => contextMenuStrip.Items[contextMenuImportHydraulicBoundaryDatabaseIndex].PerformClick();
+
+ // Then
+ string expectedMessage =
+ string.Format("Fout bij het lezen van bestand '{0}': het bijbehorende HLCD bestand is niet gevonden in dezelfde map als het HRD bestand.",
+ testFile);
+ TestHelper.AssertLogMessageIsGenerated(action, expectedMessage);
+
+ Assert.IsNull(assessmentSection.HydraulicBoundaryDatabase);
+ }
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [RequiresSTA]
+ public void GivenNoFilePathIsSet_WhenOpeneningValidFileWithoutSettingsDatabaseFromContextMenu_ThenPathWillNotBeSetAndLogMessageAdded()
+ {
+ // Given
+ string testFile = Path.Combine(testDataPathNoSettings, "HRD dutch coast south.sqlite");
+
+ int contextMenuImportHydraulicBoundaryDatabaseIndex = 0;
+
+ AssessmentSection assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+ HydraulicBoundaryDatabaseContext hydraulicBoundaryDatabaseContext = new HydraulicBoundaryDatabaseContext(assessmentSection);
+
+ using (TreeViewControl treeViewControl = new TreeViewControl())
+ using (RingtoetsPlugin plugin = new RingtoetsPlugin())
+ {
+ IGui gui = mocks.DynamicMock();
+ gui.Expect(cmp => cmp.Get(hydraulicBoundaryDatabaseContext, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
+ mocks.ReplayAll();
+
+ DialogBoxHandler = (name, wnd) =>
+ {
+ OpenFileDialogTester tester = new OpenFileDialogTester(wnd);
+ tester.OpenFile(testFile);
+ };
+
+ TreeNodeInfo info = GetInfo(plugin);
+ plugin.Gui = gui;
+
+ using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(hydraulicBoundaryDatabaseContext, null, treeViewControl))
+ {
+ // When
+ Action action = () => contextMenuStrip.Items[contextMenuImportHydraulicBoundaryDatabaseIndex].PerformClick();
+
+ // Then
+ string expectedMessage =
+ string.Format("Fout bij het lezen van bestand '{0}': kon het rekeninstellingen bestand niet openen. Fout bij het lezen van bestand '{1}': het bestand bestaat niet.",
+ testFile,
+ HydraulicDatabaseHelper.GetHydraulicBoundarySettingsDatabase(testFile));
+ TestHelper.AssertLogMessageIsGenerated(action, expectedMessage);
+
+ Assert.IsNull(assessmentSection.HydraulicBoundaryDatabase);
+ }
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [RequiresSTA]
+ public void GivenNoFilePathIsSet_WhenOpeneningValidFileWithInvalidSettingsDatabaseFromContextMenu_ThenPathWillNotBeSetAndLogMessageAdded()
+ {
+ // Given
+ string testFile = Path.Combine(testDataPathInvalidSettings, "HRD dutch coast south.sqlite");
+
+ int contextMenuImportHydraulicBoundaryDatabaseIndex = 0;
+
+ AssessmentSection assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+ HydraulicBoundaryDatabaseContext hydraulicBoundaryDatabaseContext = new HydraulicBoundaryDatabaseContext(assessmentSection);
+
+ using (TreeViewControl treeViewControl = new TreeViewControl())
+ using (RingtoetsPlugin plugin = new RingtoetsPlugin())
+ {
+ IGui gui = mocks.DynamicMock();
+ gui.Expect(cmp => cmp.Get(hydraulicBoundaryDatabaseContext, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
+ mocks.ReplayAll();
+
+ DialogBoxHandler = (name, wnd) =>
+ {
+ OpenFileDialogTester tester = new OpenFileDialogTester(wnd);
+ tester.OpenFile(testFile);
+ };
+
+ TreeNodeInfo info = GetInfo(plugin);
+ plugin.Gui = gui;
+
+ using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(hydraulicBoundaryDatabaseContext, null, treeViewControl))
+ {
+ // When
+ Action action = () => contextMenuStrip.Items[contextMenuImportHydraulicBoundaryDatabaseIndex].PerformClick();
+
+ // Then
+ string expectedMessage =
+ string.Format("Fout bij het lezen van bestand '{0}': kon het rekeninstellingen bestand niet openen. De rekeninstellingen database heeft niet het juiste schema.",
+ testFile);
+ TestHelper.AssertLogMessageIsGenerated(action, expectedMessage);
+
+ Assert.IsNull(assessmentSection.HydraulicBoundaryDatabase);
+ }
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [RequiresSTA]
+ public void GivenFilePathIsSet_WhenOpeningSameFileFromContextMenu_ThenCalculationsWillNotBeClearedAndNoNotifyObservers()
+ {
+ // Given
+ string validFile = Path.Combine(testDataPath, "HRD dutch coast south.sqlite");
+ IObserver assessmentObserver = mocks.StrictMock();
+ IObserver grassCoverErosionOutwardsLocationsObserver = mocks.StrictMock();
+ int contextMenuImportHydraulicBoundaryDatabaseIndex = 0;
+
+ AssessmentSection assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+ using (HydraulicBoundaryDatabaseImporter importer = new HydraulicBoundaryDatabaseImporter())
+ {
+ importer.Import(assessmentSection, validFile);
+ }
+
+ assessmentSection.Attach(assessmentObserver);
+
+ HydraulicBoundaryDatabaseContext hydraulicBoundaryDatabaseContext = new HydraulicBoundaryDatabaseContext(assessmentSection);
+
+ var pipingOutput = new TestPipingOutput();
+ var pipingSemiProbabilisticOutput = new TestPipingSemiProbabilisticOutput();
+ var pipingCalculation = new PipingCalculation(new GeneralPipingInput())
+ {
+ InputParameters =
+ {
+ HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First()
+ },
+ Output = pipingOutput,
+ SemiProbabilisticOutput = pipingSemiProbabilisticOutput
+ };
+
+ assessmentSection.PipingFailureMechanism.CalculationsGroup.Children.Add(pipingCalculation);
+ assessmentSection.GrassCoverErosionOutwards.SetGrassCoverErosionOutwardsHydraulicBoundaryLocations(assessmentSection.HydraulicBoundaryDatabase);
+
+ // Precondition
+ Assert.IsNotNull(assessmentSection.HydraulicBoundaryDatabase);
+ CollectionAssert.IsNotEmpty(assessmentSection.HydraulicBoundaryDatabase.Locations);
+
+ string currentFilePath = assessmentSection.HydraulicBoundaryDatabase.FilePath;
+ string currentVersion = assessmentSection.HydraulicBoundaryDatabase.Version;
+ var currentLocations = assessmentSection.HydraulicBoundaryDatabase.Locations;
+ var currentFirstGrassCoverErosionOutwardsLocation = assessmentSection.GrassCoverErosionOutwards.HydraulicBoundaryLocations.First();
+ assessmentSection.GrassCoverErosionOutwards.HydraulicBoundaryLocations.Attach(grassCoverErosionOutwardsLocationsObserver);
+
+ using (TreeViewControl treeViewControl = new TreeViewControl())
+ using (RingtoetsPlugin plugin = new RingtoetsPlugin())
+ {
+ IGui gui = mocks.DynamicMock();
+ gui.Expect(cmp => cmp.Get(hydraulicBoundaryDatabaseContext, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
+ mocks.ReplayAll();
+
+ DialogBoxHandler = (name, wnd) =>
+ {
+ OpenFileDialogTester tester = new OpenFileDialogTester(wnd);
+ tester.OpenFile(validFile);
+ };
+
+ TreeNodeInfo info = GetInfo(plugin);
+ plugin.Gui = gui;
+
+ using (ContextMenuStrip contextMenuAdapter = info.ContextMenuStrip(hydraulicBoundaryDatabaseContext, null, treeViewControl))
+ {
+ // When
+ Action action = () => contextMenuAdapter.Items[contextMenuImportHydraulicBoundaryDatabaseIndex].PerformClick();
+
+ // Then
+ string expectedMessage = string.Format("Database op pad '{0}' gekoppeld.", validFile);
+ TestHelper.AssertLogMessageIsGenerated(action, expectedMessage);
+
+ Assert.IsNotNull(assessmentSection.HydraulicBoundaryDatabase);
+ Assert.AreEqual(currentFilePath, assessmentSection.HydraulicBoundaryDatabase.FilePath);
+ Assert.AreEqual(currentVersion, assessmentSection.HydraulicBoundaryDatabase.Version);
+ CollectionAssert.AreEqual(currentLocations, assessmentSection.HydraulicBoundaryDatabase.Locations);
+ Assert.AreSame(assessmentSection.HydraulicBoundaryDatabase.Locations.First(), pipingCalculation.InputParameters.HydraulicBoundaryLocation);
+ Assert.AreSame(pipingOutput, pipingCalculation.Output);
+ Assert.AreSame(pipingSemiProbabilisticOutput, pipingCalculation.SemiProbabilisticOutput);
+ Assert.AreSame(currentFirstGrassCoverErosionOutwardsLocation, assessmentSection.GrassCoverErosionOutwards.HydraulicBoundaryLocations.First());
+ }
+ }
+ mocks.VerifyAll();
+ }
+
+ private static TreeNodeInfo GetInfo(RingtoetsPlugin plugin)
+ {
+ return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(HydraulicBoundaryDatabaseContext));
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/MacrostabilityInwardsFailureMechanismSectionResultContextTreeNodeInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/MacrostabilityInwardsFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/MacrostabilityInwardsFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -0,0 +1,138 @@
+// 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.Controls.TreeView;
+using Core.Common.Gui;
+using Core.Common.Gui.ContextMenu;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Forms.PresentationObjects;
+using Ringtoets.Integration.Data.StandAlone;
+using Ringtoets.Integration.Data.StandAlone.SectionResults;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.Integration.Plugin.Test.TreeNodeInfos
+{
+ [TestFixture]
+ public class MacrostabilityInwardsFailureMechanismSectionResultContextTreeNodeInfoTest
+ {
+ private MockRepository mocks;
+ private RingtoetsPlugin plugin;
+ private TreeNodeInfo info;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks = new MockRepository();
+ plugin = new RingtoetsPlugin();
+ info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(FailureMechanismSectionResultContext));
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ plugin.Dispose();
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ // Assert
+ Assert.AreEqual(typeof(FailureMechanismSectionResultContext), info.TagType);
+
+ Assert.IsNull(info.ChildNodeObjects);
+ Assert.IsNull(info.ForeColor);
+ Assert.IsNull(info.EnsureVisibleOnCreate);
+ Assert.IsNull(info.CanRename);
+ Assert.IsNull(info.OnNodeRenamed);
+ Assert.IsNull(info.CanRemove);
+ Assert.IsNull(info.OnNodeRemoved);
+ Assert.IsNull(info.CanCheck);
+ Assert.IsNull(info.IsChecked);
+ Assert.IsNull(info.OnNodeChecked);
+ Assert.IsNull(info.CanDrag);
+ Assert.IsNull(info.CanDrop);
+ Assert.IsNull(info.CanInsert);
+ Assert.IsNull(info.OnDrop);
+ }
+
+ [Test]
+ public void Text_Always_ReturnsName()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ var mechanism = new MacrostabilityInwardsFailureMechanism();
+ var context = new FailureMechanismSectionResultContext(mechanism.SectionResults, mechanism);
+
+ // Call
+ var text = info.Text(context);
+
+ // Assert
+ Assert.AreEqual("Resultaat", text);
+ }
+
+ [Test]
+ public void Image_Always_ReturnsGenericInputOutputIcon()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ // Call
+ var image = info.Image(null);
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.FailureMechanismSectionResultIcon, image);
+ }
+
+ [Test]
+ public void ContextMenuStrip_Always_CallsBuilder()
+ {
+ // Setup
+ var menuBuilderMock = mocks.StrictMock();
+ menuBuilderMock.Expect(mb => mb.AddOpenItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.Build()).Return(null);
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var gui = mocks.Stub();
+ gui.Stub(g => g.Get(null, treeViewControl)).Return(menuBuilderMock);
+ gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ // Call
+ info.ContextMenuStrip(null, null, treeViewControl);
+ }
+ // Assert
+ // Assert expectancies are called in TearDown()
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/MacrostabilityOutwardsFailureMechanismSectionResultContextTreeNodeInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/MacrostabilityOutwardsFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/MacrostabilityOutwardsFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -0,0 +1,138 @@
+// 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.Controls.TreeView;
+using Core.Common.Gui;
+using Core.Common.Gui.ContextMenu;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Forms.PresentationObjects;
+using Ringtoets.Integration.Data.StandAlone;
+using Ringtoets.Integration.Data.StandAlone.SectionResults;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.Integration.Plugin.Test.TreeNodeInfos
+{
+ [TestFixture]
+ public class MacrostabilityOutwardsFailureMechanismSectionResultContextTreeNodeInfoTest
+ {
+ private MockRepository mocks;
+ private RingtoetsPlugin plugin;
+ private TreeNodeInfo info;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks = new MockRepository();
+ plugin = new RingtoetsPlugin();
+ info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(FailureMechanismSectionResultContext));
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ plugin.Dispose();
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ // Assert
+ Assert.AreEqual(typeof(FailureMechanismSectionResultContext), info.TagType);
+
+ Assert.IsNull(info.ChildNodeObjects);
+ Assert.IsNull(info.ForeColor);
+ Assert.IsNull(info.EnsureVisibleOnCreate);
+ Assert.IsNull(info.CanRename);
+ Assert.IsNull(info.OnNodeRenamed);
+ Assert.IsNull(info.CanRemove);
+ Assert.IsNull(info.OnNodeRemoved);
+ Assert.IsNull(info.CanCheck);
+ Assert.IsNull(info.IsChecked);
+ Assert.IsNull(info.OnNodeChecked);
+ Assert.IsNull(info.CanDrag);
+ Assert.IsNull(info.CanDrop);
+ Assert.IsNull(info.CanInsert);
+ Assert.IsNull(info.OnDrop);
+ }
+
+ [Test]
+ public void Text_Always_ReturnsName()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ var mechanism = new MacrostabilityOutwardsFailureMechanism();
+ var context = new FailureMechanismSectionResultContext(mechanism.SectionResults, mechanism);
+
+ // Call
+ var text = info.Text(context);
+
+ // Assert
+ Assert.AreEqual("Resultaat", text);
+ }
+
+ [Test]
+ public void Image_Always_ReturnsGenericInputOutputIcon()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ // Call
+ var image = info.Image(null);
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.FailureMechanismSectionResultIcon, image);
+ }
+
+ [Test]
+ public void ContextMenuStrip_Always_CallsBuilder()
+ {
+ // Setup
+ var menuBuilderMock = mocks.StrictMock();
+ menuBuilderMock.Expect(mb => mb.AddOpenItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.Build()).Return(null);
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var gui = mocks.Stub();
+ gui.Stub(g => g.Get(null, treeViewControl)).Return(menuBuilderMock);
+ gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ // Call
+ info.ContextMenuStrip(null, null, treeViewControl);
+ }
+ // Assert
+ // Assert expectancies are called in TearDown()
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/MicrostabilityFailureMechanismSectionResultContextTreeNodeInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/MicrostabilityFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/MicrostabilityFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -0,0 +1,138 @@
+// 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.Controls.TreeView;
+using Core.Common.Gui;
+using Core.Common.Gui.ContextMenu;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Forms.PresentationObjects;
+using Ringtoets.Integration.Data.StandAlone;
+using Ringtoets.Integration.Data.StandAlone.SectionResults;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.Integration.Plugin.Test.TreeNodeInfos
+{
+ [TestFixture]
+ public class MicrostabilityFailureMechanismSectionResultContextTreeNodeInfoTest
+ {
+ private MockRepository mocks;
+ private RingtoetsPlugin plugin;
+ private TreeNodeInfo info;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks = new MockRepository();
+ plugin = new RingtoetsPlugin();
+ info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(FailureMechanismSectionResultContext));
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ plugin.Dispose();
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ // Assert
+ Assert.AreEqual(typeof(FailureMechanismSectionResultContext), info.TagType);
+
+ Assert.IsNull(info.ChildNodeObjects);
+ Assert.IsNull(info.ForeColor);
+ Assert.IsNull(info.EnsureVisibleOnCreate);
+ Assert.IsNull(info.CanRename);
+ Assert.IsNull(info.OnNodeRenamed);
+ Assert.IsNull(info.CanRemove);
+ Assert.IsNull(info.OnNodeRemoved);
+ Assert.IsNull(info.CanCheck);
+ Assert.IsNull(info.IsChecked);
+ Assert.IsNull(info.OnNodeChecked);
+ Assert.IsNull(info.CanDrag);
+ Assert.IsNull(info.CanDrop);
+ Assert.IsNull(info.CanInsert);
+ Assert.IsNull(info.OnDrop);
+ }
+
+ [Test]
+ public void Text_Always_ReturnsName()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ var mechanism = new MicrostabilityFailureMechanism();
+ var context = new FailureMechanismSectionResultContext(mechanism.SectionResults, mechanism);
+
+ // Call
+ var text = info.Text(context);
+
+ // Assert
+ Assert.AreEqual("Resultaat", text);
+ }
+
+ [Test]
+ public void Image_Always_ReturnsGenericInputOutputIcon()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ // Call
+ var image = info.Image(null);
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.FailureMechanismSectionResultIcon, image);
+ }
+
+ [Test]
+ public void ContextMenuStrip_Always_CallsBuilder()
+ {
+ // Setup
+ var menuBuilderMock = mocks.StrictMock();
+ menuBuilderMock.Expect(mb => mb.AddOpenItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.Build()).Return(null);
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var gui = mocks.Stub();
+ gui.Stub(g => g.Get(null, treeViewControl)).Return(menuBuilderMock);
+ gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ // Call
+ info.ContextMenuStrip(null, null, treeViewControl);
+ }
+ // Assert
+ // Assert expectancies are called in TearDown()
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/PipingStructureFailureMechanismSectionResultContextTreeNodeInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/PipingStructureFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/PipingStructureFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -0,0 +1,138 @@
+// 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.Controls.TreeView;
+using Core.Common.Gui;
+using Core.Common.Gui.ContextMenu;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Forms.PresentationObjects;
+using Ringtoets.Integration.Data.StandAlone;
+using Ringtoets.Integration.Data.StandAlone.SectionResults;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.Integration.Plugin.Test.TreeNodeInfos
+{
+ [TestFixture]
+ public class PipingStructureFailureMechanismSectionResultContextTreeNodeInfoTest
+ {
+ private MockRepository mocks;
+ private RingtoetsPlugin plugin;
+ private TreeNodeInfo info;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks = new MockRepository();
+ plugin = new RingtoetsPlugin();
+ info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(FailureMechanismSectionResultContext));
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ plugin.Dispose();
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ // Assert
+ Assert.AreEqual(typeof(FailureMechanismSectionResultContext), info.TagType);
+
+ Assert.IsNull(info.ChildNodeObjects);
+ Assert.IsNull(info.ForeColor);
+ Assert.IsNull(info.EnsureVisibleOnCreate);
+ Assert.IsNull(info.CanRename);
+ Assert.IsNull(info.OnNodeRenamed);
+ Assert.IsNull(info.CanRemove);
+ Assert.IsNull(info.OnNodeRemoved);
+ Assert.IsNull(info.CanCheck);
+ Assert.IsNull(info.IsChecked);
+ Assert.IsNull(info.OnNodeChecked);
+ Assert.IsNull(info.CanDrag);
+ Assert.IsNull(info.CanDrop);
+ Assert.IsNull(info.CanInsert);
+ Assert.IsNull(info.OnDrop);
+ }
+
+ [Test]
+ public void Text_Always_ReturnsName()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ var mechanism = new PipingStructureFailureMechanism();
+ var context = new FailureMechanismSectionResultContext(mechanism.SectionResults, mechanism);
+
+ // Call
+ var text = info.Text(context);
+
+ // Assert
+ Assert.AreEqual("Resultaat", text);
+ }
+
+ [Test]
+ public void Image_Always_ReturnsGenericInputOutputIcon()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ // Call
+ var image = info.Image(null);
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.FailureMechanismSectionResultIcon, image);
+ }
+
+ [Test]
+ public void ContextMenuStrip_Always_CallsBuilder()
+ {
+ // Setup
+ var menuBuilderMock = mocks.StrictMock();
+ menuBuilderMock.Expect(mb => mb.AddOpenItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.Build()).Return(null);
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var gui = mocks.Stub();
+ gui.Stub(g => g.Get(null, treeViewControl)).Return(menuBuilderMock);
+ gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ // Call
+ info.ContextMenuStrip(null, null, treeViewControl);
+ }
+ // Assert
+ // Assert expectancies are called in TearDown()
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/ProbabilityAssessmentOutputTreeNodeInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/ProbabilityAssessmentOutputTreeNodeInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/ProbabilityAssessmentOutputTreeNodeInfoTest.cs (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -0,0 +1,135 @@
+// 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.Controls.TreeView;
+using Core.Common.Gui;
+using Core.Common.Gui.ContextMenu;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.Probability;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.Integration.Plugin.Test.TreeNodeInfos
+{
+ [TestFixture]
+ public class ProbabilityAssessmentOutputTreeNodeInfoTest
+ {
+ private MockRepository mocksRepository;
+ private RingtoetsPlugin plugin;
+ private TreeNodeInfo info;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocksRepository = new MockRepository();
+ plugin = new RingtoetsPlugin();
+ info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(ProbabilityAssessmentOutput));
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ plugin.Dispose();
+ mocksRepository.VerifyAll();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ mocksRepository.ReplayAll();
+
+ // Assert
+ Assert.AreEqual(typeof(ProbabilityAssessmentOutput), info.TagType);
+ Assert.IsNotNull(info.Text);
+ Assert.IsNotNull(info.Image);
+ Assert.IsNotNull(info.ContextMenuStrip);
+ Assert.IsNull(info.ForeColor);
+ Assert.IsNull(info.EnsureVisibleOnCreate);
+ Assert.IsNull(info.ChildNodeObjects);
+ Assert.IsNull(info.CanRename);
+ Assert.IsNull(info.OnNodeRenamed);
+ Assert.IsNull(info.CanRemove);
+ Assert.IsNull(info.OnNodeRemoved);
+ Assert.IsNull(info.CanCheck);
+ Assert.IsNull(info.IsChecked);
+ Assert.IsNull(info.OnNodeChecked);
+ Assert.IsNull(info.CanDrag);
+ Assert.IsNull(info.CanDrop);
+ Assert.IsNull(info.CanInsert);
+ Assert.IsNull(info.OnDrop);
+ }
+
+ [Test]
+ public void Text_Always_ReturnsFromResource()
+ {
+ // Setup
+ mocksRepository.ReplayAll();
+
+ // Call
+ var text = info.Text(null);
+
+ // Assert
+ Assert.AreEqual(RingtoetsCommonFormsResources.CalculationOutput_DisplayName, text);
+ }
+
+ [Test]
+ public void Image_Always_ReturnsGeneralOutputIcon()
+ {
+ // Setup
+ mocksRepository.ReplayAll();
+
+ // Call
+ var image = info.Image(null);
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GeneralOutputIcon, image);
+ }
+
+ [Test]
+ public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods()
+ {
+ // Setup
+ var guiMock = mocksRepository.StrictMock();
+ guiMock.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ guiMock.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+ var menuBuilderMock = mocksRepository.StrictMock();
+
+ menuBuilderMock.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.Build()).Return(null);
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ guiMock.Expect(cmp => cmp.Get(null, treeViewControl)).Return(menuBuilderMock);
+ mocksRepository.ReplayAll();
+
+ plugin.Gui = guiMock;
+
+ // Call
+ info.ContextMenuStrip(null, null, treeViewControl);
+ }
+ // Assert
+ // Assert expectancies called in TearDown()
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/ReferenceLineContextTreeNodeInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/ReferenceLineContextTreeNodeInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/ReferenceLineContextTreeNodeInfoTest.cs (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -0,0 +1,202 @@
+// 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.Drawing;
+using System.Linq;
+using Core.Common.Controls.TreeView;
+using Core.Common.Gui;
+using Core.Common.Gui.ContextMenu;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Forms.PresentationObjects;
+using RingtoetsIntegrationFormsResources = Ringtoets.Integration.Forms.Properties.Resources;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.Integration.Plugin.Test.TreeNodeInfos
+{
+ [TestFixture]
+ public class ReferenceLineContextTreeNodeInfoTest
+ {
+ private MockRepository mocks;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks = new MockRepository();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Assert
+ Assert.AreEqual(typeof(ReferenceLineContext), info.TagType);
+ Assert.IsNull(info.EnsureVisibleOnCreate);
+ Assert.IsNull(info.ChildNodeObjects);
+ Assert.IsNull(info.CanRename);
+ Assert.IsNull(info.OnNodeRenamed);
+ Assert.IsNull(info.CanRemove);
+ Assert.IsNull(info.OnNodeRemoved);
+ Assert.IsNull(info.CanCheck);
+ Assert.IsNull(info.IsChecked);
+ Assert.IsNull(info.OnNodeChecked);
+ Assert.IsNull(info.CanDrag);
+ Assert.IsNull(info.CanDrop);
+ Assert.IsNull(info.CanInsert);
+ Assert.IsNull(info.OnDrop);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Text_Always_ReturnsName()
+ {
+ // Setup
+ var assessmentSection = mocks.StrictMock();
+ mocks.ReplayAll();
+
+ var referenceLineContext = new ReferenceLineContext(assessmentSection);
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Call
+ var text = info.Text(referenceLineContext);
+
+ // Assert
+ Assert.AreEqual("Referentielijn", text);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Image_Always_ReturnsSetImage()
+ {
+ // Setup
+ var assessmentSection = mocks.StrictMock();
+ mocks.ReplayAll();
+
+ var referenceLineContext = new ReferenceLineContext(assessmentSection);
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Call
+ var image = info.Image(referenceLineContext);
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.ReferenceLineIcon, image);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ContextMenuStrip_Always_CallsBuilder()
+ {
+ // Setup
+ var menuBuilderMock = mocks.StrictMock();
+ menuBuilderMock.Expect(mb => mb.AddImportItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddExportItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.Build()).Return(null);
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var gui = mocks.Stub();
+ gui.Stub(g => g.Get(null, treeViewControl)).Return(menuBuilderMock);
+ gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+ mocks.ReplayAll();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ plugin.Gui = gui;
+
+ // Call
+ info.ContextMenuStrip(null, null, treeViewControl);
+ }
+ }
+ // Assert
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ForeColor_ContextHasNoReferenceLine_ReturnDisabledColor()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var referenceLineContext = new ReferenceLineContext(assessmentSection);
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Call
+ Color color = info.ForeColor(referenceLineContext);
+
+ // Assert
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), color);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ForeColor_ContextHasReferenceLineData_ReturnControlText()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ assessmentSection.ReferenceLine = new ReferenceLine();
+ mocks.ReplayAll();
+
+ var referenceLineContext = new ReferenceLineContext(assessmentSection);
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Call
+ Color color = info.ForeColor(referenceLineContext);
+
+ // Assert
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), color);
+ }
+ mocks.VerifyAll();
+ }
+
+ private TreeNodeInfo GetInfo(RingtoetsPlugin plugin)
+ {
+ return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(ReferenceLineContext));
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/RingtoetsProjectTreeNodeInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/RingtoetsProjectTreeNodeInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/RingtoetsProjectTreeNodeInfoTest.cs (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -0,0 +1,207 @@
+// 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 System.Windows.Forms;
+using Core.Common.Controls.TreeView;
+using Core.Common.Gui;
+using Core.Common.Gui.ContextMenu;
+using Core.Common.Gui.TestUtil.ContextMenu;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Integration.Data;
+using Ringtoets.Integration.Forms.Properties;
+using GuiResources = Core.Common.Gui.Properties.Resources;
+
+namespace Ringtoets.Integration.Plugin.Test.TreeNodeInfos
+{
+ [TestFixture]
+ public class RingtoetsProjectTreeNodeInfoTest
+ {
+ private MockRepository mockRepository;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mockRepository = new MockRepository();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Assert
+ Assert.AreEqual(typeof(RingtoetsProject), info.TagType);
+ Assert.IsNull(info.ForeColor);
+ Assert.IsNull(info.CanCheck);
+ Assert.IsNull(info.IsChecked);
+ Assert.IsNull(info.OnNodeChecked);
+ Assert.IsNull(info.CanDrag);
+ Assert.IsNull(info.CanDrop);
+ Assert.IsNull(info.CanInsert);
+ Assert.IsNull(info.OnDrop);
+ Assert.IsNull(info.EnsureVisibleOnCreate);
+ Assert.IsNull(info.CanRename);
+ Assert.IsNull(info.OnNodeRenamed);
+ Assert.IsNull(info.CanRemove);
+ Assert.IsNull(info.OnNodeRemoved);
+ }
+ }
+
+ [Test]
+ public void Text_Always_ReturnsName()
+ {
+ // Setup
+ var testName = "ttt";
+ var project = new RingtoetsProject(testName);
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Call
+ var text = info.Text(project);
+
+ // Assert
+ Assert.AreEqual(testName, text);
+ }
+ }
+
+ [Test]
+ public void Image_Always_ReturnsSetImage()
+ {
+ // Setup
+ var project = new RingtoetsProject();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Call
+ var image = info.Image(project);
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(GuiResources.ProjectIcon, image);
+ }
+ }
+
+ [Test]
+ public void ChildNodeObjects_Always_ReturnsChildrenOfData()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+ var project = new RingtoetsProject();
+ project.AssessmentSections.Add(assessmentSection);
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+ // Call
+
+ var objects = info.ChildNodeObjects(project);
+
+ // Assert
+ Assert.AreEqual(1, objects.Length);
+ var actualAssessmentSection = (AssessmentSection) objects[0];
+ Assert.AreSame(assessmentSection, actualAssessmentSection);
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_Always_CallsBuilder()
+ {
+ // Setup
+ var menuBuilderMock = mockRepository.StrictMock();
+ menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.Build()).Return(null);
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var guiMock = mockRepository.Stub();
+ guiMock.Stub(g => g.Get(null, treeViewControl)).Return(menuBuilderMock);
+ guiMock.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ guiMock.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+ mockRepository.ReplayAll();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+ plugin.Gui = guiMock;
+
+ // Call
+ info.ContextMenuStrip(null, null, treeViewControl);
+ }
+ }
+ // Assert
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void ContextMenuStrip_Always_ContextMenuItemAddAssessmentSectionEnabled()
+ {
+ // Setup
+ var guiMock = mockRepository.StrictMock();
+ guiMock.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ guiMock.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+
+ var project = new RingtoetsProject();
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ guiMock.Expect(cmp => cmp.Get(project, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
+ mockRepository.ReplayAll();
+
+ using (var plugin = new RingtoetsPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ plugin.Gui = guiMock;
+
+ // Call
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(project, null, treeViewControl))
+ {
+ const string expectedItemText = "T&raject toevoegen...";
+ const string expectedItemTooltip = "Voeg een nieuw traject toe aan het project.";
+ TestHelper.AssertContextMenuStripContainsItem(contextMenu, 0, expectedItemText, expectedItemTooltip, Resources.AddAssessmentSectionFolder);
+ }
+ }
+ }
+ // Assert
+ mockRepository.VerifyAll(); // Expect no calls on arguments
+ }
+
+ private static TreeNodeInfo GetInfo(RingtoetsPlugin plugin)
+ {
+ return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(RingtoetsProject));
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultContextTreeNodeInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -0,0 +1,138 @@
+// 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.Controls.TreeView;
+using Core.Common.Gui;
+using Core.Common.Gui.ContextMenu;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Forms.PresentationObjects;
+using Ringtoets.Integration.Data.StandAlone;
+using Ringtoets.Integration.Data.StandAlone.SectionResults;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.Integration.Plugin.Test.TreeNodeInfos
+{
+ [TestFixture]
+ public class StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultContextTreeNodeInfoTest
+ {
+ private MockRepository mocks;
+ private RingtoetsPlugin plugin;
+ private TreeNodeInfo info;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks = new MockRepository();
+ plugin = new RingtoetsPlugin();
+ info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(FailureMechanismSectionResultContext));
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ plugin.Dispose();
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ // Assert
+ Assert.AreEqual(typeof(FailureMechanismSectionResultContext), info.TagType);
+
+ Assert.IsNull(info.ChildNodeObjects);
+ Assert.IsNull(info.ForeColor);
+ Assert.IsNull(info.EnsureVisibleOnCreate);
+ Assert.IsNull(info.CanRename);
+ Assert.IsNull(info.OnNodeRenamed);
+ Assert.IsNull(info.CanRemove);
+ Assert.IsNull(info.OnNodeRemoved);
+ Assert.IsNull(info.CanCheck);
+ Assert.IsNull(info.IsChecked);
+ Assert.IsNull(info.OnNodeChecked);
+ Assert.IsNull(info.CanDrag);
+ Assert.IsNull(info.CanDrop);
+ Assert.IsNull(info.CanInsert);
+ Assert.IsNull(info.OnDrop);
+ }
+
+ [Test]
+ public void Text_Always_ReturnsName()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ var mechanism = new StrengthStabilityLengthwiseConstructionFailureMechanism();
+ var context = new FailureMechanismSectionResultContext(mechanism.SectionResults, mechanism);
+
+ // Call
+ var text = info.Text(context);
+
+ // Assert
+ Assert.AreEqual("Resultaat", text);
+ }
+
+ [Test]
+ public void Image_Always_ReturnsGenericInputOutputIcon()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ // Call
+ var image = info.Image(null);
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.FailureMechanismSectionResultIcon, image);
+ }
+
+ [Test]
+ public void ContextMenuStrip_Always_CallsBuilder()
+ {
+ // Setup
+ var menuBuilderMock = mocks.StrictMock();
+ menuBuilderMock.Expect(mb => mb.AddOpenItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.Build()).Return(null);
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var gui = mocks.Stub();
+ gui.Stub(g => g.Get(null, treeViewControl)).Return(menuBuilderMock);
+ gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ // Call
+ info.ContextMenuStrip(null, null, treeViewControl);
+ }
+ // Assert
+ // Assert expectancies are called in TearDown()
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/TechnicalInnovationFailureMechanismSectionResultContextTreeNodeInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/TechnicalInnovationFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/TechnicalInnovationFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -0,0 +1,138 @@
+// 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.Controls.TreeView;
+using Core.Common.Gui;
+using Core.Common.Gui.ContextMenu;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Forms.PresentationObjects;
+using Ringtoets.Integration.Data.StandAlone;
+using Ringtoets.Integration.Data.StandAlone.SectionResults;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.Integration.Plugin.Test.TreeNodeInfos
+{
+ [TestFixture]
+ public class TechnicalInnovationFailureMechanismSectionResultContextTreeNodeInfoTest
+ {
+ private MockRepository mocks;
+ private RingtoetsPlugin plugin;
+ private TreeNodeInfo info;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks = new MockRepository();
+ plugin = new RingtoetsPlugin();
+ info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(FailureMechanismSectionResultContext));
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ plugin.Dispose();
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ // Assert
+ Assert.AreEqual(typeof(FailureMechanismSectionResultContext), info.TagType);
+
+ Assert.IsNull(info.ChildNodeObjects);
+ Assert.IsNull(info.ForeColor);
+ Assert.IsNull(info.EnsureVisibleOnCreate);
+ Assert.IsNull(info.CanRename);
+ Assert.IsNull(info.OnNodeRenamed);
+ Assert.IsNull(info.CanRemove);
+ Assert.IsNull(info.OnNodeRemoved);
+ Assert.IsNull(info.CanCheck);
+ Assert.IsNull(info.IsChecked);
+ Assert.IsNull(info.OnNodeChecked);
+ Assert.IsNull(info.CanDrag);
+ Assert.IsNull(info.CanDrop);
+ Assert.IsNull(info.CanInsert);
+ Assert.IsNull(info.OnDrop);
+ }
+
+ [Test]
+ public void Text_Always_ReturnsName()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ var mechanism = new TechnicalInnovationFailureMechanism();
+ var context = new FailureMechanismSectionResultContext(mechanism.SectionResults, mechanism);
+
+ // Call
+ var text = info.Text(context);
+
+ // Assert
+ Assert.AreEqual("Resultaat", text);
+ }
+
+ [Test]
+ public void Image_Always_ReturnsGenericInputOutputIcon()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ // Call
+ var image = info.Image(null);
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.FailureMechanismSectionResultIcon, image);
+ }
+
+ [Test]
+ public void ContextMenuStrip_Always_CallsBuilder()
+ {
+ // Setup
+ var menuBuilderMock = mocks.StrictMock();
+ menuBuilderMock.Expect(mb => mb.AddOpenItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.Build()).Return(null);
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var gui = mocks.Stub();
+ gui.Stub(g => g.Get(null, treeViewControl)).Return(menuBuilderMock);
+ gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ // Call
+ info.ContextMenuStrip(null, null, treeViewControl);
+ }
+ // Assert
+ // Assert expectancies are called in TearDown()
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/WaterPressureAsphaltCoverFailureMechanismSectionResultContextTreeNodeInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/WaterPressureAsphaltCoverFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/WaterPressureAsphaltCoverFailureMechanismSectionResultContextTreeNodeInfoTest.cs (revision 2d006ceaaef282af15090fe5505ffeca58a291e0)
@@ -0,0 +1,138 @@
+// 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.Controls.TreeView;
+using Core.Common.Gui;
+using Core.Common.Gui.ContextMenu;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Forms.PresentationObjects;
+using Ringtoets.Integration.Data.StandAlone;
+using Ringtoets.Integration.Data.StandAlone.SectionResults;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.Integration.Plugin.Test.TreeNodeInfos
+{
+ [TestFixture]
+ public class WaterPressureAsphaltCoverFailureMechanismSectionResultContextTreeNodeInfoTest
+ {
+ private MockRepository mocks;
+ private RingtoetsPlugin plugin;
+ private TreeNodeInfo info;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks = new MockRepository();
+ plugin = new RingtoetsPlugin();
+ info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(FailureMechanismSectionResultContext));
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ plugin.Dispose();
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ // Assert
+ Assert.AreEqual(typeof(FailureMechanismSectionResultContext