Fisheye: Tag 15ba2de00ab1dd0df317409a272ef686ee688297 refers to a dead (removed) revision in file `Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PresentationObjects/HeightStructureContext.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PresentationObjects/HeightStructuresCollectionContext.cs =================================================================== diff -u --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PresentationObjects/HeightStructuresCollectionContext.cs (revision 0) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PresentationObjects/HeightStructuresCollectionContext.cs (revision 15ba2de00ab1dd0df317409a272ef686ee688297) @@ -0,0 +1,60 @@ +// 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.Base; +using Core.Common.Controls.PresentationObjects; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.HeightStructures.Data; + +namespace Ringtoets.HeightStructures.Forms.PresentationObjects +{ + /// + /// The presentation object for a collection of . + /// + public class HeightStructuresCollectionContext : ObservableWrappedObjectContextBase> + { + /// + /// Creates an instance of . + /// + /// The wrapped + /// containing . + /// The assessment section which the height structures + /// belong to. + /// Thrown when any of the input arguments + /// are null. + public HeightStructuresCollectionContext(ObservableList heightStructures, IAssessmentSection assessmentSection) + : base(heightStructures) + { + if (assessmentSection == null) + { + throw new ArgumentNullException("assessmentSection"); + } + + AssessmentSection = assessmentSection; + } + + /// + /// Gets the assessment section of this instance. + /// + public IAssessmentSection AssessmentSection { get; private set; } + } +} \ No newline at end of file Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Ringtoets.HeightStructures.Forms.csproj =================================================================== diff -u -rcd4c32e6c897ceff2c5ae483e3bfb586ab9b6598 -r15ba2de00ab1dd0df317409a272ef686ee688297 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Ringtoets.HeightStructures.Forms.csproj (.../Ringtoets.HeightStructures.Forms.csproj) (revision cd4c32e6c897ceff2c5ae483e3bfb586ab9b6598) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Ringtoets.HeightStructures.Forms.csproj (.../Ringtoets.HeightStructures.Forms.csproj) (revision 15ba2de00ab1dd0df317409a272ef686ee688297) @@ -41,7 +41,7 @@ Properties\GlobalAssembly.cs - + Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs =================================================================== diff -u -r423010168fe01b2373e9be55f047659911e670f5 -r15ba2de00ab1dd0df317409a272ef686ee688297 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs (.../HeightStructuresPlugin.cs) (revision 423010168fe01b2373e9be55f047659911e670f5) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs (.../HeightStructuresPlugin.cs) (revision 15ba2de00ab1dd0df317409a272ef686ee688297) @@ -64,7 +64,7 @@ public override IEnumerable GetImportInfos() { - yield return new ImportInfo() + yield return new ImportInfo { CreateFileImporter = (context, filePath) => new HeightStructuresImporter(context.WrappedData, context.AssessmentSection.ReferenceLine, @@ -140,7 +140,7 @@ .Build() }; - yield return new TreeNodeInfo + yield return new TreeNodeInfo { Text = context => RingtoetsCommonFormsResources.StructuresCollection_DisplayName, Image = context => RingtoetsCommonFormsResources.GeneralFolderIcon, @@ -253,7 +253,7 @@ { new FailureMechanismSectionsContext(failureMechanism, assessmentSection), new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, assessmentSection), - new HeightStructureContext(failureMechanism.HeightStructures, assessmentSection), + new HeightStructuresCollectionContext(failureMechanism.HeightStructures, assessmentSection), new CommentContext(failureMechanism) }; } Fisheye: Tag 15ba2de00ab1dd0df317409a272ef686ee688297 refers to a dead (removed) revision in file `Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PresentationObjects/HeightStructureContextTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PresentationObjects/HeightStructuresCollectionContextTest.cs =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PresentationObjects/HeightStructuresCollectionContextTest.cs (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PresentationObjects/HeightStructuresCollectionContextTest.cs (revision 15ba2de00ab1dd0df317409a272ef686ee688297) @@ -0,0 +1,70 @@ +// 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.Base; +using Core.Common.Controls.PresentationObjects; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.HeightStructures.Data; +using Ringtoets.HeightStructures.Forms.PresentationObjects; + +namespace Ringtoets.HeightStructures.Forms.Test.PresentationObjects +{ + [TestFixture] + public class HeightStructuresCollectionContextTest + { + [Test] + public void ParameteredConstructor_ExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var assessmentSectionMock = mocks.Stub(); + mocks.ReplayAll(); + + var heightStructures = new ObservableList(); + + // Call + var context = new HeightStructuresCollectionContext(heightStructures, assessmentSectionMock); + + // Assert + Assert.IsInstanceOf>>(context); + Assert.AreSame(heightStructures, context.WrappedData); + Assert.AreSame(assessmentSectionMock, context.AssessmentSection); + mocks.VerifyAll(); + } + + [Test] + public void ParameteredConstructor_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Setup + var heightStructures = new ObservableList(); + + // Call + TestDelegate test = () => new HeightStructuresCollectionContext(heightStructures, null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + } +} \ No newline at end of file Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Ringtoets.HeightStructures.Forms.Test.csproj =================================================================== diff -u -r6e5f2280217d2ba8367c240bd44bcfe3a21cebc8 -r15ba2de00ab1dd0df317409a272ef686ee688297 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Ringtoets.HeightStructures.Forms.Test.csproj (.../Ringtoets.HeightStructures.Forms.Test.csproj) (revision 6e5f2280217d2ba8367c240bd44bcfe3a21cebc8) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Ringtoets.HeightStructures.Forms.Test.csproj (.../Ringtoets.HeightStructures.Forms.Test.csproj) (revision 15ba2de00ab1dd0df317409a272ef686ee688297) @@ -61,7 +61,7 @@ Properties\GlobalAssembly.cs - + @@ -71,7 +71,7 @@ - + Fisheye: Tag 15ba2de00ab1dd0df317409a272ef686ee688297 refers to a dead (removed) revision in file `Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructureContextTreeNodeInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresCollectionContextTreeNodeInfoTest.cs =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresCollectionContextTreeNodeInfoTest.cs (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresCollectionContextTreeNodeInfoTest.cs (revision 15ba2de00ab1dd0df317409a272ef686ee688297) @@ -0,0 +1,241 @@ +// 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.HeightStructures.Data; +using Ringtoets.HeightStructures.Forms.PresentationObjects; +using Ringtoets.HeightStructures.Plugin; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.HeightStructures.Forms.Test.TreeNodeInfos +{ + [TestFixture] + public class HeightStructuresCollectionContextTreeNodeInfoTest + { + private HeightStructuresPlugin plugin; + private TreeNodeInfo info; + + [SetUp] + public void SetUp() + { + plugin = new HeightStructuresPlugin(); + info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(HeightStructuresCollectionContext)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Assert + Assert.AreEqual(typeof(HeightStructuresCollectionContext), info.TagType); + Assert.IsNotNull(info.Text); + Assert.IsNotNull(info.Image); + Assert.IsNotNull(info.ForeColor); + Assert.IsNotNull(info.ChildNodeObjects); + Assert.IsNotNull(info.ContextMenuStrip); + 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_ReturnExpectedText() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var heightStructures = new ObservableList(); + + var heightStructureContext = new HeightStructuresCollectionContext(heightStructures, assessmentSection); + + // Call + string text = info.Text(heightStructureContext); + + // Assert + const string expectedText = "Kunstwerken"; + Assert.AreEqual(expectedText, text); + mocks.VerifyAll(); + } + + [Test] + public void Image_Always_ReturnExpectedImage() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var heightStructures = new ObservableList(); + + var heightStructureContext = new HeightStructuresCollectionContext(heightStructures, assessmentSection); + + // Call + Image image = info.Image(heightStructureContext); + + // Assert + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GeneralFolderIcon, image); + mocks.VerifyAll(); + } + + [Test] + public void ForeColor_CollectionHasElementsEmpty_ReturnControlText() + { + // Setup + var mocks = new MockRepository(); + var asssessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var heightStructures = new ObservableList + { + CreateHeightStructure() + }; + + // Precondition + CollectionAssert.IsNotEmpty(heightStructures); + + var context = new HeightStructuresCollectionContext(heightStructures, asssessmentSection); + + // Call + Color color = info.ForeColor(context); + + // Assert + Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), color); + mocks.VerifyAll(); + } + + [Test] + public void ChildNodeObjects_Always_ReturnDikeProfiles() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + HeightStructure heightStructure1 = CreateHeightStructure(); + HeightStructure heightStructure2 = CreateHeightStructure(); + var heightStructures = new ObservableList + { + heightStructure1, + heightStructure2 + }; + + var heightStructureContext = new HeightStructuresCollectionContext(heightStructures, assessmentSection); + + // Call + object[] children = info.ChildNodeObjects(heightStructureContext); + + // Assert + CollectionAssert.AreEqual(heightStructures, children); + mocks.VerifyAll(); + } + + [Test] + public void ForeColor_CollectionIsEmpty_ReturnGrayText() + { + // Setup + var mocks = new MockRepository(); + var asssessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var heightStructures = new ObservableList(); + + // Precondition + CollectionAssert.IsEmpty(heightStructures); + + var context = new HeightStructuresCollectionContext(heightStructures, asssessmentSection); + + // Call + Color color = info.ForeColor(context); + + // Assert + Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), color); + mocks.VerifyAll(); + } + + [Test] + public void ContextMenuStrip_Always_CallsBuilder() + { + // Setup + var mocks = new MockRepository(); + var menuBuilderMock = mocks.StrictMock(); + menuBuilderMock.Expect(mb => mb.AddImportItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.Build()).Return(null); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocks.Stub(); + gui.Stub(g => g.Get(null, treeViewControl)).Return(menuBuilderMock); + + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + info.ContextMenuStrip(null, null, treeViewControl); + } + // Assert + mocks.VerifyAll(); + } + + private static HeightStructure CreateHeightStructure() + { + var heightStructure = new HeightStructure("aName", "anId", new Point2D(1.22, 2.333), + 0.12345, + 234.567, 0.23456, + 345.678, 0.34567, + 456.789, 0.45678, + 567.890, 0.56789, + 0.67890, + 112.223, 0.11222, + 225.336, 0.22533); + return heightStructure; + } + } +} \ No newline at end of file Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -rcd4c32e6c897ceff2c5ae483e3bfb586ab9b6598 -r15ba2de00ab1dd0df317409a272ef686ee688297 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision cd4c32e6c897ceff2c5ae483e3bfb586ab9b6598) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision 15ba2de00ab1dd0df317409a272ef686ee688297) @@ -126,7 +126,7 @@ Assert.AreSame(failureMechanism.ForeshoreProfiles, profilesContext.WrappedData); Assert.AreSame(assessmentSectionMock, profilesContext.ParentAssessmentSection); - var heightStructureContext = (HeightStructureContext) inputsFolder.Contents[2]; + var heightStructureContext = (HeightStructuresCollectionContext) inputsFolder.Contents[2]; Assert.AreSame(failureMechanism.HeightStructures, heightStructureContext.WrappedData); Assert.AreSame(assessmentSectionMock, heightStructureContext.AssessmentSection); Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/HeightStructuresPluginTest.cs =================================================================== diff -u -r2973c5f790a5131e427bd5f73e2a620044199639 -r15ba2de00ab1dd0df317409a272ef686ee688297 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/HeightStructuresPluginTest.cs (.../HeightStructuresPluginTest.cs) (revision 2973c5f790a5131e427bd5f73e2a620044199639) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/HeightStructuresPluginTest.cs (.../HeightStructuresPluginTest.cs) (revision 15ba2de00ab1dd0df317409a272ef686ee688297) @@ -102,7 +102,7 @@ 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(HeightStructureContext))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HeightStructuresCollectionContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(ProbabilityAssessmentOutput))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(EmptyProbabilityAssessmentOutput))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext))); @@ -155,7 +155,7 @@ // Assert Assert.AreEqual(1, importInfos.Length); - Assert.AreEqual(1, importInfos.Count(i => i.DataType == typeof(HeightStructureContext))); + Assert.AreEqual(1, importInfos.Count(i => i.DataType == typeof(HeightStructuresCollectionContext))); } mocks.VerifyAll(); } @@ -171,7 +171,7 @@ // Assert Assert.AreEqual(1, importInfos.Length); - Assert.IsTrue(importInfos.Any(i => i.DataType == typeof(HeightStructureContext))); + Assert.IsTrue(importInfos.Any(i => i.DataType == typeof(HeightStructuresCollectionContext))); } } } Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/ImportInfos/HeightStructureContextImportInfoTest.cs =================================================================== diff -u -r423010168fe01b2373e9be55f047659911e670f5 -r15ba2de00ab1dd0df317409a272ef686ee688297 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/ImportInfos/HeightStructureContextImportInfoTest.cs (.../HeightStructureContextImportInfoTest.cs) (revision 423010168fe01b2373e9be55f047659911e670f5) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/ImportInfos/HeightStructureContextImportInfoTest.cs (.../HeightStructureContextImportInfoTest.cs) (revision 15ba2de00ab1dd0df317409a272ef686ee688297) @@ -50,7 +50,7 @@ var list = new ObservableList(); - var importTarget = new HeightStructureContext(list, assessmentSection); + var importTarget = new HeightStructuresCollectionContext(list, assessmentSection); using (var plugin = new HeightStructuresPlugin()) { @@ -140,7 +140,7 @@ var list = new ObservableList(); - var context = new HeightStructureContext(list, assessmentSection); + var context = new HeightStructuresCollectionContext(list, assessmentSection); using (var plugin = new HeightStructuresPlugin()) { @@ -166,7 +166,7 @@ var list = new ObservableList(); - var context = new HeightStructureContext(list, assessmentSection); + var context = new HeightStructuresCollectionContext(list, assessmentSection); using (var plugin = new HeightStructuresPlugin()) { @@ -183,7 +183,7 @@ private static ImportInfo GetImportInfo(HeightStructuresPlugin plugin) { - return plugin.GetImportInfos().First(ii => ii.DataType == typeof(HeightStructureContext)); + return plugin.GetImportInfos().First(ii => ii.DataType == typeof(HeightStructuresCollectionContext)); } } } \ No newline at end of file