Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj =================================================================== diff -u -r248229db928c9e5556be704ed274226f80b4ef19 -r8d97f1f5da3f6e6954160d0e0076ce04349ed738 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 248229db928c9e5556be704ed274226f80b4ef19) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 8d97f1f5da3f6e6954160d0e0076ce04349ed738) @@ -99,7 +99,8 @@ - + + Fisheye: Tag 8d97f1f5da3f6e6954160d0e0076ce04349ed738 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/ForeshoreProfileContextTreeNodeInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/ForeshoreProfilesContextTreeNodeInfoTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/ForeshoreProfilesContextTreeNodeInfoTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/ForeshoreProfilesContextTreeNodeInfoTest.cs (revision 8d97f1f5da3f6e6954160d0e0076ce04349ed738) @@ -0,0 +1,208 @@ +// 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.Base; +using Core.Common.Base.Geometry; +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.Data.DikeProfiles; +using Ringtoets.Common.Forms.PresentationObjects; +using Ringtoets.Integration.Plugin; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.Integration.Forms.Test.TreeNodeInfos +{ + [TestFixture] + public class ForeshoreProfilesContextTreeNodeInfoTest + { + private RingtoetsPlugin plugin; + private TreeNodeInfo info; + + [SetUp] + public void SetUp() + { + plugin = new RingtoetsPlugin(); + info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(ForeshoreProfilesContext)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + info = null; + } + + [Test] + public void Initialized_ExpectedValues() + { + // Assert + Assert.IsNull(info.CanCheck); + Assert.IsNull(info.CanDrag); + Assert.IsNull(info.CanDrop); + Assert.IsNull(info.CanInsert); + Assert.IsNull(info.CanRemove); + Assert.IsNull(info.CanRename); + Assert.IsNull(info.EnsureVisibleOnCreate); + Assert.IsNull(info.IsChecked); + Assert.IsNull(info.OnDrop); + Assert.IsNull(info.OnNodeChecked); + Assert.IsNull(info.OnNodeRemoved); + Assert.IsNull(info.OnNodeRenamed); + } + + [Test] + public void Text_Always_ReturnText() + { + // Call + string text = info.Text(null); + + // Assert + Assert.AreEqual("Voorlandprofielen", text); + } + + [Test] + public void Image_Always_ReturnFolderIcon() + { + // Call + Image icon = info.Image(null); + + // Assert + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GeneralFolderIcon, icon); + } + + [Test] + public void ForeColor_CollectionIsEmpty_ReturnGrayText() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var emptyCollection = new ObservableList(); + var context = new ForeshoreProfilesContext(emptyCollection, assessmentSection); + + // Call + Color color = info.ForeColor(context); + + // Assert + Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), color); + mocks.ReplayAll(); + } + + [Test] + public void ForeColor_CollectionHasElements_ReturnControlText() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var emptyCollection = new ObservableList + { + new ForeshoreProfile(new Point2D(0, 0), new Point2D[0], null, new ForeshoreProfile.ConstructionProperties()) + }; + var context = new ForeshoreProfilesContext(emptyCollection, assessmentSection); + + // Call + Color color = info.ForeColor(context); + + // Assert + Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), color); + mocks.ReplayAll(); + } + + [Test] + public void ChildNodeObjects_Always_ReturnChildrenOfCollection() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var profile1 = new ForeshoreProfile(new Point2D(0, 0), new Point2D[0], null, new ForeshoreProfile.ConstructionProperties()); + var profile2 = new ForeshoreProfile(new Point2D(1, 1), new Point2D[0], null, new ForeshoreProfile.ConstructionProperties()); + var profile3 = new ForeshoreProfile(new Point2D(2, 2), new Point2D[0], null, new ForeshoreProfile.ConstructionProperties()); + var emptyCollection = new ObservableList + { + profile1, + profile2, + profile3, + }; + var context = new ForeshoreProfilesContext(emptyCollection, assessmentSection); + + // Call + object[] children = info.ChildNodeObjects(context); + + // Assert + var expectedChildren = new[] + { + profile1, + profile2, + profile3 + }; + CollectionAssert.AreEqual(expectedChildren, children); + mocks.ReplayAll(); + } + + [Test] + public void ContextMenuStrip_Always_ReturnContextMenuStrip() + { + // Setup + var mocks = new MockRepository(); + using (var treeViewControl = new TreeViewControl()) + { + var assessmentSection = mocks.Stub(); + + var emptyCollection = new ObservableList(); + var context = new ForeshoreProfilesContext(emptyCollection, assessmentSection); + + var contextMenuBuilder = mocks.Stub(); + contextMenuBuilder.Expect(b => b.AddImportItem()).Return(contextMenuBuilder); + contextMenuBuilder.Expect(b => b.AddSeparator()).Return(contextMenuBuilder); + contextMenuBuilder.Expect(b => b.AddCollapseAllItem()).Return(contextMenuBuilder); + contextMenuBuilder.Expect(b => b.AddExpandAllItem()).Return(contextMenuBuilder); + contextMenuBuilder.Expect(b => b.Build()).Return(null); + + var gui = mocks.Stub(); + gui.Stub(g => g.Get(context, treeViewControl)).Return(contextMenuBuilder); + gui.Stub(g => g.ProjectOpened += null).IgnoreArguments(); + gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + info.ContextMenuStrip(context, null, treeViewControl); + + // Assert + plugin.Dispose(); + mocks.VerifyAll(); + } + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/ForeshoreTreeNodeInfoTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/ForeshoreTreeNodeInfoTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/ForeshoreTreeNodeInfoTest.cs (revision 8d97f1f5da3f6e6954160d0e0076ce04349ed738) @@ -0,0 +1,156 @@ +// 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.Collections.Generic; +using System.Drawing; +using System.Linq; +using Core.Common.Base.Geometry; +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.DikeProfiles; +using Ringtoets.Integration.Plugin; +using Ringtoets.Integration.Plugin.Properties; + +namespace Ringtoets.Integration.Forms.Test.TreeNodeInfos +{ + [TestFixture] + public class ForeshoreTreeNodeInfoTest + { + private RingtoetsPlugin plugin; + private TreeNodeInfo info; + + [SetUp] + public void SetUp() + { + plugin = new RingtoetsPlugin(); + info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(ForeshoreProfile)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Assert + Assert.AreEqual(typeof(ForeshoreProfile), 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_ReturnForeshoreProfileName() + { + // Setup + const string profileName = "Random profile name"; + + var foreshoreGeometry = new List + { + new Point2D(2.2, 3.3) + }; + + var nonDefaultBreakWaterType = BreakWaterType.Wall; + var nonDefaultBreakWaterHeight = 5.5; + var breakWater = new BreakWater(nonDefaultBreakWaterType, nonDefaultBreakWaterHeight); + + double orientation = 96; + var foreshoreProfile = new ForeshoreProfile(new Point2D(0, 0), + foreshoreGeometry.ToArray(), + breakWater, + new ForeshoreProfile.ConstructionProperties + { + Orientation = orientation, + Name = profileName + }); + + // Call + string text = info.Text(foreshoreProfile); + + // Assert + Assert.AreEqual(profileName, text); + } + + [Test] + public void Image_Always_ReturnExpectedImage() + { + // Call + Image image = info.Image(null); + + // Assert + TestHelper.AssertImagesAreEqual(Resources.Foreshore, image); + } + + [Test] + public void ContextMenuStrip_Always_CallsBuilder() + { + // Setup + var mocks = new MockRepository(); + var menuBuilderMock = mocks.StrictMock(); + menuBuilderMock.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.Build()).Return(null); + + var gui = mocks.Stub(); + gui.Stub(g => g.ProjectOpened += null).IgnoreArguments(); + gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); + + using (var treeViewControl = new TreeViewControl()) + { + gui.Stub(g => g.Get(null, treeViewControl)).Return(menuBuilderMock); + + mocks.ReplayAll(); + + using (var p = new RingtoetsPlugin()) + { + p.Gui = gui; + var i = p.GetTreeNodeInfos().First(tni => tni.TagType == typeof(ForeshoreProfile)); + + // Call + i.ContextMenuStrip(null, null, treeViewControl); + } + } + + // Assert + mocks.VerifyAll(); + } + } +} Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs =================================================================== diff -u -rd2b9feaf8aceaa9a96d0e6e19fd6fbbee8987ca6 -r8d97f1f5da3f6e6954160d0e0076ce04349ed738 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs (.../RingtoetsPluginTest.cs) (revision d2b9feaf8aceaa9a96d0e6e19fd6fbbee8987ca6) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs (.../RingtoetsPluginTest.cs) (revision 8d97f1f5da3f6e6954160d0e0076ce04349ed738) @@ -46,7 +46,6 @@ using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Forms.PropertyClasses; using Ringtoets.Common.Forms.Views; -using Ringtoets.Common.Service.Properties; using Ringtoets.GrassCoverErosionInwards.Forms.PresentationObjects; using Ringtoets.HydraRing.Data; using Ringtoets.Integration.Data; @@ -57,6 +56,7 @@ using Ringtoets.Integration.Forms.Views.SectionResultViews; using RingtoetsFormsResources = Ringtoets.Integration.Forms.Properties.Resources; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; +using RingtoetsCommonServiceResources = Ringtoets.Common.Service.Properties.Resources; namespace Ringtoets.Integration.Plugin.Test { @@ -179,7 +179,7 @@ // Then var fileMissingMessage = string.Format("Fout bij het lezen van bestand '{0}': Het bestand bestaat niet.", nonExistingFileExistingFile); string message = string.Format( - Resources.Hydraulic_boundary_database_connection_failed_0_, + RingtoetsCommonServiceResources.Hydraulic_boundary_database_connection_failed_0_, fileMissingMessage); TestHelper.AssertLogMessageWithLevelIsGenerated(action, Tuple.Create(message, LogLevelConstant.Warn)); }