Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs =================================================================== diff -u -rb2841ec8a6fc64308b1ede3988aeddc479a749a0 -r4e8b7f9361b06dbfe875188995c7b8cf94ed762d --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs (.../GrassCoverErosionInwardsPlugin.cs) (revision b2841ec8a6fc64308b1ede3988aeddc479a749a0) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs (.../GrassCoverErosionInwardsPlugin.cs) (revision 4e8b7f9361b06dbfe875188995c7b8cf94ed762d) @@ -302,6 +302,15 @@ ForeColor = output => Color.FromKnownColor(KnownColor.GrayText) }; + yield return new TreeNodeInfo + { + Text = output => GrassCoverErosionInwardsFormsResources.OvertoppingRate_DisplayName, + Image = output => RingtoetsCommonFormsResources.GeneralOutputIcon, + ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl) + .AddPropertiesItem() + .Build() + }; + } private void CalculateAll(GrassCoverErosionInwardsFailureMechanism failureMechanism, IEnumerable calculations, IAssessmentSection assessmentSection) @@ -933,26 +942,12 @@ private static object[] OutputContextChildNodeObjects(GrassCoverErosionInwardsOutputContext context) { - var childNodes = new List + return new[] { - context.WrappedData.OvertoppingOutput + context.WrappedData.OvertoppingOutput, + context.WrappedData.DikeHeightOutput ?? (object) new EmptyDikeHeightOutput(), + context.WrappedData.OvertoppingRateOutput ?? (object) new EmptyOvertoppingRateOutput() }; - - if (context.WrappedData.DikeHeightOutput != null) - { - childNodes.Add(context.WrappedData.DikeHeightOutput); - } - else - { - childNodes.Add(new EmptyDikeHeightOutput()); - } - - if (context.WrappedData.OvertoppingRateOutput == null) - { - childNodes.Add(new EmptyOvertoppingRateOutput()); - } - - return childNodes.ToArray(); } #endregion Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/GrassCoverErosionInwardsPluginTest.cs =================================================================== diff -u -rb2841ec8a6fc64308b1ede3988aeddc479a749a0 -r4e8b7f9361b06dbfe875188995c7b8cf94ed762d --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/GrassCoverErosionInwardsPluginTest.cs (.../GrassCoverErosionInwardsPluginTest.cs) (revision b2841ec8a6fc64308b1ede3988aeddc479a749a0) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/GrassCoverErosionInwardsPluginTest.cs (.../GrassCoverErosionInwardsPluginTest.cs) (revision 4e8b7f9361b06dbfe875188995c7b8cf94ed762d) @@ -106,7 +106,7 @@ TreeNodeInfo[] treeNodeInfos = plugin.GetTreeNodeInfos().ToArray(); // Assert - Assert.AreEqual(12, treeNodeInfos.Length); + Assert.AreEqual(13, treeNodeInfos.Length); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(GrassCoverErosionInwardsFailureMechanismContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(DikeProfilesContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(GrassCoverErosionInwardsCalculationGroupContext))); @@ -119,6 +119,7 @@ Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(EmptyDikeHeightOutput))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(DikeHeightOutput))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(EmptyOvertoppingRateOutput))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(OvertoppingRateOutput))); } } Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj =================================================================== diff -u -rb2841ec8a6fc64308b1ede3988aeddc479a749a0 -r4e8b7f9361b06dbfe875188995c7b8cf94ed762d --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj) (revision b2841ec8a6fc64308b1ede3988aeddc479a749a0) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj) (revision 4e8b7f9361b06dbfe875188995c7b8cf94ed762d) @@ -84,6 +84,7 @@ + Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsOutputContextTreeNodeInfoTest.cs =================================================================== diff -u -rb2841ec8a6fc64308b1ede3988aeddc479a749a0 -r4e8b7f9361b06dbfe875188995c7b8cf94ed762d --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsOutputContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsOutputContextTreeNodeInfoTest.cs) (revision b2841ec8a6fc64308b1ede3988aeddc479a749a0) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsOutputContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsOutputContextTreeNodeInfoTest.cs) (revision 4e8b7f9361b06dbfe875188995c7b8cf94ed762d) @@ -127,13 +127,16 @@ object[] children = info.ChildNodeObjects(context).ToArray(); // Assert - Assert.AreEqual(2, children.Length); + Assert.AreEqual(3, children.Length); var overtoppingOutput = children[0] as GrassCoverErosionInwardsOvertoppingOutput; Assert.AreSame(context.WrappedData.OvertoppingOutput, overtoppingOutput); var dikeHeightOutput = children[1] as DikeHeightOutput; Assert.AreSame(context.WrappedData.DikeHeightOutput, dikeHeightOutput); + + var overtoppingRateOutput = children[2] as OvertoppingRateOutput; + Assert.AreSame(context.WrappedData.OvertoppingRateOutput, overtoppingRateOutput); } [Test] Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/OvertoppingRateOutputTreeNodeInfoTest.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/OvertoppingRateOutputTreeNodeInfoTest.cs (revision 0) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/OvertoppingRateOutputTreeNodeInfoTest.cs (revision 4e8b7f9361b06dbfe875188995c7b8cf94ed762d) @@ -0,0 +1,136 @@ +// Copyright (C) Stichting Deltares 2017. 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.GrassCoverErosionInwards.Data; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.GrassCoverErosionInwards.Plugin.Test.TreeNodeInfos +{ + [TestFixture] + public class OvertoppingRateOutputTreeNodeInfoTest + { + private MockRepository mocks; + private GrassCoverErosionInwardsPlugin plugin; + private TreeNodeInfo info; + + [SetUp] + public void SetUp() + { + mocks = new MockRepository(); + plugin = new GrassCoverErosionInwardsPlugin(); + info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(OvertoppingRateOutput)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + mocks.VerifyAll(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Setup + mocks.ReplayAll(); + + // Assert + Assert.IsNotNull(info.Text); + Assert.IsNull(info.ForeColor); + Assert.IsNotNull(info.Image); + Assert.IsNotNull(info.ContextMenuStrip); + Assert.IsNull(info.EnsureVisibleOnCreate); + Assert.IsNull(info.ExpandOnCreate); + 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 + mocks.ReplayAll(); + + // Call + string text = info.Text(null); + + // Assert + Assert.AreEqual("Overslagdebiet", text); + } + + [Test] + public void Image_Always_ReturnsGeneralOutputIcon() + { + // Setup + mocks.ReplayAll(); + + // Call + Image image = info.Image(null); + + // Assert + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GeneralOutputIcon, image); + } + + [Test] + public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods() + { + // Setup + var menuBuilderMock = mocks.StrictMock(); + using (mocks.Ordered()) + { + 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(cmp => cmp.Get(null, treeViewControl)).Return(menuBuilderMock); + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + info.ContextMenuStrip(null, null, treeViewControl); + } + // Assert + // Assert expectancies called in TearDown() + } + } +} \ No newline at end of file