Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PresentationObjects/HeightStructuresScenariosContext.cs =================================================================== diff -u --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PresentationObjects/HeightStructuresScenariosContext.cs (revision 0) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PresentationObjects/HeightStructuresScenariosContext.cs (revision 2f94a4a9a4058aa718129ba8d399e5944a994070) @@ -0,0 +1,47 @@ +// 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 Core.Common.Controls.PresentationObjects; +using Ringtoets.Common.Data.Calculation; +using Ringtoets.HeightStructures.Data; + +namespace Ringtoets.HeightStructures.Forms.PresentationObjects +{ + /// + /// Presentation object for configuration of scenarios for the Grass Cover Erosion Inwards + /// failure mechanism. + /// + public class HeightStructuresScenariosContext : WrappedObjectContextBase + { + /// + /// Creates a new instance of . + /// + /// The wrapped . + /// A forming the context. + public HeightStructuresScenariosContext(CalculationGroup wrappedData, HeightStructuresFailureMechanism failureMechanism) + : base(wrappedData) + { + ParentFailureMechanism = failureMechanism; + } + + public HeightStructuresFailureMechanism ParentFailureMechanism { get; private set; } + } +} \ No newline at end of file Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Ringtoets.HeightStructures.Forms.csproj =================================================================== diff -u -re59a92bdf530c0f3522a25253350f6f6f593ddbd -r2f94a4a9a4058aa718129ba8d399e5944a994070 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Ringtoets.HeightStructures.Forms.csproj (.../Ringtoets.HeightStructures.Forms.csproj) (revision e59a92bdf530c0f3522a25253350f6f6f593ddbd) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Ringtoets.HeightStructures.Forms.csproj (.../Ringtoets.HeightStructures.Forms.csproj) (revision 2f94a4a9a4058aa718129ba8d399e5944a994070) @@ -41,6 +41,7 @@ Properties\GlobalAssembly.cs + Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs =================================================================== diff -u -re59a92bdf530c0f3522a25253350f6f6f593ddbd -r2f94a4a9a4058aa718129ba8d399e5944a994070 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs (.../HeightStructuresPlugin.cs) (revision e59a92bdf530c0f3522a25253350f6f6f593ddbd) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs (.../HeightStructuresPlugin.cs) (revision 2f94a4a9a4058aa718129ba8d399e5944a994070) @@ -149,6 +149,15 @@ .Build() }; + yield return new TreeNodeInfo + { + Text = context => RingtoetsCommonFormsResources.Scenarios_DisplayName, + Image = context => RingtoetsCommonFormsResources.ScenariosIcon, + ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl) + .AddOpenItem() + .Build() + }; + yield return new TreeNodeInfo> { Text = context => RingtoetsCommonFormsResources.FailureMechanism_AssessmentResult_DisplayName, @@ -253,6 +262,7 @@ { return new ArrayList { + new HeightStructuresScenariosContext(failureMechanism.CalculationsGroup, failureMechanism), new FailureMechanismSectionResultContext(failureMechanism.SectionResults, failureMechanism) }; } Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Ringtoets.HeightStructures.Forms.Test.csproj =================================================================== diff -u -re59a92bdf530c0f3522a25253350f6f6f593ddbd -r2f94a4a9a4058aa718129ba8d399e5944a994070 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Ringtoets.HeightStructures.Forms.Test.csproj (.../Ringtoets.HeightStructures.Forms.Test.csproj) (revision e59a92bdf530c0f3522a25253350f6f6f593ddbd) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Ringtoets.HeightStructures.Forms.Test.csproj (.../Ringtoets.HeightStructures.Forms.Test.csproj) (revision 2f94a4a9a4058aa718129ba8d399e5944a994070) @@ -71,6 +71,7 @@ + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -rb2306061789f5e34a6f0994552b4431d01d220f0 -r2f94a4a9a4058aa718129ba8d399e5944a994070 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision b2306061789f5e34a6f0994552b4431d01d220f0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision 2f94a4a9a4058aa718129ba8d399e5944a994070) @@ -141,7 +141,11 @@ var outputsFolder = (CategoryTreeFolder) children[2]; Assert.AreEqual("Oordeel", outputsFolder.Name); Assert.AreEqual(TreeFolderCategory.Output, outputsFolder.Category); - var failureMechanismResultsContext = (FailureMechanismSectionResultContext) outputsFolder.Contents[0]; + var scenariosContext = (HeightStructuresScenariosContext)outputsFolder.Contents[0]; + Assert.AreSame(failureMechanism, scenariosContext.ParentFailureMechanism); + Assert.AreSame(failureMechanism.CalculationsGroup, scenariosContext.WrappedData); + + var failureMechanismResultsContext = (FailureMechanismSectionResultContext) outputsFolder.Contents[1]; Assert.AreSame(failureMechanism, failureMechanismResultsContext.FailureMechanism); Assert.AreSame(failureMechanism.SectionResults, failureMechanismResultsContext.WrappedData); } Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresScenariosContextTreeNodeInfoTest.cs =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresScenariosContextTreeNodeInfoTest.cs (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresScenariosContextTreeNodeInfoTest.cs (revision 2f94a4a9a4058aa718129ba8d399e5944a994070) @@ -0,0 +1,142 @@ +// 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.Calculation; +using Ringtoets.HeightStructures.Data; +using Ringtoets.HeightStructures.Forms.PresentationObjects; +using Ringtoets.HeightStructures.Plugin; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.HeightStructures.Forms.Test.TreeNodeInfos +{ + [TestFixture] + public class HeightStructuresScenariosContextTreeNodeInfoTest + { + private HeightStructuresPlugin plugin; + private TreeNodeInfo info; + + [SetUp] + public void SetUp() + { + plugin = new HeightStructuresPlugin(); + info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(HeightStructuresScenariosContext)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Assert + Assert.AreEqual(typeof(HeightStructuresScenariosContext), 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.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_ReturnScenarios() + { + // Setup + var group = new CalculationGroup(); + var failureMechanism = new HeightStructuresFailureMechanism(); + var context = new HeightStructuresScenariosContext(group, failureMechanism); + + // Call + string text = info.Text(context); + + // Assert + Assert.AreEqual("Scenario's", text); + } + + [Test] + public void Image_Always_ReturnExpectedImage() + { + // Setup + var group = new CalculationGroup(); + var failureMechanism = new HeightStructuresFailureMechanism(); + var context = new HeightStructuresScenariosContext(group, failureMechanism); + + // Call + Image image = info.Image(context); + + // Assert + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.ScenariosIcon, image); + } + + [Test] + public void ContextMenuStrip_Always_CallsBuilder() + { + // Setup + using (var treeViewControl = new TreeViewControl()) + { + var group = new CalculationGroup(); + var failureMechanism = new HeightStructuresFailureMechanism(); + var context = new HeightStructuresScenariosContext(group, failureMechanism); + + var mocks = new MockRepository(); + + var menuBuilderMock = mocks.Stub(); + menuBuilderMock.Expect(mb => mb.AddOpenItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.Build()).Return(null); + + var gui = mocks.Stub(); + gui.Expect(g => g.Get(context, treeViewControl)).Return(menuBuilderMock); + + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + info.ContextMenuStrip(context, null, treeViewControl); + + // Assert + mocks.VerifyAll(); + } + } + } +} \ No newline at end of file Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/HeightStructuresPluginTest.cs =================================================================== diff -u -r6b9fda141298524c0910937dd090d82be420c52b -r2f94a4a9a4058aa718129ba8d399e5944a994070 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/HeightStructuresPluginTest.cs (.../HeightStructuresPluginTest.cs) (revision 6b9fda141298524c0910937dd090d82be420c52b) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/HeightStructuresPluginTest.cs (.../HeightStructuresPluginTest.cs) (revision 2f94a4a9a4058aa718129ba8d399e5944a994070) @@ -105,13 +105,15 @@ TreeNodeInfo[] treeNodeInfos = plugin.GetTreeNodeInfos().ToArray(); // Assert - Assert.AreEqual(7, treeNodeInfos.Length); + Assert.AreEqual(8, treeNodeInfos.Length); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HeightStructuresFailureMechanismContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HeightStructuresCalculationGroupContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HeightStructuresCalculationContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HeightStructuresInputContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HeightStructuresContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HeightStructure))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HeightStructuresScenariosContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext))); }