Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Data/GrassCoverErosionOutwardsFailureMechanism.cs =================================================================== diff -u -r4cacd866e5c6c2a5669a4c58f389b7f8e2c16374 -r1f58fe3574c5bad0bee42c6e02f679a718335ab2 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Data/GrassCoverErosionOutwardsFailureMechanism.cs (.../GrassCoverErosionOutwardsFailureMechanism.cs) (revision 4cacd866e5c6c2a5669a4c58f389b7f8e2c16374) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Data/GrassCoverErosionOutwardsFailureMechanism.cs (.../GrassCoverErosionOutwardsFailureMechanism.cs) (revision 1f58fe3574c5bad0bee42c6e02f679a718335ab2) @@ -44,7 +44,7 @@ { sectionResults = new List(); GeneralInput = new GeneralGrassCoverErosionOutwardsInput(); - HydraulicBoundariesCalculationGroup = new CalculationGroup(RingtoetsCommonDataResources.FailureMechanism_HydraulicBoundariesCalculationGroup_DisplayName, false); + HydraulicBoundariesCalculationGroup = new CalculationGroup(RingtoetsCommonDataResources.FailureMechanism_Calculations_DisplayName, false); } /// Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PresentationObjects/HydraulicBoundariesGroupContext.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PresentationObjects/HydraulicBoundariesGroupContext.cs (revision 0) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PresentationObjects/HydraulicBoundariesGroupContext.cs (revision 1f58fe3574c5bad0bee42c6e02f679a718335ab2) @@ -0,0 +1,55 @@ +// 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.Controls.PresentationObjects; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Calculation; + +namespace Ringtoets.GrassCoverErosionOutwards.Forms.PresentationObjects +{ + /// + /// Presentation object for Hydraulic boundary locations and calculations. + /// + public class HydraulicBoundariesGroupContext : ObservableWrappedObjectContextBase + { + /// + /// Initializes a new instance of the class. + /// + /// The assessment section which the context belongs to. + /// The instance wrapped by this context object. + /// Thrown when any input argument is null. + public HydraulicBoundariesGroupContext(IAssessmentSection assessmentSection, CalculationGroup calculationGroup) + : base(assessmentSection) + { + if (calculationGroup == null) + { + throw new ArgumentNullException("calculationGroup"); + } + HydraulicBoundariesCalculationGroup = calculationGroup; + } + + /// + /// Gets the hydraulic boundaries calculation groups. + /// + public CalculationGroup HydraulicBoundariesCalculationGroup { get; private set; } + } +} \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Ringtoets.GrassCoverErosionOutwards.Forms.csproj =================================================================== diff -u -rfa57b44c0603a332adc76bee0edd4e42f89e122c -r1f58fe3574c5bad0bee42c6e02f679a718335ab2 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Ringtoets.GrassCoverErosionOutwards.Forms.csproj (.../Ringtoets.GrassCoverErosionOutwards.Forms.csproj) (revision fa57b44c0603a332adc76bee0edd4e42f89e122c) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Ringtoets.GrassCoverErosionOutwards.Forms.csproj (.../Ringtoets.GrassCoverErosionOutwards.Forms.csproj) (revision 1f58fe3574c5bad0bee42c6e02f679a718335ab2) @@ -40,6 +40,7 @@ Properties\GlobalAssembly.cs + Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs =================================================================== diff -u -r4cacd866e5c6c2a5669a4c58f389b7f8e2c16374 -r1f58fe3574c5bad0bee42c6e02f679a718335ab2 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision 4cacd866e5c6c2a5669a4c58f389b7f8e2c16374) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision 1f58fe3574c5bad0bee42c6e02f679a718335ab2) @@ -80,9 +80,9 @@ .Build() }; - yield return new TreeNodeInfo + yield return new TreeNodeInfo { - Text = context => context.WrappedData.Name, + Text = context => RingtoetsCommonDataResources.FailureMechanism_HydraulicBoundariesCalculationGroup_DisplayName, Image = context => RingtoetsCommonFormsResources.GeneralFolderIcon, ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl) .AddExportItem() @@ -130,7 +130,7 @@ return new object[] { new CategoryTreeFolder(RingtoetsCommonFormsResources.FailureMechanism_Inputs_DisplayName, GetInputs(wrappedData, failureMechanismContext.Parent), TreeFolderCategory.Input), - new GrassCoverErosionOutwardsHydraulicBoundariesCalculationGroupContext(wrappedData.HydraulicBoundariesCalculationGroup), + new HydraulicBoundariesGroupContext(failureMechanismContext.Parent, wrappedData.HydraulicBoundariesCalculationGroup), new CategoryTreeFolder(RingtoetsCommonFormsResources.FailureMechanism_Outputs_DisplayName, GetOutputs(wrappedData), TreeFolderCategory.Output) }; } Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Data.Test/GrassCoverErosionOutwardsFailureMechanismTest.cs =================================================================== diff -u -r4cacd866e5c6c2a5669a4c58f389b7f8e2c16374 -r1f58fe3574c5bad0bee42c6e02f679a718335ab2 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Data.Test/GrassCoverErosionOutwardsFailureMechanismTest.cs (.../GrassCoverErosionOutwardsFailureMechanismTest.cs) (revision 4cacd866e5c6c2a5669a4c58f389b7f8e2c16374) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Data.Test/GrassCoverErosionOutwardsFailureMechanismTest.cs (.../GrassCoverErosionOutwardsFailureMechanismTest.cs) (revision 1f58fe3574c5bad0bee42c6e02f679a718335ab2) @@ -41,7 +41,7 @@ Assert.AreEqual("GEBU", failureMechanism.Code); CollectionAssert.IsEmpty(failureMechanism.Sections); - Assert.AreEqual("Hydraulische randvoorwaarden", failureMechanism.HydraulicBoundariesCalculationGroup.Name); + Assert.AreEqual("Berekeningen", failureMechanism.HydraulicBoundariesCalculationGroup.Name); Assert.IsFalse(failureMechanism.HydraulicBoundariesCalculationGroup.IsNameEditable); CollectionAssert.IsEmpty(failureMechanism.HydraulicBoundariesCalculationGroup.Children); } Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PresentationObjects/HydraulicBoundariesGroupContextTest.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PresentationObjects/HydraulicBoundariesGroupContextTest.cs (revision 0) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PresentationObjects/HydraulicBoundariesGroupContextTest.cs (revision 1f58fe3574c5bad0bee42c6e02f679a718335ab2) @@ -0,0 +1,71 @@ +// 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.Controls.PresentationObjects; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.GrassCoverErosionOutwards.Data; +using Ringtoets.GrassCoverErosionOutwards.Forms.PresentationObjects; + +namespace Ringtoets.GrassCoverErosionOutwards.Forms.Test.PresentationObjects +{ + [TestFixture] + public class HydraulicBoundariesGroupContextTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var assessmentSectionMock = mocks.StrictMock(); + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + + // Call + var context = new HydraulicBoundariesGroupContext(assessmentSectionMock,failureMechanism.HydraulicBoundariesCalculationGroup); + + // Assert + Assert.IsInstanceOf>(context); + Assert.AreSame(assessmentSectionMock, context.WrappedData); + Assert.AreSame(failureMechanism.HydraulicBoundariesCalculationGroup, context.HydraulicBoundariesCalculationGroup); + mocks.VerifyAll(); + } + + [Test] + public void Constructor_HydraulicBoundariesCalculationGroupIsNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSectionMock = mocks.StrictMock(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => new HydraulicBoundariesGroupContext(assessmentSectionMock, null); + + // Assert + var paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("calculationGroup", paramName); + } + } +} \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj =================================================================== diff -u -r4cacd866e5c6c2a5669a4c58f389b7f8e2c16374 -r1f58fe3574c5bad0bee42c6e02f679a718335ab2 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj (.../Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj) (revision 4cacd866e5c6c2a5669a4c58f389b7f8e2c16374) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj (.../Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj) (revision 1f58fe3574c5bad0bee42c6e02f679a718335ab2) @@ -59,11 +59,12 @@ + - + Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/GrassCoverErosionOutwardsFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -r4cacd866e5c6c2a5669a4c58f389b7f8e2c16374 -r1f58fe3574c5bad0bee42c6e02f679a718335ab2 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/GrassCoverErosionOutwardsFailureMechanismContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsFailureMechanismContextTreeNodeInfoTest.cs) (revision 4cacd866e5c6c2a5669a4c58f389b7f8e2c16374) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/GrassCoverErosionOutwardsFailureMechanismContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsFailureMechanismContextTreeNodeInfoTest.cs) (revision 1f58fe3574c5bad0bee42c6e02f679a718335ab2) @@ -194,8 +194,8 @@ var commentContext = (CommentContext) inputsFolder.Contents[1]; Assert.AreSame(failureMechanism, commentContext.WrappedData); - var hydraulicBoundariesCalculationGroup = (GrassCoverErosionOutwardsHydraulicBoundariesCalculationGroupContext) children[1]; - Assert.AreSame(failureMechanism.HydraulicBoundariesCalculationGroup, hydraulicBoundariesCalculationGroup.WrappedData); + var hydraulicBoundariesGroupContext = (HydraulicBoundariesGroupContext) children[1]; + Assert.AreSame(failureMechanism.HydraulicBoundariesCalculationGroup, hydraulicBoundariesGroupContext.HydraulicBoundariesCalculationGroup); var outputsFolder = (CategoryTreeFolder) children[2]; Assert.AreEqual("Oordeel", outputsFolder.Name); Fisheye: Tag 1f58fe3574c5bad0bee42c6e02f679a718335ab2 refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/GrassCoverErosionOutwardsHydraulicBoundariesCalculationGroupContextTreeNodeInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/HydraulicBoundariesGroupContextTreeNodeInfoTest.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/HydraulicBoundariesGroupContextTreeNodeInfoTest.cs (revision 0) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/HydraulicBoundariesGroupContextTreeNodeInfoTest.cs (revision 1f58fe3574c5bad0bee42c6e02f679a718335ab2) @@ -0,0 +1,145 @@ +// 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.Properties; +using Ringtoets.GrassCoverErosionOutwards.Data; +using Ringtoets.GrassCoverErosionOutwards.Forms.PresentationObjects; +using Ringtoets.GrassCoverErosionOutwards.Plugin; + +namespace Ringtoets.GrassCoverErosionOutwards.Forms.Test.TreeNodeInfos +{ + [TestFixture] + public class HydraulicBoundariesGroupContextTreeNodeInfoTest + { + private MockRepository mocks; + private GrassCoverErosionOutwardsPlugin plugin; + private TreeNodeInfo info; + + [SetUp] + public void SetUp() + { + mocks = new MockRepository(); + plugin = new GrassCoverErosionOutwardsPlugin(); + info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(HydraulicBoundariesGroupContext)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + mocks.VerifyAll(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Assert + Assert.AreEqual(typeof(HydraulicBoundariesGroupContext), 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); + } + + [Test] + public void Text_Always_ReturnName() + { + // Setup + var assessmentSectionMock = mocks.StrictMock(); + mocks.ReplayAll(); + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + var context = new HydraulicBoundariesGroupContext(assessmentSectionMock, failureMechanism.HydraulicBoundariesCalculationGroup); + + // Call + string nodeText = info.Text(context); + + // Assert + Assert.AreEqual("Hydraulische randvoorwaarden", nodeText); + } + + [Test] + public void Image_Always_ReturnFailureMechanismIcon() + { + // Setup + var assessmentSectionMock = mocks.StrictMock(); + mocks.ReplayAll(); + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + var context = new HydraulicBoundariesGroupContext(assessmentSectionMock, failureMechanism.HydraulicBoundariesCalculationGroup); + + // Call + Image icon = info.Image(context); + + // Assert + TestHelper.AssertImagesAreEqual(Resources.GeneralFolderIcon, icon); + } + + [Test] + public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods() + { + // Setup + using (var treeViewControl = new TreeViewControl()) + { + var assessmentSectionMock = mocks.StrictMock(); + mocks.ReplayAll(); + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + var context = new HydraulicBoundariesGroupContext(assessmentSectionMock, failureMechanism.HydraulicBoundariesCalculationGroup); + + var menuBuilder = mocks.StrictMock(); + menuBuilder.Expect(mb => mb.AddExportItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.Build()).Return(null); + + var gui = mocks.StrictMock(); + gui.Expect(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilder); + + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + info.ContextMenuStrip(context, null, treeViewControl); + } + + // Assert + // Assert expectancies are called in TearDown() + } + } +} \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/GrassCoverErosionOutwardsPluginTest.cs =================================================================== diff -u -r4cacd866e5c6c2a5669a4c58f389b7f8e2c16374 -r1f58fe3574c5bad0bee42c6e02f679a718335ab2 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/GrassCoverErosionOutwardsPluginTest.cs (.../GrassCoverErosionOutwardsPluginTest.cs) (revision 4cacd866e5c6c2a5669a4c58f389b7f8e2c16374) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/GrassCoverErosionOutwardsPluginTest.cs (.../GrassCoverErosionOutwardsPluginTest.cs) (revision 1f58fe3574c5bad0bee42c6e02f679a718335ab2) @@ -80,7 +80,7 @@ Assert.AreEqual(3, treeNodeInfos.Length); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(GrassCoverErosionOutwardsFailureMechanismContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext))); - Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(GrassCoverErosionOutwardsHydraulicBoundariesCalculationGroupContext))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HydraulicBoundariesGroupContext))); } } @@ -99,7 +99,7 @@ } } - private static bool PropertyInfoExists (PropertyInfo[] treeNodeInfos) + private static bool PropertyInfoExists(PropertyInfo[] treeNodeInfos) { return treeNodeInfos.Any(tni => tni.DataType == typeof(TDataObject) && tni.PropertyObjectType == typeof(TPropertyObject)); }