Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs =================================================================== diff -u -r98929f84fbf311bd19d8e61cc8499cdb40b22ea0 -rc909835782c9416cd44e2c7e43ff28a678928b1c --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs (.../ClosingStructuresPlugin.cs) (revision 98929f84fbf311bd19d8e61cc8499cdb40b22ea0) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs (.../ClosingStructuresPlugin.cs) (revision c909835782c9416cd44e2c7e43ff28a678928b1c) @@ -130,6 +130,15 @@ .AddPropertiesItem() .Build() }; + + yield return new TreeNodeInfo + { + Text = context => RingtoetsCommonFormsResources.Scenarios_DisplayName, + Image = context => RingtoetsCommonFormsResources.ScenariosIcon, + ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl) + .AddOpenItem() + .Build() + }; } public override IEnumerable GetImportInfos() @@ -211,6 +220,7 @@ { return new ArrayList { + new ClosingStructuresScenariosContext(failureMechanism.CalculationsGroup, failureMechanism), new FailureMechanismSectionResultContext(failureMechanism.SectionResults, failureMechanism) }; } Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Ringtoets.ClosingStructures.Forms.Test.csproj =================================================================== diff -u -rd02fb5898bd5e5964c1798f3926b458cd777aaf3 -rc909835782c9416cd44e2c7e43ff28a678928b1c --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Ringtoets.ClosingStructures.Forms.Test.csproj (.../Ringtoets.ClosingStructures.Forms.Test.csproj) (revision d02fb5898bd5e5964c1798f3926b458cd777aaf3) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Ringtoets.ClosingStructures.Forms.Test.csproj (.../Ringtoets.ClosingStructures.Forms.Test.csproj) (revision c909835782c9416cd44e2c7e43ff28a678928b1c) @@ -76,6 +76,7 @@ + Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructureFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -r6b6f344a9cf3e6c44b63320dfa3f5c828c4221d8 -rc909835782c9416cd44e2c7e43ff28a678928b1c --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructureFailureMechanismContextTreeNodeInfoTest.cs (.../ClosingStructureFailureMechanismContextTreeNodeInfoTest.cs) (revision 6b6f344a9cf3e6c44b63320dfa3f5c828c4221d8) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructureFailureMechanismContextTreeNodeInfoTest.cs (.../ClosingStructureFailureMechanismContextTreeNodeInfoTest.cs) (revision c909835782c9416cd44e2c7e43ff28a678928b1c) @@ -143,9 +143,13 @@ var outputsFolder = (CategoryTreeFolder) children[2]; Assert.AreEqual("Oordeel", outputsFolder.Name); Assert.AreEqual(TreeFolderCategory.Output, outputsFolder.Category); - Assert.AreEqual(1, outputsFolder.Contents.Count); + Assert.AreEqual(2, outputsFolder.Contents.Count); - var failureMechanismResultsContext = (FailureMechanismSectionResultContext) outputsFolder.Contents[0]; + var scenariosContext = (ClosingStructuresScenariosContext) outputsFolder.Contents[0]; + Assert.AreSame(failureMechanism.CalculationsGroup, scenariosContext.WrappedData); + Assert.AreSame(failureMechanism, scenariosContext.ParentFailureMechanism); + + var failureMechanismResultsContext = (FailureMechanismSectionResultContext) outputsFolder.Contents[1]; Assert.AreSame(failureMechanism, failureMechanismResultsContext.FailureMechanism); Assert.AreSame(failureMechanism.SectionResults, failureMechanismResultsContext.WrappedData); } Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructuresInputContextTreeNodeInfoTest.cs =================================================================== diff -u -r6b6f344a9cf3e6c44b63320dfa3f5c828c4221d8 -rc909835782c9416cd44e2c7e43ff28a678928b1c --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructuresInputContextTreeNodeInfoTest.cs (.../ClosingStructuresInputContextTreeNodeInfoTest.cs) (revision 6b6f344a9cf3e6c44b63320dfa3f5c828c4221d8) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructuresInputContextTreeNodeInfoTest.cs (.../ClosingStructuresInputContextTreeNodeInfoTest.cs) (revision c909835782c9416cd44e2c7e43ff28a678928b1c) @@ -26,10 +26,8 @@ using Core.Common.TestUtil; using NUnit.Framework; using Rhino.Mocks; -using Ringtoets.ClosingStructures.Data; using Ringtoets.ClosingStructures.Forms.PresentationObjects; using Ringtoets.ClosingStructures.Plugin; -using Ringtoets.Common.Data.AssessmentSection; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; using ClosingStructuresFormsResources = Ringtoets.ClosingStructures.Forms.Properties.Resources; Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructuresScenariosContextTreeNodeInfoTest.cs =================================================================== diff -u --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructuresScenariosContextTreeNodeInfoTest.cs (revision 0) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructuresScenariosContextTreeNodeInfoTest.cs (revision c909835782c9416cd44e2c7e43ff28a678928b1c) @@ -0,0 +1,128 @@ +// 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.ClosingStructures.Forms.PresentationObjects; +using Ringtoets.ClosingStructures.Plugin; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.ClosingStructures.Forms.Test.TreeNodeInfos +{ + [TestFixture] + public class ClosingStructuresScenariosContextTreeNodeInfoTest + { + private MockRepository mocks; + private ClosingStructuresPlugin plugin; + private TreeNodeInfo info; + + [SetUp] + public void SetUp() + { + mocks = new MockRepository(); + plugin = new ClosingStructuresPlugin(); + info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(ClosingStructuresScenariosContext)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + mocks.VerifyAll(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Setup + mocks.ReplayAll(); + + // Assert + Assert.AreEqual(typeof(ClosingStructuresScenariosContext), 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_ReturnsTextFromResource() + { + // Call + var text = info.Text(null); + + // Assert + Assert.AreEqual("Scenario's", text); + } + + [Test] + public void Image_Always_ReturnsSetImage() + { + // Call + var image = info.Image(null); + + // Assert + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.ScenariosIcon, image); + } + + [Test] + public void ContextMenuStrip_Always_CallsBuilderMethods() + { + // Setup + var guiMock = mocks.StrictMock(); + var menuBuilderMock = mocks.StrictMock(); + + using (var treeViewControl = new TreeViewControl()) + { + guiMock.Expect(g => g.Get(null, treeViewControl)).Return(menuBuilderMock); + + menuBuilderMock.Expect(mb => mb.AddOpenItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.Build()).Return(null); + mocks.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/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/ClosingStructuresPluginTest.cs =================================================================== diff -u -rc6b1371c973eedaa7267dab274ac9d5cb3c8171b -rc909835782c9416cd44e2c7e43ff28a678928b1c --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/ClosingStructuresPluginTest.cs (.../ClosingStructuresPluginTest.cs) (revision c6b1371c973eedaa7267dab274ac9d5cb3c8171b) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/ClosingStructuresPluginTest.cs (.../ClosingStructuresPluginTest.cs) (revision c909835782c9416cd44e2c7e43ff28a678928b1c) @@ -80,14 +80,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(ClosingStructuresFailureMechanismContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(ClosingStructuresContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(ClosingStructure))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(ClosingStructuresCalculationGroupContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(ClosingStructuresCalculationContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(ClosingStructuresInputContext))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(ClosingStructuresScenariosContext))); } }