Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsInputContextTreeNodeInfoTest.cs =================================================================== diff -u -r33efdf255d012f47a045c7f3181487e0453cf5e2 -r80dce3e20a58c31ec56ee8ee734a1127b9a0cb28 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsInputContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsInputContextTreeNodeInfoTest.cs) (revision 33efdf255d012f47a045c7f3181487e0453cf5e2) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsInputContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsInputContextTreeNodeInfoTest.cs) (revision 80dce3e20a58c31ec56ee8ee734a1127b9a0cb28) @@ -56,6 +56,9 @@ { // Assert Assert.AreEqual(typeof(GrassCoverErosionInwardsInputContext), 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); @@ -77,12 +80,13 @@ { // Setup var generalInput = new GeneralGrassCoverErosionInwardsInput(); - var assessmentSection = mocksRepository.StrictMock(); + var assessmentSectionMock = mocksRepository.StrictMock(); var grassCoverErosionInwardsInputContext = new GrassCoverErosionInwardsInputContext( mocksRepository.StrictMock(generalInput), mocksRepository.StrictMock(generalInput, new GeneralNormProbabilityInput()), new GrassCoverErosionInwardsFailureMechanism(), - assessmentSection); + assessmentSectionMock); + mocksRepository.ReplayAll(); // Call @@ -98,12 +102,13 @@ { // Setup var generalInput = new GeneralGrassCoverErosionInwardsInput(); - var assessmentSection = mocksRepository.StrictMock(); + var assessmentSectionMock = mocksRepository.StrictMock(); var grassCoverErosionInwardsInputContext = new GrassCoverErosionInwardsInputContext( mocksRepository.StrictMock(generalInput), mocksRepository.StrictMock(generalInput, new GeneralNormProbabilityInput()), new GrassCoverErosionInwardsFailureMechanism(), - assessmentSection); + assessmentSectionMock); + mocksRepository.ReplayAll(); // Call @@ -116,14 +121,14 @@ } [Test] - public void ContextMenuStrip_Always_CallsBuilder() + public void ContextMenuStrip_Always_CallsBuilderMethods() { // Setup - var gui = mocksRepository.StrictMultiMock(); - var treeViewControl = mocksRepository.StrictMock(); + var guiMock = mocksRepository.StrictMock(); + var treeViewControlMock = mocksRepository.StrictMock(); var menuBuilderMock = mocksRepository.StrictMock(); - gui.Expect(g => g.Get(null, treeViewControl)).Return(menuBuilderMock); + guiMock.Expect(g => g.Get(null, treeViewControlMock)).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddImportItem()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddExportItem()).Return(menuBuilderMock); @@ -132,10 +137,10 @@ menuBuilderMock.Expect(mb => mb.Build()).Return(null); mocksRepository.ReplayAll(); - plugin.Gui = gui; + plugin.Gui = guiMock; // Call - info.ContextMenuStrip(null, null, treeViewControl); + info.ContextMenuStrip(null, null, treeViewControlMock); // Assert mocksRepository.VerifyAll(); Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Properties/Resources.Designer.cs =================================================================== diff -u -r20231cfee041a316978347564bd1fddbb41b9ffc -r80dce3e20a58c31ec56ee8ee734a1127b9a0cb28 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 20231cfee041a316978347564bd1fddbb41b9ffc) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 80dce3e20a58c31ec56ee8ee734a1127b9a0cb28) @@ -106,5 +106,14 @@ "", resourceCulture); } } + + /// + /// Looks up a localized string similar to Invoer. + /// + public static string HeightStructuresInputContext_NodeDisplayName { + get { + return ResourceManager.GetString("HeightStructuresInputContext_NodeDisplayName", resourceCulture); + } + } } } Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Properties/Resources.resx =================================================================== diff -u -r20231cfee041a316978347564bd1fddbb41b9ffc -r80dce3e20a58c31ec56ee8ee734a1127b9a0cb28 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Properties/Resources.resx (.../Resources.resx) (revision 20231cfee041a316978347564bd1fddbb41b9ffc) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Properties/Resources.resx (.../Resources.resx) (revision 80dce3e20a58c31ec56ee8ee734a1127b9a0cb28) @@ -129,6 +129,9 @@ De berekening + + Invoer + ..\Resources\control_equalizer_blue.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresGuiPlugin.cs =================================================================== diff -u -r7cebb168afee29822b64f213045a21520b38ade0 -r80dce3e20a58c31ec56ee8ee734a1127b9a0cb28 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresGuiPlugin.cs (.../HeightStructuresGuiPlugin.cs) (revision 7cebb168afee29822b64f213045a21520b38ade0) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresGuiPlugin.cs (.../HeightStructuresGuiPlugin.cs) (revision 80dce3e20a58c31ec56ee8ee734a1127b9a0cb28) @@ -64,6 +64,18 @@ CalculationContextContextMenuStrip, CalculationContextOnNodeRemoved); + yield return new TreeNodeInfo + { + Text = inputContext => HeightStructuresFormsResources.HeightStructuresInputContext_NodeDisplayName, + Image = inputContext => RingtoetsCommonFormsResources.GenericInputOutputIcon, + ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl) + .AddImportItem() + .AddExportItem() + .AddSeparator() + .AddPropertiesItem() + .Build() + }; + yield return new TreeNodeInfo { Text = pipingOutput => RingtoetsCommonFormsResources.CalculationOutput_DisplayName, Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PresentationObjects/HeightStructuresInputContextTest.cs =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PresentationObjects/HeightStructuresInputContextTest.cs (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PresentationObjects/HeightStructuresInputContextTest.cs (revision 80dce3e20a58c31ec56ee8ee734a1127b9a0cb28) @@ -0,0 +1,86 @@ +// 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 Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Calculation; +using Ringtoets.HeightStructures.Data; +using Ringtoets.HeightStructures.Forms.PresentationObjects; +using Ringtoets.HeightStructures.Forms.Properties; + +namespace Ringtoets.HeightStructures.Forms.Test.PresentationObjects +{ + [TestFixture] + public class HeightStructuresInputContextTest + { + private MockRepository mocksRepository; + + [SetUp] + public void SetUp() + { + mocksRepository = new MockRepository(); + } + + [Test] + public void ConstructorWithData_Always_ExpectedPropertiesSet() + { + // Setup + var inputMock = mocksRepository.StrictMock(); + var calculationMock = mocksRepository.StrictMock(); + var failureMechanismMock = mocksRepository.StrictMock(); + var assessmentSectionMock = mocksRepository.StrictMock(); + mocksRepository.ReplayAll(); + + // Call + var context = new HeightStructuresInputContext(inputMock, calculationMock, failureMechanismMock, assessmentSectionMock); + + // Assert + Assert.IsInstanceOf>(context); + Assert.AreEqual(inputMock, context.WrappedData); + Assert.AreEqual(calculationMock, context.Calculation); + Assert.AreEqual(failureMechanismMock, context.FailureMechanism); + Assert.AreEqual(assessmentSectionMock, context.AssessmentSection); + mocksRepository.VerifyAll(); + } + + [Test] + public void Constructor_NullCalculation_ThrowsArgumentNullException() + { + // Setup + var inputMock = mocksRepository.StrictMock(); + var failureMechanismMock = mocksRepository.StrictMock(); + var assessmentSectionMock = mocksRepository.StrictMock(); + mocksRepository.ReplayAll(); + + // Call + TestDelegate test = () => new HeightStructuresInputContext(inputMock, null, failureMechanismMock, assessmentSectionMock); + + // Assert + var message = String.Format(Resources.HeightStructuresContext_AssertInputsAreNotNull_DataDescription_0_cannot_be_null, + Resources.HeightStructuresInputContext_DataDescription_HeightStructuresInputCalculationItem); + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, message); + mocksRepository.VerifyAll(); + } + } +} Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Ringtoets.HeightStructures.Forms.Test.csproj =================================================================== diff -u -re17e5b2635c772e29fb45610f10a3b4021ab7eaa -r80dce3e20a58c31ec56ee8ee734a1127b9a0cb28 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Ringtoets.HeightStructures.Forms.Test.csproj (.../Ringtoets.HeightStructures.Forms.Test.csproj) (revision e17e5b2635c772e29fb45610f10a3b4021ab7eaa) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Ringtoets.HeightStructures.Forms.Test.csproj (.../Ringtoets.HeightStructures.Forms.Test.csproj) (revision 80dce3e20a58c31ec56ee8ee734a1127b9a0cb28) @@ -60,7 +60,8 @@ - + + Fisheye: Tag 80dce3e20a58c31ec56ee8ee734a1127b9a0cb28 refers to a dead (removed) revision in file `Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresInputContextTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresInputContextTreeNodeInfoTest.cs =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresInputContextTreeNodeInfoTest.cs (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresInputContextTreeNodeInfoTest.cs (revision 80dce3e20a58c31ec56ee8ee734a1127b9a0cb28) @@ -0,0 +1,146 @@ +// 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.HeightStructures.Data; +using Ringtoets.HeightStructures.Forms.PresentationObjects; +using Ringtoets.HeightStructures.Plugin; +using HeightStructuresFormsResources = Ringtoets.HeightStructures.Forms.Properties.Resources; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.HeightStructures.Forms.Test.TreeNodeInfos +{ + [TestFixture] + public class HeightStructuresInputContextTreeNodeInfoTest + { + private MockRepository mocksRepository; + private HeightStructuresGuiPlugin plugin; + private TreeNodeInfo info; + + [SetUp] + public void SetUp() + { + mocksRepository = new MockRepository(); + plugin = new HeightStructuresGuiPlugin(); + info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(HeightStructuresInputContext)); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Assert + Assert.AreEqual(typeof(HeightStructuresInputContext), 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() + { + // Setup + var assessmentSectionMock = mocksRepository.StrictMock(); + var heightStructuresInputContext = new HeightStructuresInputContext( + new HeightStructuresInput(), + new HeightStructuresCalculation(), + new HeightStructuresFailureMechanism(), + assessmentSectionMock); + + mocksRepository.ReplayAll(); + + // Call + var text = info.Text(heightStructuresInputContext); + + // Assert + Assert.AreEqual(HeightStructuresFormsResources.HeightStructuresInputContext_NodeDisplayName, text); + mocksRepository.VerifyAll(); + } + + [Test] + public void Image_Always_ReturnsSetImage() + { + // Setup + var assessmentSectionMock = mocksRepository.StrictMock(); + var heightStructuresInputContext = new HeightStructuresInputContext( + new HeightStructuresInput(), + new HeightStructuresCalculation(), + new HeightStructuresFailureMechanism(), + assessmentSectionMock); + + mocksRepository.ReplayAll(); + + // Call + var image = info.Image(heightStructuresInputContext); + + // Assert + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, image); + + mocksRepository.VerifyAll(); + } + + [Test] + public void ContextMenuStrip_Always_CallsBuilderMethods() + { + // Setup + var guiMock = mocksRepository.StrictMock(); + var treeViewControlMock = mocksRepository.StrictMock(); + var menuBuilderMock = mocksRepository.StrictMock(); + + guiMock.Expect(g => g.Get(null, treeViewControlMock)).Return(menuBuilderMock); + + menuBuilderMock.Expect(mb => mb.AddImportItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddExportItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.Build()).Return(null); + mocksRepository.ReplayAll(); + + plugin.Gui = guiMock; + + // Call + info.ContextMenuStrip(null, null, treeViewControlMock); + + // Assert + mocksRepository.VerifyAll(); + } + } +} Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/HeightStructuresGuiPluginTest.cs =================================================================== diff -u -re2986d74885385074ad0f6d164a722c0c7e39a8b -r80dce3e20a58c31ec56ee8ee734a1127b9a0cb28 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/HeightStructuresGuiPluginTest.cs (.../HeightStructuresGuiPluginTest.cs) (revision e2986d74885385074ad0f6d164a722c0c7e39a8b) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/HeightStructuresGuiPluginTest.cs (.../HeightStructuresGuiPluginTest.cs) (revision 80dce3e20a58c31ec56ee8ee734a1127b9a0cb28) @@ -68,10 +68,11 @@ TreeNodeInfo[] treeNodeInfos = guiPlugin.GetTreeNodeInfos().ToArray(); // Assert - Assert.AreEqual(5, treeNodeInfos.Length); + Assert.AreEqual(6, 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(HeightStructuresOutput))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(EmptyHeightStructuresOutput))); }