Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/EmptyStabilityStoneCoverOutputTreeNodeInfoTest.cs =================================================================== diff -u -r0d98073e4ba2bdc6b69b7f875508488d1fa0148a -r0d7efa62d16c64a925c63172e4d1bf1a4e0bf94f --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/EmptyStabilityStoneCoverOutputTreeNodeInfoTest.cs (.../EmptyStabilityStoneCoverOutputTreeNodeInfoTest.cs) (revision 0d98073e4ba2bdc6b69b7f875508488d1fa0148a) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/EmptyStabilityStoneCoverOutputTreeNodeInfoTest.cs (.../EmptyStabilityStoneCoverOutputTreeNodeInfoTest.cs) (revision 0d7efa62d16c64a925c63172e4d1bf1a4e0bf94f) @@ -37,91 +37,89 @@ public class EmptyStabilityStoneCoverOutputTreeNodeInfoTest { private MockRepository mocks; - private StabilityStoneCoverPlugin plugin; - private TreeNodeInfo info; [SetUp] public void SetUp() { mocks = new MockRepository(); - plugin = new StabilityStoneCoverPlugin(); - info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(EmptyStabilityStoneCoverOutput)); } - [TearDown] - public void TearDown() - { - plugin.Dispose(); - mocks.VerifyAll(); - } - [Test] public void Initialized_Always_ExpectedPropertiesSet() { // Setup - mocks.ReplayAll(); + using (var plugin = new StabilityStoneCoverPlugin()) + { + var info = GetInfo(plugin); - // Assert - Assert.AreEqual(typeof(EmptyStabilityStoneCoverOutput), 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); - Assert.IsNull(info.ChildNodeObjects); + // Assert + 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); + Assert.IsNull(info.ChildNodeObjects); + } } [Test] public void Text_Always_ReturnName() { // Setup - mocks.ReplayAll(); - var output = new EmptyStabilityStoneCoverOutput(); - // Call - string nodeText = info.Text(output); + using (var plugin = new StabilityStoneCoverPlugin()) + { + var info = GetInfo(plugin); - // Assert - Assert.AreEqual("Resultaat", nodeText); + // Call + string nodeText = info.Text(output); + + // Assert + Assert.AreEqual("Resultaat", nodeText); + } } [Test] public void ForeColor_Always_ReturnGrayText() { // Setup - mocks.ReplayAll(); - var output = new EmptyStabilityStoneCoverOutput(); + + using (var plugin = new StabilityStoneCoverPlugin()) + { + var info = GetInfo(plugin); - // Call - Color color = info.ForeColor(output); + // Call + Color color = info.ForeColor(output); - // Assert - Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), color); + // Assert + Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), color); + } } [Test] public void Image_Always_ReturnOutputIcon() { // Setup - mocks.ReplayAll(); - var output = new EmptyStabilityStoneCoverOutput(); - // Call - Image icon = info.Image(output); + using (var plugin = new StabilityStoneCoverPlugin()) + { + var info = GetInfo(plugin); + // Call + Image icon = info.Image(output); - // Assert - TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GeneralOutputIcon, icon); + // Assert + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GeneralOutputIcon, icon); + } } [Test] @@ -141,14 +139,23 @@ mocks.ReplayAll(); - plugin.Gui = gui; + using (var plugin = new StabilityStoneCoverPlugin()) + { + var info = GetInfo(plugin); + plugin.Gui = gui; - // Call - info.ContextMenuStrip(output, null, treeViewControl); + // Call + info.ContextMenuStrip(output, null, treeViewControl); + } } // Assert // Assert expectancies are called in TearDown() } + + private TreeNodeInfo GetInfo(StabilityStoneCoverPlugin plugin) + { + return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(EmptyStabilityStoneCoverOutput)); + } } } \ No newline at end of file Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationInputContextTreeNodeInfoTest.cs =================================================================== diff -u -r0d98073e4ba2bdc6b69b7f875508488d1fa0148a -r0d7efa62d16c64a925c63172e4d1bf1a4e0bf94f --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationInputContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationInputContextTreeNodeInfoTest.cs) (revision 0d98073e4ba2bdc6b69b7f875508488d1fa0148a) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationInputContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationInputContextTreeNodeInfoTest.cs) (revision 0d7efa62d16c64a925c63172e4d1bf1a4e0bf94f) @@ -36,50 +36,41 @@ namespace Ringtoets.StabilityStoneCover.Forms.Test.TreeNodeInfos { + [TestFixture] public class StabilityStoneCoverWaveConditionsCalculationInputContextTreeNodeInfoTest { private MockRepository mocks; - private StabilityStoneCoverPlugin plugin; - private TreeNodeInfo info; [SetUp] public void SetUp() { mocks = new MockRepository(); - plugin = new StabilityStoneCoverPlugin(); - info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(StabilityStoneCoverWaveConditionsCalculationInputContext)); } - [TearDown] - public void TearDown() - { - plugin.Dispose(); - mocks.VerifyAll(); - } - [Test] public void Initialized_Always_ExpectedPropertiesSet() { // Setup - mocks.ReplayAll(); + using (var plugin = new StabilityStoneCoverPlugin()) + { + var info = GetInfo(plugin); - // Assert - Assert.AreEqual(typeof(StabilityStoneCoverWaveConditionsCalculationInputContext), 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); - Assert.IsNull(info.ChildNodeObjects); - Assert.IsNull(info.ForeColor); + // Assert + 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); + Assert.IsNull(info.ChildNodeObjects); + Assert.IsNull(info.ForeColor); + } } [Test] @@ -95,11 +86,16 @@ failureMechanism, assessmentSection); - // Call - string nodeText = info.Text(context); + using (var plugin = new StabilityStoneCoverPlugin()) + { + var info = GetInfo(plugin); - // Assert - Assert.AreEqual("Invoer", nodeText); + // Call + string nodeText = info.Text(context); + + // Assert + Assert.AreEqual("Invoer", nodeText); + } } [Test] @@ -114,12 +110,15 @@ var context = new StabilityStoneCoverWaveConditionsCalculationInputContext(input, failureMechanism, assessmentSection); + using (var plugin = new StabilityStoneCoverPlugin()) + { + var info = GetInfo(plugin); + // Call + Image icon = info.Image(context); - // Call - Image icon = info.Image(context); - - // Assert - TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, icon); + // Assert + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, icon); + } } [Test] @@ -145,14 +144,23 @@ mocks.ReplayAll(); - plugin.Gui = gui; + using (var plugin = new StabilityStoneCoverPlugin()) + { + var info = GetInfo(plugin); + plugin.Gui = gui; - // Call - info.ContextMenuStrip(context, null, treeViewControl); + // Call + info.ContextMenuStrip(context, null, treeViewControl); + } } // Assert // Assert expectancies are called in TearDown() } + + private TreeNodeInfo GetInfo(StabilityStoneCoverPlugin plugin) + { + return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(StabilityStoneCoverWaveConditionsCalculationInputContext)); + } } } \ No newline at end of file Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsOutputTreeNodeInfoTest.cs =================================================================== diff -u -r2336e45e063aee566b1fa028efed72d531cdf5ee -r0d7efa62d16c64a925c63172e4d1bf1a4e0bf94f --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsOutputTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsOutputTreeNodeInfoTest.cs) (revision 2336e45e063aee566b1fa028efed72d531cdf5ee) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsOutputTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsOutputTreeNodeInfoTest.cs) (revision 0d7efa62d16c64a925c63172e4d1bf1a4e0bf94f) @@ -38,77 +38,73 @@ public class StabilityStoneCoverWaveConditionsOutputTreeNodeInfoTest { private MockRepository mocks; - private StabilityStoneCoverPlugin plugin; - private TreeNodeInfo info; [SetUp] public void SetUp() { mocks = new MockRepository(); - plugin = new StabilityStoneCoverPlugin(); - info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(StabilityStoneCoverWaveConditionsOutput)); } - [TearDown] - public void TearDown() - { - plugin.Dispose(); - mocks.VerifyAll(); - } - [Test] public void Initialized_Always_ExpectedPropertiesSet() { // Setup - mocks.ReplayAll(); + using (var plugin = new StabilityStoneCoverPlugin()) + { + var info = GetInfo(plugin); - // Assert - Assert.AreEqual(typeof(StabilityStoneCoverWaveConditionsOutput), 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); - Assert.IsNull(info.ChildNodeObjects); - Assert.IsNull(info.ForeColor); + // Assert + 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); + Assert.IsNull(info.ChildNodeObjects); + Assert.IsNull(info.ForeColor); + } } [Test] public void Text_Always_ReturnName() { // Setup - mocks.ReplayAll(); - var output = new StabilityStoneCoverWaveConditionsOutput(Enumerable.Empty(), Enumerable.Empty()); - // Call - string nodeText = info.Text(output); + using (var plugin = new StabilityStoneCoverPlugin()) + { + var info = GetInfo(plugin); - // Assert - Assert.AreEqual("Resultaat", nodeText); + // Call + string nodeText = info.Text(output); + + // Assert + Assert.AreEqual("Resultaat", nodeText); + } } [Test] public void Image_Always_ReturnOutputIcon() { // Setup - mocks.ReplayAll(); - var output = new StabilityStoneCoverWaveConditionsOutput(Enumerable.Empty(), Enumerable.Empty()); - // Call - Image icon = info.Image(output); + using (var plugin = new StabilityStoneCoverPlugin()) + { + var info = GetInfo(plugin); - // Assert - TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GeneralOutputIcon, icon); + // Call + Image icon = info.Image(output); + + // Assert + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GeneralOutputIcon, icon); + } } [Test] @@ -128,14 +124,23 @@ mocks.ReplayAll(); - plugin.Gui = gui; + using (var plugin = new StabilityStoneCoverPlugin()) + { + var info = GetInfo(plugin); + plugin.Gui = gui; - // Call - info.ContextMenuStrip(output, null, treeViewControl); + // Call + info.ContextMenuStrip(output, null, treeViewControl); + } } // Assert // Assert expectancies are called in TearDown() } + + private TreeNodeInfo GetInfo(StabilityStoneCoverPlugin plugin) + { + return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(StabilityStoneCoverWaveConditionsOutput)); + } } } \ No newline at end of file Index: Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Plugin/WaveImpactAsphaltCoverPlugin.cs =================================================================== diff -u -r11f0867b39150ae5fac83dc178a89fee46d27611 -r0d7efa62d16c64a925c63172e4d1bf1a4e0bf94f --- Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Plugin/WaveImpactAsphaltCoverPlugin.cs (.../WaveImpactAsphaltCoverPlugin.cs) (revision 11f0867b39150ae5fac83dc178a89fee46d27611) +++ Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Plugin/WaveImpactAsphaltCoverPlugin.cs (.../WaveImpactAsphaltCoverPlugin.cs) (revision 0d7efa62d16c64a925c63172e4d1bf1a4e0bf94f) @@ -21,6 +21,7 @@ using System.Collections; using System.Collections.Generic; +using System.Drawing; using System.IO; using System.Linq; using System.Windows.Forms; @@ -31,6 +32,7 @@ using Ringtoets.Common.Data; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.Forms.Helpers; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Forms.TreeNodeInfos; using Ringtoets.HydraRing.Data; @@ -97,6 +99,34 @@ WaveConditionsCalculationContextChildNodeObjects, WaveConditionsCalculationContextContextMenuStrip, WaveConditionsCalculationContextOnNodeRemoved); + + yield return new TreeNodeInfo + { + Text = context => RingtoetsCommonFormsResources.Calculation_Input, + Image = context => RingtoetsCommonFormsResources.GenericInputOutputIcon, + ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl) + .AddPropertiesItem() + .Build() + }; + + yield return new TreeNodeInfo + { + Text = emptyPipingOutput => RingtoetsCommonFormsResources.CalculationOutput_DisplayName, + Image = emptyPipingOutput => RingtoetsCommonFormsResources.GeneralOutputIcon, + ForeColor = emptyPipingOutput => Color.FromKnownColor(KnownColor.GrayText), + ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl) + .AddPropertiesItem() + .Build() + }; + + yield return new TreeNodeInfo + { + Text = emptyPipingOutput => RingtoetsCommonFormsResources.CalculationOutput_DisplayName, + Image = emptyPipingOutput => RingtoetsCommonFormsResources.GeneralOutputIcon, + ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl) + .AddPropertiesItem() + .Build() + }; } #region ViewInfos @@ -234,7 +264,8 @@ return childNodeObjects.ToArray(); } - private ContextMenuStrip WaveConditionsCalculationGroupContextContextMenuStrip(WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext nodeData, object parentData, TreeViewControl treeViewControl) + private ContextMenuStrip WaveConditionsCalculationGroupContextContextMenuStrip(WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext nodeData, + object parentData, TreeViewControl treeViewControl) { var group = nodeData.WrappedData; var builder = new RingtoetsContextMenuBuilder(Gui.Get(nodeData, treeViewControl)); @@ -250,9 +281,7 @@ builder.AddExportItem() .AddSeparator() .AddCreateCalculationGroupItem(group) - // TODO Restore in WTI-819 - //.AddCreateCalculationItem(nodeData, AddWaveConditionsCalculation) - ; + .AddCreateCalculationItem(nodeData, AddWaveConditionsCalculation); if (!isNestedGroup) { @@ -298,9 +327,9 @@ private string ValidateAllDataAvailableAndGetErrorMessage(IAssessmentSection assessmentSection, WaveImpactAsphaltCoverFailureMechanism failureMechanism) { - // TODO WTI-856 + // TODO WTI-856 Contextmenu item is now set to Enabled == false by returning !NullOrEmpty from this method. - return null; + return "Er is geen vakindeling geïmporteerd."; } private StrictContextMenuItem CreateGenerateWaveConditionsCalculationsItem(WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext nodeData) @@ -327,15 +356,14 @@ private void AddWaveConditionsCalculation(WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext nodeData) { - // TODO WTI-819, also add ViewInfo -// var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation -// { -// Name = NamingHelper.GetUniqueName(nodeData.WrappedData.Children, -// WaveImpactAsphaltCoverDataResources.WaveImpactAsphaltCoverWaveConditionsCalculation_DefaultName, -// c => c.Name) -// }; -// nodeData.WrappedData.Children.Add(calculation); -// nodeData.WrappedData.NotifyObservers(); + var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation + { + Name = NamingHelper.GetUniqueName(nodeData.WrappedData.Children, + WaveImpactAsphaltCoverDataResources.WaveImpactAsphaltCoverWaveConditionsCalculation_DefaultName, + c => c.Name) + }; + nodeData.WrappedData.Children.Add(calculation); + nodeData.WrappedData.NotifyObservers(); } private void ValidateAll(IEnumerable calculations, GeneralWaveConditionsInput generalInput, int norm, HydraulicBoundaryDatabase database) @@ -404,13 +432,16 @@ return childNodes.ToArray(); } - private ContextMenuStrip WaveConditionsCalculationContextContextMenuStrip(WaveImpactAsphaltCoverWaveConditionsCalculationContext nodeData, object parentData, TreeViewControl treeViewControl) + private ContextMenuStrip WaveConditionsCalculationContextContextMenuStrip(WaveImpactAsphaltCoverWaveConditionsCalculationContext nodeData, + object parentData, TreeViewControl treeViewControl) { var builder = new RingtoetsContextMenuBuilder(Gui.Get(nodeData, treeViewControl)); WaveImpactAsphaltCoverWaveConditionsCalculation calculation = nodeData.WrappedData; - return builder.AddValidateCalculationItem(nodeData, + return builder.AddExportItem() + .AddSeparator() + .AddValidateCalculationItem(nodeData, c => ValidateAll( new[] { @@ -422,7 +453,6 @@ ValidateAllDataAvailableAndGetErrorMessageForCalculation) .AddPerformCalculationItem(calculation, nodeData, PerformCalculation) .AddClearCalculationOutputItem(calculation) - .AddExportItem() .AddSeparator() .AddRenameItem() .AddDeleteItem() Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/Ringtoets.WaveImpactAsphaltCover.Forms.Test.csproj =================================================================== diff -u -r8e97f37e10d4445dfa2aeda2d321f347b5a59921 -r0d7efa62d16c64a925c63172e4d1bf1a4e0bf94f --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/Ringtoets.WaveImpactAsphaltCover.Forms.Test.csproj (.../Ringtoets.WaveImpactAsphaltCover.Forms.Test.csproj) (revision 8e97f37e10d4445dfa2aeda2d321f347b5a59921) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/Ringtoets.WaveImpactAsphaltCover.Forms.Test.csproj (.../Ringtoets.WaveImpactAsphaltCover.Forms.Test.csproj) (revision 0d7efa62d16c64a925c63172e4d1bf1a4e0bf94f) @@ -62,6 +62,10 @@ + + + + Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/TreeNodeInfos/EmptyWaveImpactAsphaltCoverOutputTreeNodeInfoTest.cs =================================================================== diff -u --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/TreeNodeInfos/EmptyWaveImpactAsphaltCoverOutputTreeNodeInfoTest.cs (revision 0) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/TreeNodeInfos/EmptyWaveImpactAsphaltCoverOutputTreeNodeInfoTest.cs (revision 0d7efa62d16c64a925c63172e4d1bf1a4e0bf94f) @@ -0,0 +1,161 @@ +// 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.WaveImpactAsphaltCover.Forms.PresentationObjects; +using Ringtoets.WaveImpactAsphaltCover.Plugin; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.WaveImpactAsphaltCover.Forms.Test.TreeNodeInfos +{ + [TestFixture] + public class EmptyWaveImpactAsphaltCoverOutputTreeNodeInfoTest + { + private MockRepository mocks; + + [SetUp] + public void SetUp() + { + mocks = new MockRepository(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Setup + using (var plugin = new WaveImpactAsphaltCoverPlugin()) + { + var info = GetInfo(plugin); + + // Assert + 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); + Assert.IsNull(info.ChildNodeObjects); + } + } + + [Test] + public void Text_Always_ReturnName() + { + // Setup + var output = new EmptyWaveImpactAsphaltCoverOutput(); + + using (var plugin = new WaveImpactAsphaltCoverPlugin()) + { + var info = GetInfo(plugin); + + // Call + string nodeText = info.Text(output); + + // Assert + Assert.AreEqual("Resultaat", nodeText); + } + } + + [Test] + public void ForeColor_Always_ReturnGrayText() + { + // Setup + var output = new EmptyWaveImpactAsphaltCoverOutput(); + + using (var plugin = new WaveImpactAsphaltCoverPlugin()) + { + var info = GetInfo(plugin); + + // Call + Color color = info.ForeColor(output); + + // Assert + Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), color); + } + } + + [Test] + public void Image_Always_ReturnOutputIcon() + { + // Setup + var output = new EmptyWaveImpactAsphaltCoverOutput(); + + using (var plugin = new WaveImpactAsphaltCoverPlugin()) + { + var info = GetInfo(plugin); + // Call + Image icon = info.Image(output); + + // Assert + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GeneralOutputIcon, icon); + } + } + + [Test] + public void ContextMenuStrip_FailureMechanismIsRelevant_CallsContextMenuBuilderMethods() + { + // Setup + using (var treeViewControl = new TreeViewControl()) + { + var output = new EmptyWaveImpactAsphaltCoverOutput(); + + var menuBuilder = mocks.StrictMock(); + menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.Build()).Return(null); + + var gui = mocks.StrictMock(); + gui.Expect(cmp => cmp.Get(output, treeViewControl)).Return(menuBuilder); + + mocks.ReplayAll(); + + using (var plugin = new WaveImpactAsphaltCoverPlugin()) + { + var info = GetInfo(plugin); + plugin.Gui = gui; + + // Call + info.ContextMenuStrip(output, null, treeViewControl); + } + } + + // Assert + // Assert expectancies are called in TearDown() + } + + private TreeNodeInfo GetInfo(WaveImpactAsphaltCoverPlugin plugin) + { + return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(EmptyWaveImpactAsphaltCoverOutput)); + } + } +} \ No newline at end of file Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs (revision 0) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs (revision 0d7efa62d16c64a925c63172e4d1bf1a4e0bf94f) @@ -0,0 +1,1027 @@ +// 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 System.Drawing; +using System.IO; +using System.Linq; +using System.Windows.Forms; +using Core.Common.Base; +using Core.Common.Base.Data; +using Core.Common.Base.Geometry; +using Core.Common.Controls.TreeView; +using Core.Common.Gui; +using Core.Common.Gui.Commands; +using Core.Common.Gui.ContextMenu; +using Core.Common.Gui.Forms.MainWindow; +using Core.Common.TestUtil; +using NUnit.Extensions.Forms; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Contribution; +using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Forms.PresentationObjects; +using Ringtoets.HydraRing.Calculation.TestUtil; +using Ringtoets.HydraRing.Data; +using Ringtoets.Revetment.Data; +using Ringtoets.Revetment.Service.TestUtil; +using Ringtoets.WaveImpactAsphaltCover.Data; +using Ringtoets.WaveImpactAsphaltCover.Forms.PresentationObjects; +using Ringtoets.WaveImpactAsphaltCover.Forms.Properties; +using Ringtoets.WaveImpactAsphaltCover.Plugin; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.WaveImpactAsphaltCover.Forms.Test.TreeNodeInfos +{ + [TestFixture] + public class WaveImpactAsphaltCoverWaveConditionsCalculationContextTreeNodeInfoTest : NUnitFormTest + { + //private const int validateMenuItemIndex = 2; + + private const int clearOutputMenuItemIndex = 4; + + private const int calculateMenuItemIndex = 3; + private MockRepository mocks; + private WaveImpactAsphaltCoverPlugin plugin; + private TreeNodeInfo info; + + [SetUp] + public void SetUp() + { + mocks = new MockRepository(); + plugin = new WaveImpactAsphaltCoverPlugin(); + info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(WaveImpactAsphaltCoverWaveConditionsCalculationContext)); + } + + [TearDown] + public override void TearDown() + { + plugin.Dispose(); + mocks.VerifyAll(); + base.TearDown(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Setup + mocks.ReplayAll(); + + // Assert + Assert.AreEqual(typeof(WaveImpactAsphaltCoverWaveConditionsCalculationContext), info.TagType); + + Assert.IsNull(info.ForeColor); + Assert.IsNull(info.CanCheck); + Assert.IsNull(info.IsChecked); + Assert.IsNull(info.OnNodeChecked); + Assert.IsNull(info.CanDrop); + Assert.IsNull(info.CanInsert); + Assert.IsNull(info.OnDrop); + } + + [Test] + public void Text_Always_ReturnCalculationName() + { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + const string name = "cool name"; + var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation + { + Name = name + }; + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var context = new WaveImpactAsphaltCoverWaveConditionsCalculationContext(calculation, + failureMechanism, + assessmentSection); + + // Call + string text = info.Text(context); + + // Assert + Assert.AreEqual(name, text); + } + + [Test] + public void Image_Always_ReturnCalculationIcon() + { + // Setup + mocks.ReplayAll(); + + // Call + Image icon = info.Image(null); + + // Assert + TestHelper.AssertImagesAreEqual(Resources.CalculationIcon, icon); + } + + [Test] + public void EnsureVisibleOnCreate_Always_ReturnTrue() + { + // Setup + mocks.ReplayAll(); + + // Call + bool shouldBeVisible = info.EnsureVisibleOnCreate(null, null); + + // Assert + Assert.IsTrue(shouldBeVisible); + } + + [Test] + public void ChildNodeObjects_CalculationWithoutOutput_ReturnChildrenWithEmptyOutput() + { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation + { + Output = null + }; + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var context = new WaveImpactAsphaltCoverWaveConditionsCalculationContext(calculation, + failureMechanism, + assessmentSection); + + // Call + object[] children = info.ChildNodeObjects(context); + + // Assert + Assert.AreEqual(3, children.Length); + + var commentsContext = (CommentContext) children[0]; + Assert.AreSame(calculation, commentsContext.WrappedData); + + var inputContext = (WaveImpactAsphaltCoverWaveConditionsCalculationInputContext) children[1]; + Assert.AreSame(calculation.InputParameters, inputContext.WrappedData); + Assert.AreSame(failureMechanism, inputContext.FailureMechanism); + Assert.AreSame(assessmentSection, inputContext.AssessmentSection); + + Assert.IsInstanceOf(children[2]); + } + + [Test] + public void ChildNodeObjects_CalculationWithOutput_ReturnChildrenWithOutput() + { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation + { + Output = new WaveImpactAsphaltCoverWaveConditionsOutput(Enumerable.Empty()) + }; + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var context = new WaveImpactAsphaltCoverWaveConditionsCalculationContext(calculation, + failureMechanism, + assessmentSection); + + // Call + object[] children = info.ChildNodeObjects(context); + + // Assert + Assert.AreEqual(3, children.Length); + + var commentsContext = (CommentContext) children[0]; + Assert.AreSame(calculation, commentsContext.WrappedData); + + var inputContext = (WaveImpactAsphaltCoverWaveConditionsCalculationInputContext) children[1]; + Assert.AreSame(calculation.InputParameters, inputContext.WrappedData); + Assert.AreSame(failureMechanism, inputContext.FailureMechanism); + Assert.AreSame(assessmentSection, inputContext.AssessmentSection); + + var output = (WaveImpactAsphaltCoverWaveConditionsOutput) children[2]; + Assert.AreSame(calculation.Output, output); + } + + [Test] + public void CanRename_Always_ReturnTrue() + { + // Setup + mocks.ReplayAll(); + + // Call + bool canRename = info.CanRename(null, null); + + // Assert + Assert.IsTrue(canRename); + } + + [Test] + public void OnNodeRenamed_ChangeNameOfCalculationAndNotifyObservers() + { + // Setup + var assessmentSection = mocks.Stub(); + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + mocks.ReplayAll(); + + var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation + { + Output = new WaveImpactAsphaltCoverWaveConditionsOutput(Enumerable.Empty()) + }; + calculation.Attach(observer); + + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var context = new WaveImpactAsphaltCoverWaveConditionsCalculationContext(calculation, + failureMechanism, + assessmentSection); + const string name = "the new name!"; + + // Call + info.OnNodeRenamed(context, name); + + // Assert + Assert.AreEqual(name, calculation.Name); + } + + [Test] + public void CanRemove_CalculationInParent_ReturnTrue() + { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation + { + Output = new WaveImpactAsphaltCoverWaveConditionsOutput(Enumerable.Empty()) + }; + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + failureMechanism.WaveConditionsCalculationGroup.Children.Add(calculation); + var context = new WaveImpactAsphaltCoverWaveConditionsCalculationContext(calculation, + failureMechanism, + assessmentSection); + + var parentContext = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, + failureMechanism, + assessmentSection); + + // Call + bool canRemoveCalculation = info.CanRemove(context, parentContext); + + // Assert + Assert.IsTrue(canRemoveCalculation); + } + + [Test] + public void CanRemove_CalculationNotInParent_ReturnTrue() + { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation + { + Output = new WaveImpactAsphaltCoverWaveConditionsOutput(Enumerable.Empty()) + }; + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var context = new WaveImpactAsphaltCoverWaveConditionsCalculationContext(calculation, + failureMechanism, + assessmentSection); + + var parentContext = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, + failureMechanism, + assessmentSection); + + // Call + bool canRemoveCalculation = info.CanRemove(context, parentContext); + + // Assert + Assert.IsFalse(canRemoveCalculation); + } + + [Test] + public void OnNodeRemoved_CalculationInParent_ReturnTrue() + { + // Setup + var assessmentSection = mocks.Stub(); + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + mocks.ReplayAll(); + + var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation + { + Output = new WaveImpactAsphaltCoverWaveConditionsOutput(Enumerable.Empty()) + }; + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + failureMechanism.WaveConditionsCalculationGroup.Children.Add(calculation); + failureMechanism.WaveConditionsCalculationGroup.Attach(observer); + var context = new WaveImpactAsphaltCoverWaveConditionsCalculationContext(calculation, + failureMechanism, + assessmentSection); + + var parentContext = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, + failureMechanism, + assessmentSection); + + // Call + info.OnNodeRemoved(context, parentContext); + + // Assert + CollectionAssert.DoesNotContain(failureMechanism.WaveConditionsCalculationGroup.Children, calculation); + } + + [Test] + public void CanDrag_Always_ReturnTrue() + { + // Setup + mocks.ReplayAll(); + + // Call + bool canDrag = info.CanDrag(null, null); + + // Assert + Assert.IsTrue(canDrag); + } + + [Test] + public void ContextMenuStrip_Always_CallsBuilder() + { + // Setup + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var assessmentSection = mocks.Stub(); + + var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation(); + var context = new WaveImpactAsphaltCoverWaveConditionsCalculationContext(calculation, + failureMechanism, + assessmentSection); + + var menuBuilderMock = mocks.StrictMock(); + menuBuilderMock.Expect(mb => mb.AddExportItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddRenameItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddDeleteItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock); + 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(g => g.Get(context, treeViewControl)).Return(menuBuilderMock); + + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + info.ContextMenuStrip(context, null, treeViewControl); + } + // Assert + // Assert expectancies are called in TearDown() + } + + // TODO WTI-856 + //[Test] + //public void GivenFailureMechanismWithoutSections_ThenValidationItemDisabled() + //{ + // // Given + // var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + // var assessmentSection = mocks.Stub(); + + // var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation + // { + // Name = "A" + // }; + // var context = new WaveImpactAsphaltCoverWaveConditionsCalculationContext(calculation, + // failureMechanism, + // assessmentSection); + + // using (var treeViewControl = new TreeViewControl()) + // { + // var appFeatureCommandHandler = mocks.Stub(); + // var importHandler = mocks.Stub(); + // var exportHandler = mocks.Stub(); + // var viewCommands = mocks.Stub(); + // var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, + // importHandler, + // exportHandler, + // viewCommands, + // context, + // treeViewControl); + + // var gui = mocks.Stub(); + // gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilderMock); + + // mocks.ReplayAll(); + + // plugin.Gui = gui; + + // using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) + // { + // // Then + // TestHelper.AssertContextMenuStripContainsItem(contextMenu, + // validateMenuItemIndex, + // "&Valideren", + // "Er is geen vakindeling geïmporteerd.", + // RingtoetsCommonFormsResources.ValidateIcon, + // false); + // } + // } + //} + + // TODO WTI-856 + //[Test] + //public void GivenAssessmentSectionWithoutHydroDatabase_ThenValidationItemDisabled() + //{ + // // Given + // var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + // failureMechanism.AddSection(new FailureMechanismSection("A", new[] + // { + // new Point2D(0, 0), + // new Point2D(1, 1) + // })); + // var assessmentSection = mocks.Stub(); + + // var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation + // { + // Name = "A" + // }; + // var context = new WaveImpactAsphaltCoverWaveConditionsCalculationContext(calculation, + // failureMechanism, + // assessmentSection); + + // using (var treeViewControl = new TreeViewControl()) + // { + // var appFeatureCommandHandler = mocks.Stub(); + // var importHandler = mocks.Stub(); + // var exportHandler = mocks.Stub(); + // var viewCommands = mocks.Stub(); + // var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, + // importHandler, + // exportHandler, + // viewCommands, + // context, + // treeViewControl); + + // var gui = mocks.Stub(); + // gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilderMock); + + // mocks.ReplayAll(); + + // plugin.Gui = gui; + + // using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) + // { + // // Then + // TestHelper.AssertContextMenuStripContainsItem(contextMenu, + // validateMenuItemIndex, + // "&Valideren", + // "Er is geen hydraulische randvoorwaardendatabase geïmporteerd.", + // RingtoetsCommonFormsResources.ValidateIcon, + // false); + // } + // } + //} + + // TODO WTI-856 + //[Test] + //public void GivenAssessmentSectionWithoutValidPathForCalculation_ThenValidationItemDisabled() + //{ + // // Given + // var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + // failureMechanism.AddSection(new FailureMechanismSection("A", new[] + // { + // new Point2D(0, 0), + // new Point2D(1, 1) + // })); + // var assessmentSection = mocks.Stub(); + // assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); + + // var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation + // { + // Name = "A" + // }; + // var context = new WaveImpactAsphaltCoverWaveConditionsCalculationContext(calculation, + // failureMechanism, + // assessmentSection); + + // using (var treeViewControl = new TreeViewControl()) + // { + // var appFeatureCommandHandler = mocks.Stub(); + // var importHandler = mocks.Stub(); + // var exportHandler = mocks.Stub(); + // var viewCommands = mocks.Stub(); + // var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, + // importHandler, + // exportHandler, + // viewCommands, + // context, + // treeViewControl); + + // var gui = mocks.Stub(); + // gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilderMock); + + // mocks.ReplayAll(); + + // plugin.Gui = gui; + + // using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) + // { + // // Then + // TestHelper.AssertContextMenuStripContainsItem(contextMenu, + // validateMenuItemIndex, + // "&Valideren", + // "Herstellen van de verbinding met de hydraulische randvoorwaardendatabase is mislukt. Fout bij het lezen van bestand '': Bestandspad mag niet leeg of ongedefinieerd zijn.", + // RingtoetsCommonFormsResources.ValidateIcon, + // false); + // } + // } + //} + + // TODO WTI-856 + //[Test] + //public void GivenAssessmentSectionWithValidPathForCalculation_ThenValidationItemEnabled() + //{ + // // Given + // string validHydroDatabasePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HydraRing.IO, + // Path.Combine("HydraulicBoundaryLocationReader", "complete.sqlite")); + + // var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + // failureMechanism.AddSection(new FailureMechanismSection("A", new[] + // { + // new Point2D(0, 0), + // new Point2D(1, 1) + // })); + // var assessmentSection = mocks.Stub(); + // assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + // { + // FilePath = validHydroDatabasePath + // }; + + // var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation + // { + // Name = "A" + // }; + // var context = new WaveImpactAsphaltCoverWaveConditionsCalculationContext(calculation, + // failureMechanism, + // assessmentSection); + + // using (var treeViewControl = new TreeViewControl()) + // { + // var appFeatureCommandHandler = mocks.Stub(); + // var importHandler = mocks.Stub(); + // var exportHandler = mocks.Stub(); + // var viewCommands = mocks.Stub(); + // var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, + // importHandler, + // exportHandler, + // viewCommands, + // context, + // treeViewControl); + + // var gui = mocks.Stub(); + // gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilderMock); + + // mocks.ReplayAll(); + + // plugin.Gui = gui; + + // using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) + // { + // // Then + // TestHelper.AssertContextMenuStripContainsItem(contextMenu, + // validateMenuItemIndex, + // "&Valideren", + // "Valideer de invoer voor deze berekening.", + // RingtoetsCommonFormsResources.ValidateIcon); + // } + // } + //} + + // TODO WTI-856 + //[Test] + //public void GivenValidCalculation_WhenValidating_ThenCalculationPassesValidation() + //{ + // // Given + // string validHydroDatabasePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HydraRing.IO, + // Path.Combine("HydraulicBoundaryLocationReader", "complete.sqlite")); + + // var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + // failureMechanism.AddSection(new FailureMechanismSection("A", new[] + // { + // new Point2D(0, 0), + // new Point2D(1, 1) + // })); + // var assessmentSection = mocks.Stub(); + // assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + // { + // FilePath = validHydroDatabasePath + // }; + // assessmentSection.Stub(a => a.Id).Return("someId"); + // assessmentSection.Stub(a => a.FailureMechanismContribution).Return( + // new FailureMechanismContribution(Enumerable.Empty(), 100, 20)); + + // var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation + // { + // Name = "A" + // }; + // var context = new WaveImpactAsphaltCoverWaveConditionsCalculationContext(calculation, + // failureMechanism, + // assessmentSection); + + // using (var treeViewControl = new TreeViewControl()) + // { + // var appFeatureCommandHandler = mocks.Stub(); + // var importHandler = mocks.Stub(); + // var exportHandler = mocks.Stub(); + // var viewCommands = mocks.Stub(); + // var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, + // importHandler, + // exportHandler, + // viewCommands, + // context, + // treeViewControl); + + // var gui = mocks.Stub(); + // gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilderMock); + + // mocks.ReplayAll(); + + // plugin.Gui = gui; + + // using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) + // { + // // Precondition + // TestHelper.AssertContextMenuStripContainsItem(contextMenu, + // validateMenuItemIndex, + // "&Valideren", + // "Valideer de invoer voor deze berekening.", + // RingtoetsCommonFormsResources.ValidateIcon); + + // // When + // ToolStripItem validateMenuItem = contextMenu.Items[validateMenuItemIndex]; + // Action call = () => validateMenuItem.PerformClick(); + + // // Then + // TestHelper.AssertLogMessages(call, logMessages => + // { + // var messages = logMessages.ToArray(); + // Assert.AreEqual(2, messages.Length); + // StringAssert.StartsWith("Validatie van 'A' gestart om: ", messages[0]); + // StringAssert.StartsWith("Validatie van 'A' beëindigd om: ", messages[1]); + // }); + // } + // } + //} + + [Test] + public void GivenAnyCalculation_ThenCalculateItemEnabled() + { + // Given + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var assessmentSection = mocks.Stub(); + + var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation + { + Name = "A" + }; + var context = new WaveImpactAsphaltCoverWaveConditionsCalculationContext(calculation, + failureMechanism, + assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + var appFeatureCommandHandler = mocks.Stub(); + var importHandler = mocks.Stub(); + var exportHandler = mocks.Stub(); + var viewCommands = mocks.Stub(); + var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, + importHandler, + exportHandler, + viewCommands, + context, + treeViewControl); + + var gui = mocks.Stub(); + gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilderMock); + + mocks.ReplayAll(); + + plugin.Gui = gui; + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) + { + // Then + TestHelper.AssertContextMenuStripContainsItem(contextMenu, + calculateMenuItemIndex, + "Be&rekenen", + "Voer deze berekening uit.", + RingtoetsCommonFormsResources.CalculateIcon); + } + } + } + + [Test] + public void GivenValidCalculation_WhenCalculating_ThenCalculationReturnsResult() + { + // Given + string validHydroDatabasePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HydraRing.IO, + Path.Combine("HydraulicBoundaryLocationReader", "complete.sqlite")); + + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + failureMechanism.AddSection(new FailureMechanismSection("A", new[] + { + new Point2D(0, 0), + new Point2D(1, 1) + })); + var assessmentSection = mocks.Stub(); + assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = validHydroDatabasePath + }; + assessmentSection.Stub(a => a.Id).Return("someId"); + assessmentSection.Stub(a => a.FailureMechanismContribution).Return( + new FailureMechanismContribution(Enumerable.Empty(), 100, 20)); + + var calculation = GetValidCalculation(); + calculation.Name = "A"; + var context = new WaveImpactAsphaltCoverWaveConditionsCalculationContext(calculation, + failureMechanism, + assessmentSection); + + DialogBoxHandler = (name, wnd) => + { + // Expect an activity dialog which is automatically closed + }; + + using (var treeViewControl = new TreeViewControl()) + { + var appFeatureCommandHandler = mocks.Stub(); + var importHandler = mocks.Stub(); + var exportHandler = mocks.Stub(); + var viewCommands = mocks.Stub(); + var mainWindow = mocks.Stub(); + var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, + importHandler, + exportHandler, + viewCommands, + context, + treeViewControl); + var observerMock = mocks.StrictMock(); + observerMock.Expect(o => o.UpdateObserver()); + calculation.Attach(observerMock); + + var gui = mocks.Stub(); + gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilderMock); + gui.Stub(g => g.MainWindow).Return(mainWindow); + + mocks.ReplayAll(); + + plugin.Gui = gui; + + using (new HydraRingCalculationServiceConfig()) + using (new WaveConditionsCalculationServiceConfig()) + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) + { + // Precondition + TestHelper.AssertContextMenuStripContainsItem(contextMenu, + calculateMenuItemIndex, + "Be&rekenen", + "Voer deze berekening uit.", + RingtoetsCommonFormsResources.CalculateIcon); + + // When + ToolStripItem calculateMenuItem = contextMenu.Items[calculateMenuItemIndex]; + Action call = () => calculateMenuItem.PerformClick(); + + // Then + TestHelper.AssertLogMessages(call, logMessages => + { + var messages = logMessages.ToArray(); + Assert.AreEqual(9, messages.Length); + StringAssert.StartsWith("Berekening van 'A' gestart om: ", messages[0]); + StringAssert.StartsWith("Berekening van 'A' beëindigd om: ", messages[7]); + StringAssert.StartsWith("Uitvoeren van 'A' is gelukt.", messages[8]); + }); + } + } + } + + [Test] + public void GivenCalculationWithoutOutput_ThenClearOutputItemDisabled() + { + // Given + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var assessmentSection = mocks.Stub(); + + var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation + { + Name = "A", + Output = null + }; + var context = new WaveImpactAsphaltCoverWaveConditionsCalculationContext(calculation, + failureMechanism, + assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + var appFeatureCommandHandler = mocks.Stub(); + var importHandler = mocks.Stub(); + var exportHandler = mocks.Stub(); + var viewCommands = mocks.Stub(); + var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, + importHandler, + exportHandler, + viewCommands, + context, + treeViewControl); + + var gui = mocks.Stub(); + gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilderMock); + + mocks.ReplayAll(); + + plugin.Gui = gui; + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) + { + // Then + TestHelper.AssertContextMenuStripContainsItem(contextMenu, + clearOutputMenuItemIndex, + "&Wis uitvoer...", + "Deze berekening heeft geen uitvoer om te wissen.", + RingtoetsCommonFormsResources.ClearIcon, + false); + } + } + } + + [Test] + public void GivenCalculationWithOutput_ThenClearOutputItemEnabled() + { + // Given + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var assessmentSection = mocks.Stub(); + + var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation + { + Name = "A", + Output = new WaveImpactAsphaltCoverWaveConditionsOutput(Enumerable.Empty()) + }; + var context = new WaveImpactAsphaltCoverWaveConditionsCalculationContext(calculation, + failureMechanism, + assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + var appFeatureCommandHandler = mocks.Stub(); + var importHandler = mocks.Stub(); + var exportHandler = mocks.Stub(); + var viewCommands = mocks.Stub(); + var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, + importHandler, + exportHandler, + viewCommands, + context, + treeViewControl); + + var gui = mocks.Stub(); + gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilderMock); + + mocks.ReplayAll(); + + plugin.Gui = gui; + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) + { + // Then + TestHelper.AssertContextMenuStripContainsItem(contextMenu, + clearOutputMenuItemIndex, + "&Wis uitvoer...", + "Wis de uitvoer van deze berekening.", + RingtoetsCommonFormsResources.ClearIcon); + } + } + } + + [Test] + public void GivenCalculationWithOutput_WhenClearingOutput_ThenClearOutput() + { + // Given + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var assessmentSection = mocks.Stub(); + + var observer = mocks.Stub(); + observer.Expect(o => o.UpdateObserver()); + + var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation + { + Name = "A", + Output = new WaveImpactAsphaltCoverWaveConditionsOutput(Enumerable.Empty()) + }; + calculation.Attach(observer); + var context = new WaveImpactAsphaltCoverWaveConditionsCalculationContext(calculation, + failureMechanism, + assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + var appFeatureCommandHandler = mocks.Stub(); + var importHandler = mocks.Stub(); + var exportHandler = mocks.Stub(); + var viewCommands = mocks.Stub(); + var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, + importHandler, + exportHandler, + viewCommands, + context, + treeViewControl); + + var gui = mocks.Stub(); + gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilderMock); + + mocks.ReplayAll(); + + plugin.Gui = gui; + + DialogBoxHandler = (name, wnd) => + { + var messageBox = new MessageBoxTester(wnd); + messageBox.ClickOk(); + }; + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) + { + // Precondition + TestHelper.AssertContextMenuStripContainsItem(contextMenu, + clearOutputMenuItemIndex, + "&Wis uitvoer...", + "Wis de uitvoer van deze berekening.", + RingtoetsCommonFormsResources.ClearIcon); + + // When + ToolStripItem validateMenuItem = contextMenu.Items[clearOutputMenuItemIndex]; + validateMenuItem.PerformClick(); + + // Then + Assert.IsNull(calculation.Output); + // Check expectancies in TearDown() + } + } + } + + private static WaveImpactAsphaltCoverWaveConditionsCalculation GetValidCalculation() + { + var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation + { + InputParameters = + { + HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1300001, "", 0.0, 0.0), + ForeshoreProfile = CreateForeshoreProfile(), + UseForeshore = true, + UseBreakWater = true, + StepSize = WaveConditionsInputStepSize.Half, + LowerBoundaryRevetment = (RoundedDouble) 4, + UpperBoundaryRevetment = (RoundedDouble) 10, + UpperBoundaryWaterLevels = (RoundedDouble) 8, + LowerBoundaryWaterLevels = (RoundedDouble) 7.1 + } + }; + calculation.InputParameters.HydraulicBoundaryLocation.DesignWaterLevel = (RoundedDouble) 9.3; + return calculation; + } + + private static ForeshoreProfile CreateForeshoreProfile() + { + return new ForeshoreProfile(new Point2D(0, 0), + new[] + { + new Point2D(3.3, 4.4), + new Point2D(5.5, 6.6) + }, + new BreakWater(BreakWaterType.Dam, 10.0), + new ForeshoreProfile.ConstructionProperties()); + } + } +} \ No newline at end of file Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r11f0867b39150ae5fac83dc178a89fee46d27611 -r0d7efa62d16c64a925c63172e4d1bf1a4e0bf94f --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision 11f0867b39150ae5fac83dc178a89fee46d27611) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision 0d7efa62d16c64a925c63172e4d1bf1a4e0bf94f) @@ -20,6 +20,7 @@ // All rights reserved. using System.Drawing; +using System.IO; using System.Linq; using System.Windows.Forms; using Core.Common.Base; @@ -29,16 +30,21 @@ using Core.Common.Gui; using Core.Common.Gui.Commands; using Core.Common.Gui.ContextMenu; +using Core.Common.Gui.Forms.MainWindow; using Core.Common.Gui.TestUtil.ContextMenu; using Core.Common.TestUtil; using NUnit.Extensions.Forms; using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.Data.Contribution; using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.HydraRing.Calculation.TestUtil; using Ringtoets.HydraRing.Data; using Ringtoets.Revetment.Data; +using Ringtoets.Revetment.Service.TestUtil; using Ringtoets.WaveImpactAsphaltCover.Data; using Ringtoets.WaveImpactAsphaltCover.Forms.PresentationObjects; using Ringtoets.WaveImpactAsphaltCover.Plugin; @@ -118,8 +124,8 @@ var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); var context = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - failureMechanism, - assessmentSection); + failureMechanism, + assessmentSection); // Call string text = info.Text(context); @@ -137,8 +143,8 @@ var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); var context = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - failureMechanism, - assessmentSection); + failureMechanism, + assessmentSection); // Call Image icon = info.Image(context); @@ -157,8 +163,8 @@ var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); var groupContext = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - failureMechanism, - assessmentSection); + failureMechanism, + assessmentSection); // Call var children = info.ChildNodeObjects(groupContext); @@ -182,16 +188,16 @@ failureMechanism.WaveConditionsCalculationGroup.Children.Add(childGroup); var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - failureMechanism, - assessmentSection); + failureMechanism, + assessmentSection); // Call var children = info.ChildNodeObjects(nodeData).ToArray(); // Assert Assert.AreEqual(failureMechanism.WaveConditionsCalculationGroup.Children.Count, children.Length); Assert.AreSame(calculationItem, children[0]); - var returnedCalculationGroupContext = (WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext)children[1]; + var returnedCalculationGroupContext = (WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext) children[1]; Assert.AreSame(childGroup, returnedCalculationGroupContext.WrappedData); Assert.AreSame(failureMechanism, returnedCalculationGroupContext.FailureMechanism); } @@ -208,11 +214,11 @@ var assessmentSection = mocks.Stub(); var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(group, - failureMechanism, - assessmentSection); + failureMechanism, + assessmentSection); var parentNodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - failureMechanism, - assessmentSection); + failureMechanism, + assessmentSection); var applicationFeatureCommandHandler = mocks.Stub(); var importHandlerMock = mocks.StrictMock(); @@ -243,71 +249,70 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) { // Assert - Assert.AreEqual(15, menu.Items.Count); + Assert.AreEqual(16, menu.Items.Count); TestHelper.AssertContextMenuStripContainsItem(menu, 0, - CoreCommonGuiResources.Export, - CoreCommonGuiResources.Export_ToolTip, + "&Exporteren...", + "Exporteer de gegevens naar een bestand.", CoreCommonGuiResources.ExportIcon); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationGroupIndexNestedGroup, - RingtoetsCommonFormsResources.CalculationGroup_Add_CalculationGroup, + "&Map toevoegen", "Voeg een nieuwe berekeningsmap toe aan deze berekeningsmap.", RingtoetsCommonFormsResources.AddFolderIcon); - // TODO WTI-819 - //TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationIndexNestedGroup, - // RingtoetsCommonFormsResources.CalculationGroup_Add_Calculation, - // "Voeg een nieuwe berekening toe aan deze berekeningsmap.", - // RingtoetsCommonFormsResources.FailureMechanismIcon); - TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndexNestedGroup-1, - RingtoetsCommonFormsResources.Validate_all, + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationIndexNestedGroup, + "Berekening &toevoegen", + "Voeg een nieuwe berekening toe aan deze berekeningsmap.", + RingtoetsCommonFormsResources.FailureMechanismIcon); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndexNestedGroup, + "Alles &valideren", "Er zijn geen berekeningen om te valideren.", RingtoetsCommonFormsResources.ValidateAllIcon, false); - TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndexNestedGroup-1, - RingtoetsCommonFormsResources.Calculate_all, + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndexNestedGroup, + "Alles be&rekenen", "Er zijn geen berekeningen om uit te voeren.", RingtoetsCommonFormsResources.CalculateAllIcon, false); - TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuClearOutputNestedGroupIndex-1, + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuClearOutputNestedGroupIndex, "&Wis alle uitvoer...", "Er zijn geen berekeningen met uitvoer om te wissen.", RingtoetsCommonFormsResources.ClearIcon, false); - TestHelper.AssertContextMenuStripContainsItem(menu, 9-1, - CoreCommonGuiResources.Rename, - CoreCommonGuiResources.Rename_ToolTip, + TestHelper.AssertContextMenuStripContainsItem(menu, 9, + "&Hernoemen", + "Wijzig de naam van dit element.", CoreCommonGuiResources.RenameIcon); - TestHelper.AssertContextMenuStripContainsItem(menu, 10-1, - CoreCommonGuiResources.Delete, - CoreCommonGuiResources.Delete_ToolTip, + TestHelper.AssertContextMenuStripContainsItem(menu, 10, + "Verwij&deren...", + "Verwijder dit element uit de boom.", CoreCommonGuiResources.DeleteIcon); - TestHelper.AssertContextMenuStripContainsItem(menu, 12-1, - CoreCommonGuiResources.Expand_all, - CoreCommonGuiResources.Expand_all_ToolTip, + TestHelper.AssertContextMenuStripContainsItem(menu, 12, + "Alles ui&tklappen", + "Klap dit element en alle onderliggende elementen uit.", CoreCommonGuiResources.ExpandAllIcon, false); - TestHelper.AssertContextMenuStripContainsItem(menu, 13-1, - CoreCommonGuiResources.Collapse_all, - CoreCommonGuiResources.Collapse_all_ToolTip, + TestHelper.AssertContextMenuStripContainsItem(menu, 13, + "Alles i&nklappen", + "Klap dit element en alle onderliggende elementen in.", CoreCommonGuiResources.CollapseAllIcon, false); - TestHelper.AssertContextMenuStripContainsItem(menu, 15-1, - CoreCommonGuiResources.Properties, - CoreCommonGuiResources.Properties_ToolTip, + TestHelper.AssertContextMenuStripContainsItem(menu, 15, + "Ei&genschappen", + "Toon de eigenschappen in het Eigenschappenpaneel.", CoreCommonGuiResources.PropertiesHS, false); CollectionAssert.AllItemsAreInstancesOfType(new[] { menu.Items[1], - menu.Items[4-1], - menu.Items[8-1], - menu.Items[11-1], - menu.Items[14-1] + menu.Items[4], + menu.Items[8], + menu.Items[11], + menu.Items[14] }, typeof(ToolStripSeparator)); } } @@ -321,8 +326,8 @@ var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - failureMechanism, - assessmentSection); + failureMechanism, + assessmentSection); var applicationFeatureCommandHandler = mocks.Stub(); var importHandlerMock = mocks.StrictMock(); @@ -349,259 +354,256 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // Assert - Assert.AreEqual(15, menu.Items.Count); + Assert.AreEqual(16, menu.Items.Count); TestHelper.AssertContextMenuStripContainsItem(menu, customOnlyContextMenuAddGenerateCalculationsIndex, - RingtoetsCommonFormsResources.CalculationsGroup_Generate_calculations, + "Genereer &berekeningen...", "Er is geen hydraulische randvoorwaardendatabase beschikbaar om de randvoorwaardenberekeningen te genereren.", RingtoetsCommonFormsResources.GenerateScenariosIcon, false); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationGroupIndexRootGroup, - RingtoetsCommonFormsResources.CalculationGroup_Add_CalculationGroup, + "&Map toevoegen", "Voeg een nieuwe berekeningsmap toe aan deze berekeningsmap.", RingtoetsCommonFormsResources.AddFolderIcon); - // TODO WTI-819 - //TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationIndexRootGroup, - // RingtoetsCommonFormsResources.CalculationGroup_Add_Calculation, - // "Voeg een nieuwe berekening toe aan deze berekeningsmap.", - // RingtoetsCommonFormsResources.FailureMechanismIcon); - TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuRemoveAllChildrenIndexRootGroup-1, - RingtoetsCommonFormsResources.CalculationGroup_RemoveAllChildrenFromGroup_Remove_all, + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationIndexRootGroup, + "Berekening &toevoegen", + "Voeg een nieuwe berekening toe aan deze berekeningsmap.", + RingtoetsCommonFormsResources.FailureMechanismIcon); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuRemoveAllChildrenIndexRootGroup, + "Map &leegmaken...", "Er zijn geen berekeningen of mappen om te verwijderen.", RingtoetsCommonFormsResources.RemoveAllIcon, false); - TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndexRootGroup-1, - RingtoetsCommonFormsResources.Validate_all, + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndexRootGroup, + "Alles &valideren", "Er zijn geen berekeningen om te valideren.", RingtoetsCommonFormsResources.ValidateAllIcon, false); - TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndexRootGroup-1, - RingtoetsCommonFormsResources.Calculate_all, + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndexRootGroup, + "Alles be&rekenen", "Er zijn geen berekeningen om uit te voeren.", RingtoetsCommonFormsResources.CalculateAllIcon, false); - TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuClearOutputIndexRootGroup-1, + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuClearOutputIndexRootGroup, "&Wis alle uitvoer...", "Er zijn geen berekeningen met uitvoer om te wissen.", RingtoetsCommonFormsResources.ClearIcon, false); - TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuExpandAllIndexRootGroup-1, - CoreCommonGuiResources.Expand_all, - CoreCommonGuiResources.Expand_all_ToolTip, + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuExpandAllIndexRootGroup, + "Alles ui&tklappen", + "Klap dit element en alle onderliggende elementen uit.", CoreCommonGuiResources.ExpandAllIcon, false); - TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCollapseAllIndexRootGroup-1, - CoreCommonGuiResources.Collapse_all, - CoreCommonGuiResources.Collapse_all_ToolTip, + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCollapseAllIndexRootGroup, + "Alles i&nklappen", + "Klap dit element en alle onderliggende elementen in.", CoreCommonGuiResources.CollapseAllIcon, false); - TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuPropertiesIndexRootGroup-1, - CoreCommonGuiResources.Properties, - CoreCommonGuiResources.Properties_ToolTip, + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuPropertiesIndexRootGroup, + "Ei&genschappen", + "Toon de eigenschappen in het Eigenschappenpaneel.", CoreCommonGuiResources.PropertiesHS, false); CollectionAssert.AllItemsAreInstancesOfType(new[] { menu.Items[2], - menu.Items[5-1], - menu.Items[7-1], - menu.Items[11-1], - menu.Items[14-1] + menu.Items[5], + menu.Items[7], + menu.Items[11], + menu.Items[14] }, typeof(ToolStripSeparator)); } } } - // TODO WTI-819 - //[Test] - //public void ContextMenuStrip_WithoutParentNodeWithHydraulicLocationsDefaultBehavior_ReturnContextMenuWithoutRenameRemove() - //{ - // // Setup - // var assessmentSection = mocks.Stub(); - // assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase - // { - // Locations = - // { - // new HydraulicBoundaryLocation(1, "1", 1, 1) - // } - // }; - // var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + [Test] + public void ContextMenuStrip_WithoutParentNodeWithHydraulicLocationsDefaultBehavior_ReturnContextMenuWithoutRenameRemove() + { + // Setup + var assessmentSection = mocks.Stub(); + assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + Locations = + { + new HydraulicBoundaryLocation(1, "1", 1, 1) + } + }; + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); - // var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - // failureMechanism, - // assessmentSection); + var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, + failureMechanism, + assessmentSection); - // var applicationFeatureCommandHandler = mocks.Stub(); - // var importHandlerMock = mocks.StrictMock(); - // var exportHandlerMock = mocks.StrictMock(); - // exportHandlerMock.Expect(ehm => ehm.CanExportFrom(nodeData)).Return(true); - // var viewCommandsHandler = mocks.StrictMock(); - // using (var treeViewControl = new TreeViewControl()) - // { - // var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler, - // importHandlerMock, - // exportHandlerMock, - // viewCommandsHandler, - // nodeData, - // treeViewControl); + var applicationFeatureCommandHandler = mocks.Stub(); + var importHandlerMock = mocks.StrictMock(); + var exportHandlerMock = mocks.StrictMock(); + exportHandlerMock.Expect(ehm => ehm.CanExportFrom(nodeData)).Return(true); + var viewCommandsHandler = mocks.StrictMock(); + using (var treeViewControl = new TreeViewControl()) + { + var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler, + importHandlerMock, + exportHandlerMock, + viewCommandsHandler, + nodeData, + treeViewControl); - // var gui = mocks.Stub(); - // gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); - // gui.Stub(cmp => cmp.ViewCommands).Return(mocks.Stub()); - // mocks.ReplayAll(); + var gui = mocks.Stub(); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(cmp => cmp.ViewCommands).Return(mocks.Stub()); + mocks.ReplayAll(); - // plugin.Gui = gui; + plugin.Gui = gui; - // // Call - // using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - // { - // // Assert - // Assert.AreEqual(16, menu.Items.Count); - // TestHelper.AssertContextMenuStripContainsItem(menu, customOnlyContextMenuAddGenerateCalculationsIndex, - // RingtoetsCommonFormsResources.CalculationsGroup_Generate_calculations, - // "Genereer randvoorwaardenberekeningen.", - // RingtoetsCommonFormsResources.GenerateScenariosIcon); - // TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationGroupIndexRootGroup, - // RingtoetsCommonFormsResources.CalculationGroup_Add_CalculationGroup, - // "Voeg een nieuwe berekeningsmap toe aan deze berekeningsmap.", - // RingtoetsCommonFormsResources.AddFolderIcon); - // TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationIndexRootGroup, - // RingtoetsCommonFormsResources.CalculationGroup_Add_Calculation, - // "Voeg een nieuwe berekening toe aan deze berekeningsmap.", - // RingtoetsCommonFormsResources.FailureMechanismIcon); + // Call + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + Assert.AreEqual(16, menu.Items.Count); + // TODO WTI-856 + //TestHelper.AssertContextMenuStripContainsItem(menu, customOnlyContextMenuAddGenerateCalculationsIndex, + // "Genereer &berekeningen...", + // "Genereer randvoorwaardenberekeningen.", + // RingtoetsCommonFormsResources.GenerateScenariosIcon); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationGroupIndexRootGroup, + "&Map toevoegen", + "Voeg een nieuwe berekeningsmap toe aan deze berekeningsmap.", + RingtoetsCommonFormsResources.AddFolderIcon); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationIndexRootGroup, + "Berekening &toevoegen", + "Voeg een nieuwe berekening toe aan deze berekeningsmap.", + RingtoetsCommonFormsResources.FailureMechanismIcon); - // TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuRemoveAllChildrenIndexRootGroup, - // RingtoetsCommonFormsResources.CalculationGroup_RemoveAllChildrenFromGroup_Remove_all, - // "Er zijn geen berekeningen of mappen om te verwijderen.", - // RingtoetsCommonFormsResources.RemoveAllIcon, - // false); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuRemoveAllChildrenIndexRootGroup, + "Map &leegmaken...", + "Er zijn geen berekeningen of mappen om te verwijderen.", + RingtoetsCommonFormsResources.RemoveAllIcon, + false); - // TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndexRootGroup, - // RingtoetsCommonFormsResources.Validate_all, - // "Er zijn geen berekeningen om te valideren.", - // RingtoetsCommonFormsResources.ValidateAllIcon, - // false); - // TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndexRootGroup, - // RingtoetsCommonFormsResources.Calculate_all, - // "Er zijn geen berekeningen om uit te voeren.", - // RingtoetsCommonFormsResources.CalculateAllIcon, - // false); - // TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuClearOutputIndexRootGroup, - // "&Wis alle uitvoer...", - // "Er zijn geen berekeningen met uitvoer om te wissen.", - // RingtoetsCommonFormsResources.ClearIcon, - // false); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndexRootGroup, + "Alles &valideren", + "Er zijn geen berekeningen om te valideren.", + RingtoetsCommonFormsResources.ValidateAllIcon, + false); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndexRootGroup, + "Alles be&rekenen", + "Er zijn geen berekeningen om uit te voeren.", + RingtoetsCommonFormsResources.CalculateAllIcon, + false); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuClearOutputIndexRootGroup, + "&Wis alle uitvoer...", + "Er zijn geen berekeningen met uitvoer om te wissen.", + RingtoetsCommonFormsResources.ClearIcon, + false); - // TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuExpandAllIndexRootGroup, - // CoreCommonGuiResources.Expand_all, - // CoreCommonGuiResources.Expand_all_ToolTip, - // CoreCommonGuiResources.ExpandAllIcon, - // false); - // TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCollapseAllIndexRootGroup, - // CoreCommonGuiResources.Collapse_all, - // CoreCommonGuiResources.Collapse_all_ToolTip, - // CoreCommonGuiResources.CollapseAllIcon, - // false); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuExpandAllIndexRootGroup, + "Alles ui&tklappen", + "Klap dit element en alle onderliggende elementen uit.", + CoreCommonGuiResources.ExpandAllIcon, + false); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCollapseAllIndexRootGroup, + "Alles i&nklappen", + "Klap dit element en alle onderliggende elementen in.", + CoreCommonGuiResources.CollapseAllIcon, + false); - // TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuPropertiesIndexRootGroup, - // CoreCommonGuiResources.Properties, - // CoreCommonGuiResources.Properties_ToolTip, - // CoreCommonGuiResources.PropertiesHS, - // false); - // CollectionAssert.AllItemsAreInstancesOfType(new[] - // { - // menu.Items[2], - // menu.Items[5], - // menu.Items[7], - // menu.Items[11], - // menu.Items[14] - // }, typeof(ToolStripSeparator)); - // } - // } - //} + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuPropertiesIndexRootGroup, + "Ei&genschappen", + "Toon de eigenschappen in het Eigenschappenpaneel.", + CoreCommonGuiResources.PropertiesHS, + false); + CollectionAssert.AllItemsAreInstancesOfType(new[] + { + menu.Items[2], + menu.Items[5], + menu.Items[7], + menu.Items[11], + menu.Items[14] + }, typeof(ToolStripSeparator)); + } + } + } - // TODO WTI-819 - //[Test] - //public void ContextMenuStrip_NestedCalculationGroupWithNoCalculations_ValidateAndCalculateAllDisabled() - //{ - // // Setup - // using (var treeViewControl = new TreeViewControl()) - // { - // var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); - // var group = new CalculationGroup(); - // failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); - // var assessmentSection = mocks.Stub(); - // var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(group, - // failureMechanism, - // assessmentSection); - // var parentNodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - // failureMechanism, - // assessmentSection); + [Test] + public void ContextMenuStrip_NestedCalculationGroupWithNoCalculations_ValidateAndCalculateAllDisabled() + { + // Setup + using (var treeViewControl = new TreeViewControl()) + { + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var group = new CalculationGroup(); + failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); + var assessmentSection = mocks.Stub(); + var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(group, + failureMechanism, + assessmentSection); + var parentNodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, + failureMechanism, + assessmentSection); - // var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - // var gui = mocks.Stub(); - // gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); + var gui = mocks.Stub(); + gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - // mocks.ReplayAll(); + mocks.ReplayAll(); - // plugin.Gui = gui; + plugin.Gui = gui; - // // Call - // using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) - // { - // // Assert - // ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroupNoCalculations]; - // ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroupNoCalculations]; - // Assert.IsFalse(validateItem.Enabled); - // Assert.IsFalse(calculateItem.Enabled); - // Assert.AreEqual(RingtoetsCommonFormsResources.FailureMechanism_CreateCalculateAllItem_No_calculations_to_run, calculateItem.ToolTipText); - // Assert.AreEqual(RingtoetsCommonFormsResources.FailureMechanism_CreateValidateAllItem_No_calculations_to_validate, validateItem.ToolTipText); - // } - // } - //} + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) + { + // Assert + ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroupNoCalculations]; + ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroupNoCalculations]; + Assert.IsFalse(validateItem.Enabled); + Assert.IsFalse(calculateItem.Enabled); + Assert.AreEqual("Er zijn geen berekeningen om uit te voeren.", calculateItem.ToolTipText); + Assert.AreEqual("Er zijn geen berekeningen om te valideren.", validateItem.ToolTipText); + } + } + } - // TODO WTI-819 - //[Test] - //public void ContextMenuStrip_FailureMechanismWithNoSections_ValidateAndCalculateAllDisabled() - //{ - // // Setup - // using (var treeViewControl = new TreeViewControl()) - // { - // var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); - // var group = new CalculationGroup(); - // group.Children.Add(new WaveImpactAsphaltCoverWaveConditionsCalculation()); - // failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); - // var assessmentSection = mocks.Stub(); - // var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(group, - // failureMechanism, - // assessmentSection); - // var parentNodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - // failureMechanism, - // assessmentSection); + [Test] + public void ContextMenuStrip_FailureMechanismWithNoSections_ValidateAndCalculateAllDisabled() + { + // Setup + using (var treeViewControl = new TreeViewControl()) + { + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var group = new CalculationGroup(); + group.Children.Add(new WaveImpactAsphaltCoverWaveConditionsCalculation()); + failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); + var assessmentSection = mocks.Stub(); + var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(group, + failureMechanism, + assessmentSection); + var parentNodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, + failureMechanism, + assessmentSection); - // var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - // var gui = mocks.Stub(); - // gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); + var gui = mocks.Stub(); + gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - // mocks.ReplayAll(); + mocks.ReplayAll(); - // plugin.Gui = gui; + plugin.Gui = gui; - // // Call - // using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) - // { - // // Assert - // ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroupNoCalculations]; - // ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroupNoCalculations]; - // Assert.IsFalse(validateItem.Enabled); - // Assert.IsFalse(calculateItem.Enabled); - // Assert.AreEqual(RingtoetsCommonFormsResources.Plugin_AllDataAvailable_No_failure_mechanism_sections_imported, calculateItem.ToolTipText); - // Assert.AreEqual(RingtoetsCommonFormsResources.Plugin_AllDataAvailable_No_failure_mechanism_sections_imported, validateItem.ToolTipText); - // } - // } - //} + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) + { + // Assert + ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroupNoCalculations]; + ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroupNoCalculations]; + Assert.IsFalse(validateItem.Enabled); + Assert.IsFalse(calculateItem.Enabled); + Assert.AreEqual("Er is geen vakindeling geïmporteerd.", calculateItem.ToolTipText); + Assert.AreEqual("Er is geen vakindeling geïmporteerd.", validateItem.ToolTipText); + } + } + } // TODO WTI-856 //[Test] @@ -904,230 +906,226 @@ // } //} - // TODO WTI-819 - //[Test] - //public void ContextMenuStrip_TwoCalculationsWithoutOutput_ClearAllOutputItemDisabled() - //{ - // string hrdPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Service, "HydraRingCalculation"); + [Test] + public void ContextMenuStrip_TwoCalculationsWithoutOutput_ClearAllOutputItemDisabled() + { + string hrdPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Service, "HydraRingCalculation"); - // var assessmentSection = mocks.Stub(); - // assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase - // { - // FilePath = Path.Combine(hrdPath, "HRD ijsselmeer.sqlite") - // }; - // assessmentSection.Stub(a => a.FailureMechanismContribution).Return( - // new FailureMechanismContribution(Enumerable.Empty(), 30, 2)); - // assessmentSection.Stub(a => a.Id).Return("someId"); + var assessmentSection = mocks.Stub(); + assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = Path.Combine(hrdPath, "HRD ijsselmeer.sqlite") + }; + assessmentSection.Stub(a => a.FailureMechanismContribution).Return( + new FailureMechanismContribution(Enumerable.Empty(), 30, 2)); + assessmentSection.Stub(a => a.Id).Return("someId"); - // var group = new CalculationGroup(); - // var calculationA = GetValidCalculation(); - // var calculationB = GetValidCalculation(); - // group.Children.Add(calculationA); - // group.Children.Add(calculationB); + var group = new CalculationGroup(); + var calculationA = GetValidCalculation(); + var calculationB = GetValidCalculation(); + group.Children.Add(calculationA); + group.Children.Add(calculationB); - // var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); - // failureMechanism.AddSection(new FailureMechanismSection("", new[] - // { - // new Point2D(0, 0) - // })); - // failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); - // var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(group, - // failureMechanism, - // assessmentSection); - // var parentNodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - // failureMechanism, - // assessmentSection); + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + failureMechanism.AddSection(new FailureMechanismSection("", new[] + { + new Point2D(0, 0) + })); + failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); + var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(group, + failureMechanism, + assessmentSection); + var parentNodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, + failureMechanism, + assessmentSection); - // var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - // // Setup - // using (var treeViewControl = new TreeViewControl()) - // { - // var mainWindow = mocks.Stub(); + // Setup + using (var treeViewControl = new TreeViewControl()) + { + var mainWindow = mocks.Stub(); - // var gui = mocks.Stub(); - // gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - // gui.Stub(g => g.MainWindow).Return(mainWindow); + var gui = mocks.Stub(); + gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mainWindow); - // mocks.ReplayAll(); + mocks.ReplayAll(); - // plugin.Gui = gui; + plugin.Gui = gui; - // using (new HydraRingCalculationServiceConfig()) - // using (new WaveConditionsCalculationServiceConfig()) - // using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) - // { - // // Call - // var clearAllOutputItem = contextMenu.Items[6]; + using (new HydraRingCalculationServiceConfig()) + using (new WaveConditionsCalculationServiceConfig()) + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) + { + // Call + var clearAllOutputItem = contextMenu.Items[6]; - // // Assert - // Assert.IsFalse(clearAllOutputItem.Enabled); - // } - // } - //} + // Assert + Assert.IsFalse(clearAllOutputItem.Enabled); + } + } + } - // TODO WTI-819 - //[Test] - //[TestCase(true)] - //[TestCase(false)] - //public void ContextMenuStrip_TwoCalculationsWithOutputClickOnClearAllOutput_OutputRemovedForCalculationsAfterConfirmation(bool confirm) - //{ - // string hrdPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Service, "HydraRingCalculation"); + [Test] + [TestCase(true)] + [TestCase(false)] + public void ContextMenuStrip_TwoCalculationsWithOutputClickOnClearAllOutput_OutputRemovedForCalculationsAfterConfirmation(bool confirm) + { + string hrdPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Service, "HydraRingCalculation"); - // var assessmentSection = mocks.Stub(); - // assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase - // { - // FilePath = Path.Combine(hrdPath, "HRD ijsselmeer.sqlite") - // }; - // assessmentSection.Stub(a => a.FailureMechanismContribution).Return( - // new FailureMechanismContribution(Enumerable.Empty(), 30, 2)); - // assessmentSection.Stub(a => a.Id).Return("someId"); + var assessmentSection = mocks.Stub(); + assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = Path.Combine(hrdPath, "HRD ijsselmeer.sqlite") + }; + assessmentSection.Stub(a => a.FailureMechanismContribution).Return( + new FailureMechanismContribution(Enumerable.Empty(), 30, 2)); + assessmentSection.Stub(a => a.Id).Return("someId"); - // var observerA = mocks.StrictMock(); - // var observerB = mocks.StrictMock(); - // if (confirm) - // { - // observerA.Expect(o => o.UpdateObserver()); - // observerB.Expect(o => o.UpdateObserver()); - // } + var observerA = mocks.StrictMock(); + var observerB = mocks.StrictMock(); + if (confirm) + { + observerA.Expect(o => o.UpdateObserver()); + observerB.Expect(o => o.UpdateObserver()); + } - // var group = new CalculationGroup(); - // var calculationA = GetValidCalculation(); - // calculationA.Output = new WaveImpactAsphaltCoverWaveConditionsOutput(Enumerable.Empty()); - // var calculationB = GetValidCalculation(); - // calculationB.Output = new WaveImpactAsphaltCoverWaveConditionsOutput(Enumerable.Empty()); - // group.Children.Add(calculationA); - // group.Children.Add(calculationB); - // calculationA.Attach(observerA); - // calculationB.Attach(observerB); + var group = new CalculationGroup(); + var calculationA = GetValidCalculation(); + calculationA.Output = new WaveImpactAsphaltCoverWaveConditionsOutput(Enumerable.Empty()); + var calculationB = GetValidCalculation(); + calculationB.Output = new WaveImpactAsphaltCoverWaveConditionsOutput(Enumerable.Empty()); + group.Children.Add(calculationA); + group.Children.Add(calculationB); + calculationA.Attach(observerA); + calculationB.Attach(observerB); - // var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); - // failureMechanism.AddSection(new FailureMechanismSection("", new[] - // { - // new Point2D(0, 0) - // })); - // failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); - // var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(group, - // failureMechanism, - // assessmentSection); - // var parentNodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - // failureMechanism, - // assessmentSection); + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + failureMechanism.AddSection(new FailureMechanismSection("", new[] + { + new Point2D(0, 0) + })); + failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); + var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(group, + failureMechanism, + assessmentSection); + var parentNodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, + failureMechanism, + assessmentSection); - // var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - // DialogBoxHandler = (name, wnd) => - // { - // var dialog = new MessageBoxTester(wnd); - // if (confirm) - // { - // dialog.ClickOk(); - // } - // else - // { - // dialog.ClickCancel(); - // } - // }; + DialogBoxHandler = (name, wnd) => + { + var dialog = new MessageBoxTester(wnd); + if (confirm) + { + dialog.ClickOk(); + } + else + { + dialog.ClickCancel(); + } + }; - // // Setup - // using (var treeViewControl = new TreeViewControl()) - // { - // var mainWindow = mocks.Stub(); + // Setup + using (var treeViewControl = new TreeViewControl()) + { + var mainWindow = mocks.Stub(); - // var gui = mocks.Stub(); - // gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - // gui.Stub(g => g.MainWindow).Return(mainWindow); + var gui = mocks.Stub(); + gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mainWindow); - // mocks.ReplayAll(); + mocks.ReplayAll(); - // plugin.Gui = gui; + plugin.Gui = gui; - // using (new HydraRingCalculationServiceConfig()) - // using (new WaveConditionsCalculationServiceConfig()) - // using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) - // { - // // Call - // contextMenu.Items[6].PerformClick(); + using (new HydraRingCalculationServiceConfig()) + using (new WaveConditionsCalculationServiceConfig()) + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) + { + // Call + contextMenu.Items[6].PerformClick(); - // // Assert - // if (confirm) - // { - // Assert.IsNull(calculationA.Output); - // Assert.IsNull(calculationB.Output); - // } - // } - // } - //} + // Assert + if (confirm) + { + Assert.IsNull(calculationA.Output); + Assert.IsNull(calculationB.Output); + } + } + } + } - // TODO WTI-819 - //[Test] - //public void ContextMenuStrip_WithoutParentNodeWithNoChildren_RemoveAllChildrenDisabled() - //{ - // // Setup - // using (var treeViewControl = new TreeViewControl()) - // { - // var assessmentSection = mocks.Stub(); + [Test] + public void ContextMenuStrip_WithoutParentNodeWithNoChildren_RemoveAllChildrenDisabled() + { + // Setup + using (var treeViewControl = new TreeViewControl()) + { + var assessmentSection = mocks.Stub(); - // var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); - // var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - // failureMechanism, - // assessmentSection); + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, + failureMechanism, + assessmentSection); - // var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - // var gui = mocks.Stub(); - // gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - // gui.Stub(cmp => cmp.ViewCommands).Return(mocks.Stub()); + var gui = mocks.Stub(); + gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(cmp => cmp.ViewCommands).Return(mocks.Stub()); - // mocks.ReplayAll(); + mocks.ReplayAll(); - // plugin.Gui = gui; + plugin.Gui = gui; - // // Call - // using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - // { - // // Assert - // ToolStripItem removeAllItemDisabled = contextMenu.Items[customOnlyContextMenuRemoveAllChildrenIndex]; - // Assert.IsFalse(removeAllItemDisabled.Enabled); - // Assert.AreEqual(RingtoetsCommonFormsResources.CalculationGroup_RemoveAllChildrenFromGroup_No_Calculation_or_Group_to_remove, removeAllItemDisabled.ToolTipText); - // } - // } - //} + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + ToolStripItem removeAllItemDisabled = contextMenu.Items[customOnlyContextMenuRemoveAllChildrenIndex]; + Assert.IsFalse(removeAllItemDisabled.Enabled); + Assert.AreEqual("Er zijn geen berekeningen of mappen om te verwijderen.", removeAllItemDisabled.ToolTipText); + } + } + } - // TODO WTI-819 - //[Test] - //public void ContextMenuStrip_WithoutParentNodeWithChildren_RemoveAllChildrenEnabled() - //{ - // // Setup - // using (var treeViewControl = new TreeViewControl()) - // { - // var assessmentSection = mocks.Stub(); - // var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); - // failureMechanism.WaveConditionsCalculationGroup.Children.Add(mocks.Stub()); - // var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - // failureMechanism, - // assessmentSection); + [Test] + public void ContextMenuStrip_WithoutParentNodeWithChildren_RemoveAllChildrenEnabled() + { + // Setup + using (var treeViewControl = new TreeViewControl()) + { + var assessmentSection = mocks.Stub(); + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + failureMechanism.WaveConditionsCalculationGroup.Children.Add(mocks.Stub()); + var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, + failureMechanism, + assessmentSection); - // var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - // var gui = mocks.Stub(); - // gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - // gui.Stub(cmp => cmp.ViewCommands).Return(mocks.Stub()); + var gui = mocks.Stub(); + gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(cmp => cmp.ViewCommands).Return(mocks.Stub()); - // mocks.ReplayAll(); + mocks.ReplayAll(); - // plugin.Gui = gui; + plugin.Gui = gui; - // // Call - // using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - // { - // // Assert - // ToolStripItem removeAllItemEnabled = contextMenu.Items[customOnlyContextMenuRemoveAllChildrenIndex]; - // Assert.IsTrue(removeAllItemEnabled.Enabled); - // Assert.AreEqual(RingtoetsCommonFormsResources.CalculationGroup_RemoveAllChildrenFromGroup_Remove_all_Tooltip, removeAllItemEnabled.ToolTipText); - // } - // } - //} + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + ToolStripItem removeAllItemEnabled = contextMenu.Items[customOnlyContextMenuRemoveAllChildrenIndex]; + Assert.IsTrue(removeAllItemEnabled.Enabled); + Assert.AreEqual("Verwijder alle berekeningen en mappen binnen deze map.", removeAllItemEnabled.ToolTipText); + } + } + } [Test] public void ContextMenuStrip_ClickOnAddGroupItem_AddGroupToCalculationGroupAndNotifyObservers() @@ -1142,11 +1140,11 @@ failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(group, - failureMechanism, - assessmentSection); + failureMechanism, + assessmentSection); var parentNodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - failureMechanism, - assessmentSection); + failureMechanism, + assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); @@ -1185,99 +1183,97 @@ } } - // TODO WTI-819 - //[Test] - //public void ContextMenuStrip_ClickOnRemoveAllInGroupAndConfirm_RemovesAllChildren() - //{ - // // Setup - // using (var treeViewControl = new TreeViewControl()) - // { - // var assessmentSection = mocks.Stub(); - // var calculation = mocks.Stub(); - // var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); - // failureMechanism.WaveConditionsCalculationGroup.Children.Add(calculation); - // var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - // failureMechanism, - // assessmentSection); + [Test] + public void ContextMenuStrip_ClickOnRemoveAllInGroupAndConfirm_RemovesAllChildren() + { + // Setup + using (var treeViewControl = new TreeViewControl()) + { + var assessmentSection = mocks.Stub(); + var calculation = mocks.Stub(); + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + failureMechanism.WaveConditionsCalculationGroup.Children.Add(calculation); + var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, + failureMechanism, + assessmentSection); - // var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - // var viewCommandsMock = mocks.StrictMock(); - // viewCommandsMock.Expect(vc => vc.RemoveAllViewsForItem(calculation)); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + var viewCommandsMock = mocks.StrictMock(); + viewCommandsMock.Expect(vc => vc.RemoveAllViewsForItem(calculation)); - // var observer = mocks.StrictMock(); - // observer.Expect(o => o.UpdateObserver()); - // failureMechanism.WaveConditionsCalculationGroup.Attach(observer); + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + failureMechanism.WaveConditionsCalculationGroup.Attach(observer); - // var gui = mocks.Stub(); - // gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - // gui.Stub(cmp => cmp.ViewCommands).Return(viewCommandsMock); + var gui = mocks.Stub(); + gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(cmp => cmp.ViewCommands).Return(viewCommandsMock); - // mocks.ReplayAll(); + mocks.ReplayAll(); - // plugin.Gui = gui; + plugin.Gui = gui; - // DialogBoxHandler = (name, wnd) => - // { - // var dialog = new MessageBoxTester(wnd); - // dialog.ClickOk(); - // }; + DialogBoxHandler = (name, wnd) => + { + var dialog = new MessageBoxTester(wnd); + dialog.ClickOk(); + }; - // using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - // { - // // Call - // contextMenu.Items[contextMenuRemoveAllInGroup].PerformClick(); + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Call + contextMenu.Items[contextMenuRemoveAllInGroup].PerformClick(); - // // Assert - // Assert.IsEmpty(failureMechanism.WaveConditionsCalculationGroup.Children); - // } - // } - //} + // Assert + Assert.IsEmpty(failureMechanism.WaveConditionsCalculationGroup.Children); + } + } + } - // TODO WTI-819 - //[Test] - //public void ContextMenuStrip_ClickOnRemoveAllInGroupAndCancel_ChildrenNotRemoved() - //{ - // // Setup - // using (var treeViewControl = new TreeViewControl()) - // { - // var assessmentSection = mocks.Stub(); - // var calculation = mocks.Stub(); - // var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); - // failureMechanism.WaveConditionsCalculationGroup.Children.Add(calculation); - // var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - // failureMechanism, - // assessmentSection); + [Test] + public void ContextMenuStrip_ClickOnRemoveAllInGroupAndCancel_ChildrenNotRemoved() + { + // Setup + using (var treeViewControl = new TreeViewControl()) + { + var assessmentSection = mocks.Stub(); + var calculation = mocks.Stub(); + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + failureMechanism.WaveConditionsCalculationGroup.Children.Add(calculation); + var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, + failureMechanism, + assessmentSection); - // var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - // var viewCommandsMock = mocks.StrictMock(); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + var viewCommandsMock = mocks.StrictMock(); - // var gui = mocks.Stub(); - // gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - // gui.Stub(cmp => cmp.ViewCommands).Return(viewCommandsMock); + var gui = mocks.Stub(); + gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(cmp => cmp.ViewCommands).Return(viewCommandsMock); - // mocks.ReplayAll(); + mocks.ReplayAll(); - // plugin.Gui = gui; + plugin.Gui = gui; - // DialogBoxHandler = (name, wnd) => - // { - // var dialog = new MessageBoxTester(wnd); - // dialog.ClickCancel(); - // }; + DialogBoxHandler = (name, wnd) => + { + var dialog = new MessageBoxTester(wnd); + dialog.ClickCancel(); + }; - // using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - // { - // // Call - // contextMenu.Items[contextMenuRemoveAllInGroup].PerformClick(); + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Call + contextMenu.Items[contextMenuRemoveAllInGroup].PerformClick(); - // // Assert - // Assert.AreEqual(new[] - // { - // calculation - // }, failureMechanism.WaveConditionsCalculationGroup.Children); - // } - // } - //} + // Assert + Assert.AreEqual(new[] + { + calculation + }, failureMechanism.WaveConditionsCalculationGroup.Children); + } + } + } // TODO WTI-808 //[Test] @@ -1342,7 +1338,7 @@ // } //} - // TODO WTI-819 + // TODO WTI-808 //[Test] //public void GivenDialogGenerateCalculationButtonClicked_WhenCancelButtonClickedAndDialogClosed_ThenCalculationGroupNotUpdated() //{ @@ -1416,13 +1412,13 @@ var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(group, - failureMechanism, - assessmentSection); + failureMechanism, + assessmentSection); failureMechanism.WaveConditionsCalculationGroup.Children.Add(group); var parentNodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - failureMechanism, - assessmentSection); + failureMechanism, + assessmentSection); parentNodeData.Attach(observer); // Precondition @@ -1435,109 +1431,107 @@ CollectionAssert.DoesNotContain(failureMechanism.WaveConditionsCalculationGroup.Children, group); } - // TODO WTI-819 - //[Test] - //public void GivenCalculationWithoutOutput_ThenClearOutputItemDisabled() - //{ - // // Given - // var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); - // var assessmentSection = mocks.Stub(); + [Test] + public void GivenCalculationWithoutOutput_ThenClearOutputItemDisabled() + { + // Given + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var assessmentSection = mocks.Stub(); - // var context = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - // failureMechanism, - // assessmentSection); + var context = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, + failureMechanism, + assessmentSection); - // using (var treeViewControl = new TreeViewControl()) - // { - // var appFeatureCommandHandler = mocks.Stub(); - // var importHandler = mocks.Stub(); - // var exportHandler = mocks.Stub(); - // var viewCommands = mocks.Stub(); - // var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, - // importHandler, - // exportHandler, - // viewCommands, - // context, - // treeViewControl); + using (var treeViewControl = new TreeViewControl()) + { + var appFeatureCommandHandler = mocks.Stub(); + var importHandler = mocks.Stub(); + var exportHandler = mocks.Stub(); + var viewCommands = mocks.Stub(); + var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, + importHandler, + exportHandler, + viewCommands, + context, + treeViewControl); - // var gui = mocks.Stub(); - // gui.Stub(g => g.ViewCommands).Return(viewCommands); - // gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilderMock); + var gui = mocks.Stub(); + gui.Stub(g => g.ViewCommands).Return(viewCommands); + gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilderMock); - // mocks.ReplayAll(); + mocks.ReplayAll(); - // plugin.Gui = gui; + plugin.Gui = gui; - // // When - // using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) - // { - // // Then - // TestHelper.AssertContextMenuStripContainsItem(contextMenu, - // contextMenuAddCalculationIndexRootGroup, - // "Berekening &toevoegen", - // "Voeg een nieuwe berekening toe aan deze berekeningsmap.", - // RingtoetsCommonFormsResources.FailureMechanismIcon); - // } - // } - //} + // When + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) + { + // Then + TestHelper.AssertContextMenuStripContainsItem(contextMenu, + contextMenuAddCalculationIndexRootGroup, + "Berekening &toevoegen", + "Voeg een nieuwe berekening toe aan deze berekeningsmap.", + RingtoetsCommonFormsResources.FailureMechanismIcon); + } + } + } - // TODO WTI-819 - //[Test] - //public void GivenCalculationWithOutput_WhenClearingOutput_ThenClearOutput() - //{ - // // Given - // var observer = mocks.Stub(); - // observer.Expect(o => o.UpdateObserver()); + [Test] + public void GivenCalculationWithOutput_WhenClearingOutput_ThenClearOutput() + { + // Given + var observer = mocks.Stub(); + observer.Expect(o => o.UpdateObserver()); - // var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); - // failureMechanism.WaveConditionsCalculationGroup.Attach(observer); - // var assessmentSection = mocks.Stub(); + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + failureMechanism.WaveConditionsCalculationGroup.Attach(observer); + var assessmentSection = mocks.Stub(); - // var context = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - // failureMechanism, - // assessmentSection); + var context = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, + failureMechanism, + assessmentSection); - // using (var treeViewControl = new TreeViewControl()) - // { - // var appFeatureCommandHandler = mocks.Stub(); - // var importHandler = mocks.Stub(); - // var exportHandler = mocks.Stub(); - // var viewCommands = mocks.Stub(); - // var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, - // importHandler, - // exportHandler, - // viewCommands, - // context, - // treeViewControl); + using (var treeViewControl = new TreeViewControl()) + { + var appFeatureCommandHandler = mocks.Stub(); + var importHandler = mocks.Stub(); + var exportHandler = mocks.Stub(); + var viewCommands = mocks.Stub(); + var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, + importHandler, + exportHandler, + viewCommands, + context, + treeViewControl); - // var gui = mocks.Stub(); - // gui.Stub(g => g.ViewCommands).Return(viewCommands); - // gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilderMock); + var gui = mocks.Stub(); + gui.Stub(g => g.ViewCommands).Return(viewCommands); + gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilderMock); - // mocks.ReplayAll(); + mocks.ReplayAll(); - // plugin.Gui = gui; + plugin.Gui = gui; - // using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) - // { - // // Precondition - // TestHelper.AssertContextMenuStripContainsItem(contextMenu, - // contextMenuAddCalculationIndexRootGroup, - // "Berekening &toevoegen", - // "Voeg een nieuwe berekening toe aan deze berekeningsmap.", - // RingtoetsCommonFormsResources.FailureMechanismIcon); + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) + { + // Precondition + TestHelper.AssertContextMenuStripContainsItem(contextMenu, + contextMenuAddCalculationIndexRootGroup, + "Berekening &toevoegen", + "Voeg een nieuwe berekening toe aan deze berekeningsmap.", + RingtoetsCommonFormsResources.FailureMechanismIcon); - // // When - // ToolStripItem validateMenuItem = contextMenu.Items[contextMenuAddCalculationIndexRootGroup]; - // validateMenuItem.PerformClick(); + // When + ToolStripItem validateMenuItem = contextMenu.Items[contextMenuAddCalculationIndexRootGroup]; + validateMenuItem.PerformClick(); - // // Then - // Assert.AreEqual(1, failureMechanism.WaveConditionsCalculationGroup.Children.Count); - // Assert.IsInstanceOf(failureMechanism.WaveConditionsCalculationGroup.Children[0]); - // // Check expectancies in TearDown() - // } - // } - //} + // Then + Assert.AreEqual(1, failureMechanism.WaveConditionsCalculationGroup.Children.Count); + Assert.IsInstanceOf(failureMechanism.WaveConditionsCalculationGroup.Children[0]); + // Check expectancies in TearDown() + } + } + } private static WaveImpactAsphaltCoverWaveConditionsCalculation GetValidCalculation() { @@ -1550,13 +1544,13 @@ UseForeshore = true, UseBreakWater = true, StepSize = WaveConditionsInputStepSize.Half, - LowerBoundaryRevetment = (RoundedDouble)4, - UpperBoundaryRevetment = (RoundedDouble)10, - UpperBoundaryWaterLevels = (RoundedDouble)8, - LowerBoundaryWaterLevels = (RoundedDouble)7.1 + LowerBoundaryRevetment = (RoundedDouble) 4, + UpperBoundaryRevetment = (RoundedDouble) 10, + UpperBoundaryWaterLevels = (RoundedDouble) 8, + LowerBoundaryWaterLevels = (RoundedDouble) 7.1 } }; - calculation.InputParameters.HydraulicBoundaryLocation.DesignWaterLevel = (RoundedDouble)9.3; + calculation.InputParameters.HydraulicBoundaryLocation.DesignWaterLevel = (RoundedDouble) 9.3; return calculation; } Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationInputContextTreeNodeInfoTest.cs =================================================================== diff -u --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationInputContextTreeNodeInfoTest.cs (revision 0) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationInputContextTreeNodeInfoTest.cs (revision 0d7efa62d16c64a925c63172e4d1bf1a4e0bf94f) @@ -0,0 +1,168 @@ +// 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.Revetment.Data; +using Ringtoets.WaveImpactAsphaltCover.Data; +using Ringtoets.WaveImpactAsphaltCover.Forms.PresentationObjects; +using Ringtoets.WaveImpactAsphaltCover.Plugin; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.WaveImpactAsphaltCover.Forms.Test.TreeNodeInfos +{ + [TestFixture] + public class WaveImpactAsphaltCoverWaveConditionsCalculationInputContextTreeNodeInfoTest + { + private MockRepository mocks; + + [SetUp] + public void SetUp() + { + mocks = new MockRepository(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Setup + using (var plugin = new WaveImpactAsphaltCoverPlugin()) + { + var info = GetInfo(plugin); + + // Assert + 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); + Assert.IsNull(info.ChildNodeObjects); + Assert.IsNull(info.ForeColor); + } + } + + [Test] + + public void Text_Always_ReturnName() + { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var input = new WaveConditionsInput(); + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var context = new WaveImpactAsphaltCoverWaveConditionsCalculationInputContext(input, + failureMechanism, + assessmentSection); + + using (var plugin = new WaveImpactAsphaltCoverPlugin()) + { + var info = GetInfo(plugin); + + // Call + string nodeText = info.Text(context); + + // Assert + Assert.AreEqual("Invoer", nodeText); + } + } + + [Test] + public void Image_Always_ReturnOutputIcon() + { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var input = new WaveConditionsInput(); + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var context = new WaveImpactAsphaltCoverWaveConditionsCalculationInputContext(input, + failureMechanism, + assessmentSection); + using (var plugin = new WaveImpactAsphaltCoverPlugin()) + { + var info = GetInfo(plugin); + + // Call + Image icon = info.Image(context); + + // Assert + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, icon); + } + } + + [Test] + public void ContextMenuStrip_FailureMechanismIsRelevant_CallsContextMenuBuilderMethods() + { + // Setup + using (var treeViewControl = new TreeViewControl()) + { + var assessmentSection = mocks.Stub(); + + var input = new WaveConditionsInput(); + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var context = new WaveImpactAsphaltCoverWaveConditionsCalculationInputContext(input, + failureMechanism, + assessmentSection); + + var menuBuilder = mocks.StrictMock(); + menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.Build()).Return(null); + + var gui = mocks.StrictMock(); + gui.Expect(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilder); + + mocks.ReplayAll(); + + using (var plugin = new WaveImpactAsphaltCoverPlugin()) + { + var info = GetInfo(plugin); + plugin.Gui = gui; + + // Call + info.ContextMenuStrip(context, null, treeViewControl); + } + } + + // Assert + // Assert expectancies are called in TearDown() + } + + private TreeNodeInfo GetInfo(WaveImpactAsphaltCoverPlugin plugin) + { + return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(WaveImpactAsphaltCoverWaveConditionsCalculationInputContext)); + } + } +} \ No newline at end of file Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsOutputTreeNodeInfoTest.cs =================================================================== diff -u --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsOutputTreeNodeInfoTest.cs (revision 0) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsOutputTreeNodeInfoTest.cs (revision 0d7efa62d16c64a925c63172e4d1bf1a4e0bf94f) @@ -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.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.Revetment.Data; +using Ringtoets.WaveImpactAsphaltCover.Data; +using Ringtoets.WaveImpactAsphaltCover.Plugin; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.WaveImpactAsphaltCover.Forms.Test.TreeNodeInfos +{ + [TestFixture] + public class WaveImpactAsphaltCoverWaveConditionsOutputTreeNodeInfoTest + { + private MockRepository mocks; + + [SetUp] + public void SetUp() + { + mocks = new MockRepository(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Setup + using (var plugin = new WaveImpactAsphaltCoverPlugin()) + { + var info = GetInfo(plugin); + + // Assert + 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); + Assert.IsNull(info.ChildNodeObjects); + Assert.IsNull(info.ForeColor); + } + } + + [Test] + public void Text_Always_ReturnName() + { + // Setup + var output = new WaveImpactAsphaltCoverWaveConditionsOutput(Enumerable.Empty()); + + using (var plugin = new WaveImpactAsphaltCoverPlugin()) + { + var info = GetInfo(plugin); + + // Call + string nodeText = info.Text(output); + + // Assert + Assert.AreEqual("Resultaat", nodeText); + } + } + + [Test] + public void Image_Always_ReturnOutputIcon() + { + // Setup + var output = new WaveImpactAsphaltCoverWaveConditionsOutput(Enumerable.Empty()); + + using (var plugin = new WaveImpactAsphaltCoverPlugin()) + { + var info = GetInfo(plugin); + + // Call + Image icon = info.Image(output); + + // Assert + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GeneralOutputIcon, icon); + } + } + + [Test] + public void ContextMenuStrip_FailureMechanismIsRelevant_CallsContextMenuBuilderMethods() + { + // Setup + using (var treeViewControl = new TreeViewControl()) + { + var output = new WaveImpactAsphaltCoverWaveConditionsOutput(Enumerable.Empty()); + + var menuBuilder = mocks.StrictMock(); + menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.Build()).Return(null); + + var gui = mocks.StrictMock(); + gui.Expect(cmp => cmp.Get(output, treeViewControl)).Return(menuBuilder); + + mocks.ReplayAll(); + + using (var plugin = new WaveImpactAsphaltCoverPlugin()) + { + var info = GetInfo(plugin); + plugin.Gui = gui; + + // Call + info.ContextMenuStrip(output, null, treeViewControl); + } + } + + // Assert + // Assert expectancies are called in TearDown() + } + + private TreeNodeInfo GetInfo(WaveImpactAsphaltCoverPlugin plugin) + { + return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(WaveImpactAsphaltCoverWaveConditionsOutput)); + } + } +} \ No newline at end of file Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Plugin.Test/WaveImpactAsphaltCoverPluginTest.cs =================================================================== diff -u -r047a56dd0274ea50de6f06ebad47fbe75ba86ba5 -r0d7efa62d16c64a925c63172e4d1bf1a4e0bf94f --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Plugin.Test/WaveImpactAsphaltCoverPluginTest.cs (.../WaveImpactAsphaltCoverPluginTest.cs) (revision 047a56dd0274ea50de6f06ebad47fbe75ba86ba5) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Plugin.Test/WaveImpactAsphaltCoverPluginTest.cs (.../WaveImpactAsphaltCoverPluginTest.cs) (revision 0d7efa62d16c64a925c63172e4d1bf1a4e0bf94f) @@ -98,11 +98,14 @@ TreeNodeInfo[] treeNodeInfos = plugin.GetTreeNodeInfos().ToArray(); // Assert - Assert.AreEqual(4, treeNodeInfos.Length); + Assert.AreEqual(7, treeNodeInfos.Length); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(WaveImpactAsphaltCoverFailureMechanismContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(WaveImpactAsphaltCoverWaveConditionsCalculationContext))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(WaveImpactAsphaltCoverWaveConditionsCalculationInputContext))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(EmptyWaveImpactAsphaltCoverOutput))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(WaveImpactAsphaltCoverWaveConditionsOutput))); } } }