Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/TreeNodeInfos/ClosingStructuresCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -r8dc7980c928c8e808007aa66dacaa01ee6fe47fb -r25b0a55f2aeac2edab0cd8b002309a63971e1db4 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/TreeNodeInfos/ClosingStructuresCalculationContextTreeNodeInfoTest.cs (.../ClosingStructuresCalculationContextTreeNodeInfoTest.cs) (revision 8dc7980c928c8e808007aa66dacaa01ee6fe47fb) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/TreeNodeInfos/ClosingStructuresCalculationContextTreeNodeInfoTest.cs (.../ClosingStructuresCalculationContextTreeNodeInfoTest.cs) (revision 25b0a55f2aeac2edab0cd8b002309a63971e1db4) @@ -714,25 +714,49 @@ } [Test] - [Combinatorial] - public void ContextMenuStripm_ForeshoreProfileStates_CreatesExpectedItem( - [Values(true, false)] bool hasForeshoreProfile, - [Values(true, false)] bool isSynchronized) + public void ContextMenuStrip_CalculationWithoutForeshoreProfile_ContextMenuItemUpdateForeshoreProfileDisabledAndToolTipSet() { // Setup var assessmentSection = mocks.Stub(); var failureMechanism = new TestClosingStructuresFailureMechanism(); var calculation = new StructuresCalculation(); - if (hasForeshoreProfile) + var nodeData = new ClosingStructuresCalculationContext(calculation, + failureMechanism, + assessmentSection); + + using (var treeViewControl = new TreeViewControl()) { - calculation.InputParameters.ForeshoreProfile = new TestForeshoreProfile(); - if (!isSynchronized) + gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { - calculation.InputParameters.UseBreakWater = true; + // Assert + TestHelper.AssertContextMenuStripContainsItem( + menu, + contextMenuUpdateForeshoreProfileIndex, + "&Bijwerken voorlandprofiel...", + "Er moet een voorlandprofiel geselecteerd zijn.", + RingtoetsCommonFormsResources.UpdateItemIcon, + false); } } + } + [Test] + public void ContextMenuStrip_CalculationWithForeshoreProfileAndInputInSync_ContextMenuItemUpdateForeshoreProfileDisabledAndToolTipSet() + { + // Setup + var assessmentSection = mocks.Stub(); + var failureMechanism = new TestClosingStructuresFailureMechanism(); + var calculation = new StructuresCalculation(); + calculation.InputParameters.ForeshoreProfile = new TestForeshoreProfile(); + var nodeData = new ClosingStructuresCalculationContext(calculation, failureMechanism, assessmentSection); @@ -749,43 +773,56 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // Assert - if (hasForeshoreProfile) - { - if (isSynchronized) - { - TestHelper.AssertContextMenuStripContainsItem( - menu, - contextMenuUpdateForeshoreProfileIndex, - "&Bijwerken voorlandprofiel...", - "Er zijn geen wijzigingen om bij te werken.", - RingtoetsCommonFormsResources.UpdateItemIcon, - false); - } - else - { - TestHelper.AssertContextMenuStripContainsItem( - menu, - contextMenuUpdateForeshoreProfileIndex, - "&Bijwerken voorlandprofiel...", - "Berekening bijwerken met het voorlandprofiel.", - RingtoetsCommonFormsResources.UpdateItemIcon); - } - } - else - { - TestHelper.AssertContextMenuStripContainsItem( - menu, - contextMenuUpdateForeshoreProfileIndex, - "&Bijwerken voorlandprofiel...", - "Er moet een voorlandprofiel geselecteerd zijn.", - RingtoetsCommonFormsResources.UpdateItemIcon, - false); - } + TestHelper.AssertContextMenuStripContainsItem( + menu, + contextMenuUpdateForeshoreProfileIndex, + "&Bijwerken voorlandprofiel...", + "Er zijn geen wijzigingen om bij te werken.", + RingtoetsCommonFormsResources.UpdateItemIcon, + false); } } } [Test] + public void ContextMenuStrip_CalculationWithForeshoreProfileAndInputOutSync_ContextMenuItemUpdateForeshoreProfileDisabledAndToolTipSet() + { + // Setup + var assessmentSection = mocks.Stub(); + var failureMechanism = new TestClosingStructuresFailureMechanism(); + + var foreshoreProfileInput = new TestForeshoreProfile(); + var calculation = new StructuresCalculation(); + calculation.InputParameters.ForeshoreProfile = foreshoreProfileInput; + TestForeshoreProfile.ModifyForeshoreProfileProperties(foreshoreProfileInput); + + var nodeData = new ClosingStructuresCalculationContext(calculation, + failureMechanism, + assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem( + menu, + contextMenuUpdateForeshoreProfileIndex, + "&Bijwerken voorlandprofiel...", + "Berekening bijwerken met het voorlandprofiel.", + RingtoetsCommonFormsResources.UpdateItemIcon); + } + } + } + + [Test] public void GivenCalculationWithoutOutputAndWithInputOutOfSync_WhenUpdateForeshoreProfileClicked_ThenNoInquiryAndCalculationUpdatedAndInputObserverNotified() { // Given @@ -796,11 +833,12 @@ var assessmentSectionStub = mocks.Stub(); var failureMechanism = new TestClosingStructuresFailureMechanism(); + var foreshoreProfileInput = new TestForeshoreProfile(true); var calculation = new StructuresCalculation { InputParameters = { - ForeshoreProfile = new TestForeshoreProfile(true) + ForeshoreProfile = foreshoreProfileInput } }; var nodeData = new ClosingStructuresCalculationContext(calculation, @@ -818,8 +856,11 @@ plugin.Gui = gui; - calculation.InputParameters.UseBreakWater = false; + TestForeshoreProfile.ModifyForeshoreProfileProperties(foreshoreProfileInput); + // Precondition + Assert.IsFalse(calculation.InputParameters.IsForeshoreProfileInputSynchronized); + using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // When @@ -842,11 +883,12 @@ var assessmentSectionStub = mocks.Stub(); var failureMechanism = new TestClosingStructuresFailureMechanism(); + var foreshoreProfileInput = new TestForeshoreProfile(true); var calculation = new StructuresCalculation { InputParameters = { - ForeshoreProfile = new TestForeshoreProfile(true) + ForeshoreProfile = foreshoreProfileInput }, Output = new TestStructuresOutput() }; @@ -888,15 +930,18 @@ plugin.Gui = gui; - calculation.InputParameters.UseBreakWater = false; + TestForeshoreProfile.ModifyForeshoreProfileProperties(foreshoreProfileInput); + // Precondition + Assert.IsFalse(calculation.InputParameters.IsForeshoreProfileInputSynchronized); + using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // When contextMenuStrip.Items[contextMenuUpdateForeshoreProfileIndex].PerformClick(); // Then - Assert.AreEqual(continuation, calculation.InputParameters.UseBreakWater); + Assert.AreEqual(continuation, calculation.InputParameters.IsForeshoreProfileInputSynchronized); Assert.AreEqual(!continuation, calculation.HasOutput); } } Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/ForeshoreProfilePermutationHelperTest.cs =================================================================== diff -u -r5b29217fb2099ab005ad86d9f53dbd8369210372 -r25b0a55f2aeac2edab0cd8b002309a63971e1db4 --- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/ForeshoreProfilePermutationHelperTest.cs (.../ForeshoreProfilePermutationHelperTest.cs) (revision 5b29217fb2099ab005ad86d9f53dbd8369210372) +++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/ForeshoreProfilePermutationHelperTest.cs (.../ForeshoreProfilePermutationHelperTest.cs) (revision 25b0a55f2aeac2edab0cd8b002309a63971e1db4) @@ -30,7 +30,7 @@ public class ForeshoreProfilePermutationHelperTest { [Test] - public void DifferentForeshoreProfileWithSameIdNameAndX0_ReturnsExpectedTestCaseData() + public void DifferentForeshoreProfilesWithSameIdNameAndX0_ReturnsExpectedTestCaseData() { // Setup const string targetName = "C"; @@ -48,7 +48,7 @@ } [Test] - public void DifferentForeshoreProfileWithSameIdNameOrientationAndX0_ReturnsExpectedTestCaseData() + public void DifferentForeshoreProfilesWithSameIdNameOrientationAndX0_ReturnsExpectedTestCaseData() { // Setup const string targetName = "C"; Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/TestForeshoreProfileTest.cs =================================================================== diff -u -r6678115bc8c06dcc0b676429038e1839b128d6f2 -r25b0a55f2aeac2edab0cd8b002309a63971e1db4 --- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/TestForeshoreProfileTest.cs (.../TestForeshoreProfileTest.cs) (revision 6678115bc8c06dcc0b676429038e1839b128d6f2) +++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/TestForeshoreProfileTest.cs (.../TestForeshoreProfileTest.cs) (revision 25b0a55f2aeac2edab0cd8b002309a63971e1db4) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using Core.Common.Base.Geometry; using NUnit.Framework; using Ringtoets.Common.Data.DikeProfiles; @@ -168,7 +169,7 @@ Assert.AreEqual(0.0, profile.Orientation.Value); Assert.AreEqual(new Point2D(0, 0), profile.WorldReferencePoint); } - + [Test] public void Constructor_WithGeometryAndId_ReturnsExpectedForeshoreProfileProperties() { @@ -193,5 +194,42 @@ Assert.AreEqual(0.0, profile.Orientation.Value); Assert.AreEqual(new Point2D(0, 0), profile.WorldReferencePoint); } + + [Test] + public void ChangeForeshoreProfile_ForeshoreProfileNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => TestForeshoreProfile.ModifyForeshoreProfileProperties(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("foreshoreProfile", exception.ParamName); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void ChangeForeshoreProfile_ForeshoreProfileHasBreakWater_ChangesProperties(bool hasBreakWater) + { + // Setup + TestForeshoreProfile profile = hasBreakWater + ? new TestForeshoreProfile( + new BreakWater(BreakWaterType.Caisson, + 12.34)) + : new TestForeshoreProfile("WithoutBreakWater"); + + // Call + TestForeshoreProfile.ModifyForeshoreProfileProperties(profile); + + // Assert + if (hasBreakWater) + { + Assert.IsNull(profile.BreakWater); + } + else + { + Assert.IsNotNull(profile.BreakWater); + } + } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/TestForeshoreProfile.cs =================================================================== diff -u -r48e2db6c910f4ec279d2d63fbb1cc05a1196b7f1 -r25b0a55f2aeac2edab0cd8b002309a63971e1db4 --- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/TestForeshoreProfile.cs (.../TestForeshoreProfile.cs) (revision 48e2db6c910f4ec279d2d63fbb1cc05a1196b7f1) +++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/TestForeshoreProfile.cs (.../TestForeshoreProfile.cs) (revision 25b0a55f2aeac2edab0cd8b002309a63971e1db4) @@ -128,5 +128,31 @@ Id = profileId, Name = profileName }) {} + + /// + /// Modifies some properties of the current instance of the foreshore profile + /// to different values. + /// + /// The current instance of which the properties which + /// need to be modified. + /// Thrown when + /// is null. + public static void ModifyForeshoreProfileProperties(TestForeshoreProfile foreshoreProfile) + { + if (foreshoreProfile == null) + { + throw new ArgumentNullException(nameof(foreshoreProfile)); + } + + BreakWater differentBreakWater = null; + if (!foreshoreProfile.HasBreakWater) + { + differentBreakWater = new BreakWater(BreakWaterType.Caisson, 12.34); + } + + var foreshoreProfileToUpdateFrom = new TestForeshoreProfile(differentBreakWater); + + foreshoreProfile.CopyProperties(foreshoreProfileToUpdateFrom); + } } } \ No newline at end of file Fisheye: Tag 25b0a55f2aeac2edab0cd8b002309a63971e1db4 refers to a dead (removed) revision in file `Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Helpers/SynchronizeCalculationWithForeshoreProfileHelperTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj =================================================================== diff -u -r72c1ce6bda4b00156c3f07cf69cb0377825dcb5e -r25b0a55f2aeac2edab0cd8b002309a63971e1db4 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision 72c1ce6bda4b00156c3f07cf69cb0377825dcb5e) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision 25b0a55f2aeac2edab0cd8b002309a63971e1db4) @@ -73,7 +73,6 @@ - Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuItemFactoryTest.cs =================================================================== diff -u -r3d95e2d4d19772aab17604346c7a6def74bb1192 -r25b0a55f2aeac2edab0cd8b002309a63971e1db4 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuItemFactoryTest.cs (.../RingtoetsContextMenuItemFactoryTest.cs) (revision 3d95e2d4d19772aab17604346c7a6def74bb1192) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuItemFactoryTest.cs (.../RingtoetsContextMenuItemFactoryTest.cs) (revision 25b0a55f2aeac2edab0cd8b002309a63971e1db4) @@ -101,7 +101,7 @@ var calculationGroupContext = new TestCalculationGroupContext(calculationGroup, failureMechanismMock); // Call - StrictContextMenuItem toolStripItem = RingtoetsContextMenuItemFactory.CreateAddCalculationItem(calculationGroupContext, context => {}); + StrictContextMenuItem toolStripItem = RingtoetsContextMenuItemFactory.CreateAddCalculationItem(calculationGroupContext, context => { }); // Assert Assert.AreEqual("Berekening &toevoegen", toolStripItem.Text); @@ -599,64 +599,76 @@ #region CreateUpdateForeshoreProfileOfCalculationItem [Test] - [Combinatorial] - public void CreateUpdateForeshoreProfileOfCalculationItem_ForeshoreProfileStates_CreatesExpectedItem( - [Values(true, false)] bool hasForeshoreProfile, - [Values(true, false)] bool isSynchronized) + public void CreateUpdateForeshoreProfileOfCalculationItem_NoForeshoreProfile_CreatesExpectedItem() { // Setup var mocks = new MockRepository(); var calculation = mocks.StrictMock>(); var input = mocks.StrictMock(); + input.Expect(ci => ci.ForeshoreProfile).Return(null); - if (hasForeshoreProfile) - { - input.Expect(ci => ci.ForeshoreProfile).Return(new TestForeshoreProfile()); - input.Expect(ci => ci.IsForeshoreProfileInputSynchronized).Return(isSynchronized); - } - else - { - input.Expect(ci => ci.ForeshoreProfile).Return(null); - } + calculation.Expect(c => c.InputParameters).Return(input).Repeat.Any(); + var inquiryHelper = mocks.StrictMock(); + mocks.ReplayAll(); + // Call + StrictContextMenuItem toolStripItem = RingtoetsContextMenuItemFactory.CreateUpdateForeshoreProfileOfCalculationItem( + calculation, + inquiryHelper, c => { }); + + // Assert + Assert.AreEqual("&Bijwerken voorlandprofiel...", toolStripItem.Text); + TestHelper.AssertImagesAreEqual(RingtoetsFormsResources.UpdateItemIcon, toolStripItem.Image); + + Assert.AreEqual("Er moet een voorlandprofiel geselecteerd zijn.", toolStripItem.ToolTipText); + Assert.IsFalse(toolStripItem.Enabled); + + mocks.VerifyAll(); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void CreateUpdateForeshoreProfileOfCalculationItem_ForeshoreProfileIsSynchronizedStates_CreatesExpectedItem(bool isSynchronized) + { + // Setup + var mocks = new MockRepository(); + var calculation = mocks.StrictMock>(); + var input = mocks.StrictMock(); + + input.Expect(ci => ci.ForeshoreProfile).Return(new TestForeshoreProfile()); + input.Expect(ci => ci.IsForeshoreProfileInputSynchronized).Return(isSynchronized); + calculation.Expect(c => c.InputParameters).Return(input).Repeat.Any(); var inquiryHelper = mocks.StrictMock(); mocks.ReplayAll(); // Call StrictContextMenuItem toolStripItem = RingtoetsContextMenuItemFactory.CreateUpdateForeshoreProfileOfCalculationItem( calculation, - inquiryHelper, c => {}); + inquiryHelper, c => { }); // Assert Assert.AreEqual("&Bijwerken voorlandprofiel...", toolStripItem.Text); TestHelper.AssertImagesAreEqual(RingtoetsFormsResources.UpdateItemIcon, toolStripItem.Image); - if (hasForeshoreProfile) + if (isSynchronized) { - if (isSynchronized) - { - Assert.AreEqual("Er zijn geen wijzigingen om bij te werken.", toolStripItem.ToolTipText); - Assert.IsFalse(toolStripItem.Enabled); - } - else - { - Assert.AreEqual("Berekening bijwerken met het voorlandprofiel.", toolStripItem.ToolTipText); - Assert.IsTrue(toolStripItem.Enabled); - } + Assert.AreEqual("Er zijn geen wijzigingen om bij te werken.", toolStripItem.ToolTipText); + Assert.IsFalse(toolStripItem.Enabled); } else { - Assert.AreEqual("Er moet een voorlandprofiel geselecteerd zijn.", toolStripItem.ToolTipText); - Assert.IsFalse(toolStripItem.Enabled); + Assert.AreEqual("Berekening bijwerken met het voorlandprofiel.", toolStripItem.ToolTipText); + Assert.IsTrue(toolStripItem.Enabled); } mocks.VerifyAll(); } [Test] [Combinatorial] - public void CreateUpdateForeshoreProfileOfCalculationItem_WithVariousOutputPerformClick_ExpectedAction( + public void CreateUpdateForeshoreProfileOfCalculationItem_WithForeshoreProfileAndVariousOutputPerformClick_ExpectedAction( [Values(true, false)] bool hasOutput, [Values(true, false)] bool continuation) { @@ -742,7 +754,7 @@ { calculation }, - inquiryHelper, c => {}); + inquiryHelper, c => { }); // Assert Assert.AreEqual("&Bijwerken voorlandprofielen...", toolStripItem.Text); Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/Ringtoets.Common.Service.Test.csproj =================================================================== diff -u -r1010d4569cd91ef8661e423e01f833e932180fd4 -r25b0a55f2aeac2edab0cd8b002309a63971e1db4 --- Ringtoets/Common/test/Ringtoets.Common.Service.Test/Ringtoets.Common.Service.Test.csproj (.../Ringtoets.Common.Service.Test.csproj) (revision 1010d4569cd91ef8661e423e01f833e932180fd4) +++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/Ringtoets.Common.Service.Test.csproj (.../Ringtoets.Common.Service.Test.csproj) (revision 25b0a55f2aeac2edab0cd8b002309a63971e1db4) @@ -71,6 +71,7 @@ + Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/SynchronizeCalculationWithForeshoreProfileHelperTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Service.Test/SynchronizeCalculationWithForeshoreProfileHelperTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/SynchronizeCalculationWithForeshoreProfileHelperTest.cs (revision 25b0a55f2aeac2edab0cd8b002309a63971e1db4) @@ -0,0 +1,82 @@ +// Copyright (C) Stichting Deltares 2017. 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 NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.Data.DikeProfiles; + +namespace Ringtoets.Common.Service.Test +{ + [TestFixture] + public class SynchronizeCalculationWithForeshoreProfileHelperTest + { + [Test] + public void UpdateForeshoreProfileDerivedCalculationInput_ForeshoreProfileSynchronized_DoesNotNotifyObservers() + { + // Setup + var mocks = new MockRepository(); + var calculationInput = mocks.StrictMock(); + calculationInput.Expect(ci => ci.IsForeshoreProfileInputSynchronized).Return(true); + + var calculation = mocks.StrictMock>(); + calculation.Stub(c => c.InputParameters).Return(calculationInput); + mocks.ReplayAll(); + + // Call + SynchronizeCalculationWithForeshoreProfileHelper.UpdateForeshoreProfileDerivedCalculationInput(calculation); + + // Assert + mocks.VerifyAll(); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void UpdateForeshoreProfileDerivedCalculationInput_ForeshoreProfileNotSynchronized_NotifyObservers(bool hasOutput) + { + // Setup + var mocks = new MockRepository(); + var calculationInput = mocks.StrictMock(); + calculationInput.Expect(ci => ci.IsForeshoreProfileInputSynchronized).Return(false); + calculationInput.Expect(ci => ci.SynchronizeForeshoreProfileInput()); + calculationInput.Expect(ci => ci.NotifyObservers()); + + var calculation = mocks.StrictMock>(); + calculation.Stub(c => c.InputParameters).Return(calculationInput); + calculation.Expect(c => c.HasOutput).Return(hasOutput); + if (hasOutput) + { + calculation.Expect(c => c.ClearOutput()); + calculation.Expect(c => c.NotifyObservers()); + } + mocks.ReplayAll(); + + // Call + SynchronizeCalculationWithForeshoreProfileHelper.UpdateForeshoreProfileDerivedCalculationInput(calculation); + + // Assert + mocks.VerifyAll(); + } + + public interface ICalculationInputWithForeshoreProfile : ICalculationInput, IHasForeshoreProfile {} + } +} \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -r3d95e2d4d19772aab17604346c7a6def74bb1192 -r25b0a55f2aeac2edab0cd8b002309a63971e1db4 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision 3d95e2d4d19772aab17604346c7a6def74bb1192) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision 25b0a55f2aeac2edab0cd8b002309a63971e1db4) @@ -761,25 +761,50 @@ } [Test] - [Combinatorial] - public void ContextMenuStripm_ForeshoreProfileStates_CreatesExpectedItem( - [Values(true, false)] bool hasForeshoreProfile, - [Values(true, false)] bool isSynchronized) + public void ContextMenuStrip_CalculationWithoutForeshoreProfile_ContextMenuItemUpdateForeshoreProfileDisabledAndToolTipSet() { // Setup var assessmentSection = mocks.Stub(); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); var calculation = new GrassCoverErosionOutwardsWaveConditionsCalculation(); - if (hasForeshoreProfile) + var nodeData = new GrassCoverErosionOutwardsWaveConditionsCalculationContext(calculation, + failureMechanism, + assessmentSection); + + using (var treeViewControl = new TreeViewControl()) { - calculation.InputParameters.ForeshoreProfile = new TestForeshoreProfile(); - if (!isSynchronized) + var gui = mocks.Stub(); + gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { - calculation.InputParameters.UseBreakWater = true; + // Assert + TestHelper.AssertContextMenuStripContainsItem( + menu, + contextMenuUpdateForeshoreProfileIndex, + "&Bijwerken voorlandprofiel...", + "Er moet een voorlandprofiel geselecteerd zijn.", + RingtoetsCommonFormsResources.UpdateItemIcon, + false); } } + } + [Test] + public void ContextMenuStrip_CalculationWithForeshoreProfileAndInputInSync_ContextMenuItemUpdateForeshoreProfileDisabledAndToolTipSet() + { + // Setup + var assessmentSection = mocks.Stub(); + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + var calculation = new GrassCoverErosionOutwardsWaveConditionsCalculation(); + calculation.InputParameters.ForeshoreProfile = new TestForeshoreProfile(); + var nodeData = new GrassCoverErosionOutwardsWaveConditionsCalculationContext(calculation, failureMechanism, assessmentSection); @@ -797,43 +822,57 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // Assert - if (hasForeshoreProfile) - { - if (isSynchronized) - { - TestHelper.AssertContextMenuStripContainsItem( - menu, - contextMenuUpdateForeshoreProfileIndex, - "&Bijwerken voorlandprofiel...", - "Er zijn geen wijzigingen om bij te werken.", - RingtoetsCommonFormsResources.UpdateItemIcon, - false); - } - else - { - TestHelper.AssertContextMenuStripContainsItem( - menu, - contextMenuUpdateForeshoreProfileIndex, - "&Bijwerken voorlandprofiel...", - "Berekening bijwerken met het voorlandprofiel.", - RingtoetsCommonFormsResources.UpdateItemIcon); - } - } - else - { - TestHelper.AssertContextMenuStripContainsItem( - menu, - contextMenuUpdateForeshoreProfileIndex, - "&Bijwerken voorlandprofiel...", - "Er moet een voorlandprofiel geselecteerd zijn.", - RingtoetsCommonFormsResources.UpdateItemIcon, - false); - } + TestHelper.AssertContextMenuStripContainsItem( + menu, + contextMenuUpdateForeshoreProfileIndex, + "&Bijwerken voorlandprofiel...", + "Er zijn geen wijzigingen om bij te werken.", + RingtoetsCommonFormsResources.UpdateItemIcon, + false); } } } [Test] + public void ContextMenuStrip_CalculationWithForeshoreProfileAndInputOutSync_ContextMenuItemUpdateForeshoreProfileDisabledAndToolTipSet() + { + // Setup + var assessmentSection = mocks.Stub(); + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + + var foreshoreProfileInput = new TestForeshoreProfile(); + var calculation = new GrassCoverErosionOutwardsWaveConditionsCalculation(); + calculation.InputParameters.ForeshoreProfile = foreshoreProfileInput; + TestForeshoreProfile.ModifyForeshoreProfileProperties(foreshoreProfileInput); + + var nodeData = new GrassCoverErosionOutwardsWaveConditionsCalculationContext(calculation, + failureMechanism, + assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocks.Stub(); + gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem( + menu, + contextMenuUpdateForeshoreProfileIndex, + "&Bijwerken voorlandprofiel...", + "Berekening bijwerken met het voorlandprofiel.", + RingtoetsCommonFormsResources.UpdateItemIcon); + } + } + } + + [Test] public void GivenCalculationWithoutOutputAndWithInputOutOfSync_WhenUpdateForeshoreProfileClicked_ThenNoInquiryAndCalculationUpdatedAndInputObserverNotified() { // Given @@ -844,11 +883,12 @@ var assessmentSectionStub = mocks.Stub(); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + var foreshoreProfileInput = new TestForeshoreProfile(true); var calculation = new GrassCoverErosionOutwardsWaveConditionsCalculation { InputParameters = { - ForeshoreProfile = new TestForeshoreProfile(true) + ForeshoreProfile = foreshoreProfileInput } }; var nodeData = new GrassCoverErosionOutwardsWaveConditionsCalculationContext(calculation, @@ -867,8 +907,11 @@ plugin.Gui = guiStub; - calculation.InputParameters.UseBreakWater = false; + TestForeshoreProfile.ModifyForeshoreProfileProperties(foreshoreProfileInput); + // Precondition + Assert.IsFalse(calculation.InputParameters.IsForeshoreProfileInputSynchronized); + using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // When @@ -889,15 +932,14 @@ var calculationObserver = mocks.StrictMock(); var calculationInputObserver = mocks.StrictMock(); var assessmentSectionStub = mocks.Stub(); - var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism - { - Contribution = 5 - }; + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + + var foreshoreProfileInput = new TestForeshoreProfile(true); var calculation = new GrassCoverErosionOutwardsWaveConditionsCalculation { InputParameters = { - ForeshoreProfile = new TestForeshoreProfile(true) + ForeshoreProfile = foreshoreProfileInput }, Output = new GrassCoverErosionOutwardsWaveConditionsOutput(Enumerable.Empty()) }; @@ -940,15 +982,18 @@ plugin.Gui = gui; - calculation.InputParameters.UseBreakWater = false; + TestForeshoreProfile.ModifyForeshoreProfileProperties(foreshoreProfileInput); + // Precondition + Assert.IsFalse(calculation.InputParameters.IsForeshoreProfileInputSynchronized); + using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // When contextMenuStrip.Items[contextMenuUpdateForeshoreProfileIndex].PerformClick(); // Then - Assert.AreEqual(continuation, calculation.InputParameters.UseBreakWater); + Assert.AreEqual(continuation, calculation.InputParameters.IsForeshoreProfileInputSynchronized); Assert.AreEqual(!continuation, calculation.HasOutput); } } Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/TreeNodeInfos/HeightStructuresCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -r8dc7980c928c8e808007aa66dacaa01ee6fe47fb -r25b0a55f2aeac2edab0cd8b002309a63971e1db4 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/TreeNodeInfos/HeightStructuresCalculationContextTreeNodeInfoTest.cs (.../HeightStructuresCalculationContextTreeNodeInfoTest.cs) (revision 8dc7980c928c8e808007aa66dacaa01ee6fe47fb) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/TreeNodeInfos/HeightStructuresCalculationContextTreeNodeInfoTest.cs (.../HeightStructuresCalculationContextTreeNodeInfoTest.cs) (revision 25b0a55f2aeac2edab0cd8b002309a63971e1db4) @@ -74,6 +74,15 @@ info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(HeightStructuresCalculationContext)); } + [TearDown] + public override void TearDown() + { + plugin.Dispose(); + mocks.VerifyAll(); + + base.TearDown(); + } + [Test] public void Initialized_Always_ExpectedPropertiesSet() { @@ -857,25 +866,50 @@ } [Test] - [Combinatorial] - public void ContextMenuStripm_ForeshoreProfileStates_CreatesExpectedItem( - [Values(true, false)] bool hasForeshoreProfile, - [Values(true, false)] bool isSynchronized) + public void ContextMenuStrip_CalculationWithoutForeshoreProfile_ContextMenuItemUpdateForeshoreProfileDisabledAndToolTipSet() { // Setup var assessmentSection = mocks.Stub(); var failureMechanism = new TestHeightStructuresFailureMechanism(); var calculation = new StructuresCalculation(); - if (hasForeshoreProfile) + var nodeData = new HeightStructuresCalculationContext(calculation, + failureMechanism, + assessmentSection); + + using (var treeViewControl = new TreeViewControl()) { - calculation.InputParameters.ForeshoreProfile = new TestForeshoreProfile(); - if (!isSynchronized) + var gui = mocks.Stub(); + gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { - calculation.InputParameters.UseBreakWater = true; + // Assert + TestHelper.AssertContextMenuStripContainsItem( + menu, + contextMenuUpdateForeshoreProfileIndex, + "&Bijwerken voorlandprofiel...", + "Er moet een voorlandprofiel geselecteerd zijn.", + RingtoetsCommonFormsResources.UpdateItemIcon, + false); } } + } + [Test] + public void ContextMenuStrip_CalculationWithForeshoreProfileAndInputInSync_ContextMenuItemUpdateForeshoreProfileDisabledAndToolTipSet() + { + // Setup + var assessmentSection = mocks.Stub(); + var failureMechanism = new TestHeightStructuresFailureMechanism(); + var calculation = new StructuresCalculation(); + calculation.InputParameters.ForeshoreProfile = new TestForeshoreProfile(); + var nodeData = new HeightStructuresCalculationContext(calculation, failureMechanism, assessmentSection); @@ -893,43 +927,57 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // Assert - if (hasForeshoreProfile) - { - if (isSynchronized) - { - TestHelper.AssertContextMenuStripContainsItem( - menu, - contextMenuUpdateForeshoreProfileIndex, - "&Bijwerken voorlandprofiel...", - "Er zijn geen wijzigingen om bij te werken.", - RingtoetsCommonFormsResources.UpdateItemIcon, - false); - } - else - { - TestHelper.AssertContextMenuStripContainsItem( - menu, - contextMenuUpdateForeshoreProfileIndex, - "&Bijwerken voorlandprofiel...", - "Berekening bijwerken met het voorlandprofiel.", - RingtoetsCommonFormsResources.UpdateItemIcon); - } - } - else - { - TestHelper.AssertContextMenuStripContainsItem( - menu, - contextMenuUpdateForeshoreProfileIndex, - "&Bijwerken voorlandprofiel...", - "Er moet een voorlandprofiel geselecteerd zijn.", - RingtoetsCommonFormsResources.UpdateItemIcon, - false); - } + TestHelper.AssertContextMenuStripContainsItem( + menu, + contextMenuUpdateForeshoreProfileIndex, + "&Bijwerken voorlandprofiel...", + "Er zijn geen wijzigingen om bij te werken.", + RingtoetsCommonFormsResources.UpdateItemIcon, + false); } } } [Test] + public void ContextMenuStrip_CalculationWithForeshoreProfileAndInputOutSync_ContextMenuItemUpdateForeshoreProfileDisabledAndToolTipSet() + { + // Setup + var assessmentSection = mocks.Stub(); + var failureMechanism = new TestHeightStructuresFailureMechanism(); + + var foreshoreProfileInput = new TestForeshoreProfile(); + var calculation = new StructuresCalculation(); + calculation.InputParameters.ForeshoreProfile = foreshoreProfileInput; + TestForeshoreProfile.ModifyForeshoreProfileProperties(foreshoreProfileInput); + + var nodeData = new HeightStructuresCalculationContext(calculation, + failureMechanism, + assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocks.Stub(); + gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem( + menu, + contextMenuUpdateForeshoreProfileIndex, + "&Bijwerken voorlandprofiel...", + "Berekening bijwerken met het voorlandprofiel.", + RingtoetsCommonFormsResources.UpdateItemIcon); + } + } + } + + [Test] public void GivenCalculationWithoutOutputAndWithInputOutOfSync_WhenUpdateForeshoreProfileClicked_ThenNoInquiryAndCalculationUpdatedAndInputObserverNotified() { // Given @@ -940,11 +988,12 @@ var assessmentSection = mocks.Stub(); var failureMechanism = new HeightStructuresFailureMechanism(); + var foreshoreProfileInput = new TestForeshoreProfile(true); var calculation = new StructuresCalculation { InputParameters = { - ForeshoreProfile = new TestForeshoreProfile(true) + ForeshoreProfile = foreshoreProfileInput } }; var nodeData = new HeightStructuresCalculationContext(calculation, @@ -963,8 +1012,11 @@ plugin.Gui = gui; - calculation.InputParameters.UseBreakWater = false; + TestForeshoreProfile.ModifyForeshoreProfileProperties(foreshoreProfileInput); + // Precondition + Assert.IsFalse(calculation.InputParameters.IsForeshoreProfileInputSynchronized); + using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // When @@ -987,11 +1039,12 @@ var assessmentSectionStub = mocks.Stub(); var failureMechanism = new TestHeightStructuresFailureMechanism(); + var foreshoreProfileInput = new TestForeshoreProfile(true); var calculation = new StructuresCalculation { InputParameters = { - ForeshoreProfile = new TestForeshoreProfile(true) + ForeshoreProfile = foreshoreProfileInput }, Output = new TestStructuresOutput() }; @@ -1034,15 +1087,18 @@ plugin.Gui = gui; - calculation.InputParameters.UseBreakWater = false; + TestForeshoreProfile.ModifyForeshoreProfileProperties(foreshoreProfileInput); + // Precondition + Assert.IsFalse(calculation.InputParameters.IsForeshoreProfileInputSynchronized); + using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // When contextMenuStrip.Items[contextMenuUpdateForeshoreProfileIndex].PerformClick(); // Then - Assert.AreEqual(continuation, calculation.InputParameters.UseBreakWater); + Assert.AreEqual(continuation, calculation.InputParameters.IsForeshoreProfileInputSynchronized); Assert.AreEqual(!continuation, calculation.HasOutput); } } @@ -1268,13 +1324,5 @@ Location = structure.Location })); } - - public override void TearDown() - { - plugin.Dispose(); - mocks.VerifyAll(); - - base.TearDown(); - } } } \ No newline at end of file Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/TreeNodeInfos/StabilityPointStructuresCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -rcb0d03fc7dc4db4769d2ae9dfb9da263172486cb -r25b0a55f2aeac2edab0cd8b002309a63971e1db4 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/TreeNodeInfos/StabilityPointStructuresCalculationContextTreeNodeInfoTest.cs (.../StabilityPointStructuresCalculationContextTreeNodeInfoTest.cs) (revision cb0d03fc7dc4db4769d2ae9dfb9da263172486cb) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/TreeNodeInfos/StabilityPointStructuresCalculationContextTreeNodeInfoTest.cs (.../StabilityPointStructuresCalculationContextTreeNodeInfoTest.cs) (revision 25b0a55f2aeac2edab0cd8b002309a63971e1db4) @@ -689,25 +689,50 @@ } [Test] - [Combinatorial] - public void ContextMenuStrip_ForeshoreProfileStates_CreatesExpectedItem( - [Values(true, false)] bool hasForeshoreProfile, - [Values(true, false)] bool isSynchronized) + public void ContextMenuStrip_CalculationWithoutForeshoreProfile_ContextMenuItemUpdateForeshoreProfileDisabledAndToolTipSet() { // Setup var assessmentSection = mocks.Stub(); var failureMechanism = new TestStabilityPointStructuresFailureMechanism(); var calculation = new StructuresCalculation(); - if (hasForeshoreProfile) + var nodeData = new StabilityPointStructuresCalculationContext(calculation, + failureMechanism, + assessmentSection); + + using (var treeViewControl = new TreeViewControl()) { - calculation.InputParameters.ForeshoreProfile = new TestForeshoreProfile(); - if (!isSynchronized) + var gui = mocks.Stub(); + gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { - calculation.InputParameters.UseBreakWater = true; + // Assert + TestHelper.AssertContextMenuStripContainsItem( + menu, + contextMenuUpdateForeshoreProfileIndex, + "&Bijwerken voorlandprofiel...", + "Er moet een voorlandprofiel geselecteerd zijn.", + RingtoetsCommonFormsResources.UpdateItemIcon, + false); } } + } + [Test] + public void ContextMenuStrip_CalculationWithForeshoreProfileAndInputInSync_ContextMenuItemUpdateForeshoreProfileDisabledAndToolTipSet() + { + // Setup + var assessmentSection = mocks.Stub(); + var failureMechanism = new TestStabilityPointStructuresFailureMechanism(); + var calculation = new StructuresCalculation(); + calculation.InputParameters.ForeshoreProfile = new TestForeshoreProfile(); + var nodeData = new StabilityPointStructuresCalculationContext(calculation, failureMechanism, assessmentSection); @@ -725,43 +750,57 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // Assert - if (hasForeshoreProfile) - { - if (isSynchronized) - { - TestHelper.AssertContextMenuStripContainsItem( - menu, - contextMenuUpdateForeshoreProfileIndex, - "&Bijwerken voorlandprofiel...", - "Er zijn geen wijzigingen om bij te werken.", - RingtoetsCommonFormsResources.UpdateItemIcon, - false); - } - else - { - TestHelper.AssertContextMenuStripContainsItem( - menu, - contextMenuUpdateForeshoreProfileIndex, - "&Bijwerken voorlandprofiel...", - "Berekening bijwerken met het voorlandprofiel.", - RingtoetsCommonFormsResources.UpdateItemIcon); - } - } - else - { - TestHelper.AssertContextMenuStripContainsItem( - menu, - contextMenuUpdateForeshoreProfileIndex, - "&Bijwerken voorlandprofiel...", - "Er moet een voorlandprofiel geselecteerd zijn.", - RingtoetsCommonFormsResources.UpdateItemIcon, - false); - } + TestHelper.AssertContextMenuStripContainsItem( + menu, + contextMenuUpdateForeshoreProfileIndex, + "&Bijwerken voorlandprofiel...", + "Er zijn geen wijzigingen om bij te werken.", + RingtoetsCommonFormsResources.UpdateItemIcon, + false); } } } [Test] + public void ContextMenuStrip_CalculationWithForeshoreProfileAndInputOutSync_ContextMenuItemUpdateForeshoreProfileDisabledAndToolTipSet() + { + // Setup + var assessmentSection = mocks.Stub(); + var failureMechanism = new TestStabilityPointStructuresFailureMechanism(); + + var foreshoreProfileInput = new TestForeshoreProfile(); + var calculation = new StructuresCalculation(); + calculation.InputParameters.ForeshoreProfile = foreshoreProfileInput; + TestForeshoreProfile.ModifyForeshoreProfileProperties(foreshoreProfileInput); + + var nodeData = new StabilityPointStructuresCalculationContext(calculation, + failureMechanism, + assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocks.Stub(); + gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem( + menu, + contextMenuUpdateForeshoreProfileIndex, + "&Bijwerken voorlandprofiel...", + "Berekening bijwerken met het voorlandprofiel.", + RingtoetsCommonFormsResources.UpdateItemIcon); + } + } + } + + [Test] public void GivenCalculationWithoutOutputAndWithInputOutOfSync_WhenUpdateForeshoreProfileClicked_ThenNoInquiryAndCalculationUpdatedAndInputObserverNotified() { // Given @@ -772,11 +811,12 @@ var assessmentSection = mocks.Stub(); var failureMechanism = new TestStabilityPointStructuresFailureMechanism(); + var foreshoreProfileInput = new TestForeshoreProfile(true); var calculation = new StructuresCalculation { InputParameters = { - ForeshoreProfile = new TestForeshoreProfile(true) + ForeshoreProfile = foreshoreProfileInput } }; var nodeData = new StabilityPointStructuresCalculationContext(calculation, @@ -795,8 +835,11 @@ plugin.Gui = gui; - calculation.InputParameters.UseBreakWater = false; + TestForeshoreProfile.ModifyForeshoreProfileProperties(foreshoreProfileInput); + // Precondition + Assert.IsFalse(calculation.InputParameters.IsForeshoreProfileInputSynchronized); + using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // When @@ -819,11 +862,12 @@ var assessmentSectionStub = mocks.Stub(); var failureMechanism = new TestStabilityPointStructuresFailureMechanism(); + var foreshoreProfileInput = new TestForeshoreProfile(true); var calculation = new StructuresCalculation { InputParameters = { - ForeshoreProfile = new TestForeshoreProfile(true) + ForeshoreProfile = foreshoreProfileInput }, Output = new TestStructuresOutput() }; @@ -866,15 +910,18 @@ plugin.Gui = gui; - calculation.InputParameters.UseBreakWater = false; + TestForeshoreProfile.ModifyForeshoreProfileProperties(foreshoreProfileInput); + // Precondition + Assert.IsFalse(calculation.InputParameters.IsForeshoreProfileInputSynchronized); + using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // When contextMenuStrip.Items[contextMenuUpdateForeshoreProfileIndex].PerformClick(); // Then - Assert.AreEqual(continuation, calculation.InputParameters.UseBreakWater); + Assert.AreEqual(continuation, calculation.InputParameters.IsForeshoreProfileInputSynchronized); Assert.AreEqual(!continuation, calculation.HasOutput); } } Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -r3d95e2d4d19772aab17604346c7a6def74bb1192 -r25b0a55f2aeac2edab0cd8b002309a63971e1db4 --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision 3d95e2d4d19772aab17604346c7a6def74bb1192) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision 25b0a55f2aeac2edab0cd8b002309a63971e1db4) @@ -728,25 +728,50 @@ } [Test] - [Combinatorial] - public void ContextMenuStripm_ForeshoreProfileStates_CreatesExpectedItem( - [Values(true, false)] bool hasForeshoreProfile, - [Values(true, false)] bool isSynchronized) + public void ContextMenuStrip_CalculationWithoutForeshoreProfile_ContextMenuItemUpdateForeshoreProfileDisabledAndToolTipSet() { // Setup var assessmentSection = mocks.Stub(); var failureMechanism = new StabilityStoneCoverFailureMechanism(); var calculation = new StabilityStoneCoverWaveConditionsCalculation(); - if (hasForeshoreProfile) + var nodeData = new StabilityStoneCoverWaveConditionsCalculationContext(calculation, + failureMechanism, + assessmentSection); + + using (var treeViewControl = new TreeViewControl()) { - calculation.InputParameters.ForeshoreProfile = new TestForeshoreProfile(); - if (!isSynchronized) + var gui = mocks.Stub(); + gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { - calculation.InputParameters.UseBreakWater = true; + // Assert + TestHelper.AssertContextMenuStripContainsItem( + menu, + contextMenuUpdateForeshoreProfileIndex, + "&Bijwerken voorlandprofiel...", + "Er moet een voorlandprofiel geselecteerd zijn.", + RingtoetsCommonFormsResources.UpdateItemIcon, + false); } } + } + [Test] + public void ContextMenuStrip_CalculationWithForeshoreProfileAndInputInSync_ContextMenuItemUpdateForeshoreProfileDisabledAndToolTipSet() + { + // Setup + var assessmentSection = mocks.Stub(); + var failureMechanism = new StabilityStoneCoverFailureMechanism(); + var calculation = new StabilityStoneCoverWaveConditionsCalculation(); + calculation.InputParameters.ForeshoreProfile = new TestForeshoreProfile(); + var nodeData = new StabilityStoneCoverWaveConditionsCalculationContext(calculation, failureMechanism, assessmentSection); @@ -764,43 +789,57 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // Assert - if (hasForeshoreProfile) - { - if (isSynchronized) - { - TestHelper.AssertContextMenuStripContainsItem( - menu, - contextMenuUpdateForeshoreProfileIndex, - "&Bijwerken voorlandprofiel...", - "Er zijn geen wijzigingen om bij te werken.", - RingtoetsCommonFormsResources.UpdateItemIcon, - false); - } - else - { - TestHelper.AssertContextMenuStripContainsItem( - menu, - contextMenuUpdateForeshoreProfileIndex, - "&Bijwerken voorlandprofiel...", - "Berekening bijwerken met het voorlandprofiel.", - RingtoetsCommonFormsResources.UpdateItemIcon); - } - } - else - { - TestHelper.AssertContextMenuStripContainsItem( - menu, - contextMenuUpdateForeshoreProfileIndex, - "&Bijwerken voorlandprofiel...", - "Er moet een voorlandprofiel geselecteerd zijn.", - RingtoetsCommonFormsResources.UpdateItemIcon, - false); - } + TestHelper.AssertContextMenuStripContainsItem( + menu, + contextMenuUpdateForeshoreProfileIndex, + "&Bijwerken voorlandprofiel...", + "Er zijn geen wijzigingen om bij te werken.", + RingtoetsCommonFormsResources.UpdateItemIcon, + false); } } } [Test] + public void ContextMenuStrip_CalculationWithForeshoreProfileAndInputOutSync_ContextMenuItemUpdateForeshoreProfileDisabledAndToolTipSet() + { + // Setup + var assessmentSection = mocks.Stub(); + var failureMechanism = new StabilityStoneCoverFailureMechanism(); + + var foreshoreProfileInput = new TestForeshoreProfile(); + var calculation = new StabilityStoneCoverWaveConditionsCalculation(); + calculation.InputParameters.ForeshoreProfile = foreshoreProfileInput; + TestForeshoreProfile.ModifyForeshoreProfileProperties(foreshoreProfileInput); + + var nodeData = new StabilityStoneCoverWaveConditionsCalculationContext(calculation, + failureMechanism, + assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocks.Stub(); + gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem( + menu, + contextMenuUpdateForeshoreProfileIndex, + "&Bijwerken voorlandprofiel...", + "Berekening bijwerken met het voorlandprofiel.", + RingtoetsCommonFormsResources.UpdateItemIcon); + } + } + } + + [Test] public void GivenCalculationWithoutOutputAndWithInputOutOfSync_WhenUpdateForeshoreProfileClicked_ThenNoInquiryAndCalculationUpdatedAndInputObserverNotified() { // Given @@ -811,11 +850,12 @@ var assessmentSection = mocks.Stub(); var failureMechanism = new StabilityStoneCoverFailureMechanism(); + var foreshoreProfileInput = new TestForeshoreProfile(true); var calculation = new StabilityStoneCoverWaveConditionsCalculation { InputParameters = { - ForeshoreProfile = new TestForeshoreProfile(true) + ForeshoreProfile = foreshoreProfileInput } }; var nodeData = new StabilityStoneCoverWaveConditionsCalculationContext(calculation, @@ -834,8 +874,11 @@ plugin.Gui = gui; - calculation.InputParameters.UseBreakWater = false; + TestForeshoreProfile.ModifyForeshoreProfileProperties(foreshoreProfileInput); + // Precondition + Assert.IsFalse(calculation.InputParameters.IsForeshoreProfileInputSynchronized); + using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // When @@ -858,11 +901,12 @@ var assessmentSectionStub = mocks.Stub(); var failureMechanism = new StabilityStoneCoverFailureMechanism(); + var foreshoreProfileInput = new TestForeshoreProfile(true); var calculation = new StabilityStoneCoverWaveConditionsCalculation { InputParameters = { - ForeshoreProfile = new TestForeshoreProfile(true) + ForeshoreProfile = foreshoreProfileInput }, Output = new StabilityStoneCoverWaveConditionsOutput(Enumerable.Empty(), Enumerable.Empty()) }; @@ -905,15 +949,18 @@ plugin.Gui = gui; - calculation.InputParameters.UseBreakWater = false; + TestForeshoreProfile.ModifyForeshoreProfileProperties(foreshoreProfileInput); + // Precondition + Assert.IsFalse(calculation.InputParameters.IsForeshoreProfileInputSynchronized); + using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // When contextMenuStrip.Items[contextMenuUpdateForeshoreProfileIndex].PerformClick(); // Then - Assert.AreEqual(continuation, calculation.InputParameters.UseBreakWater); + Assert.AreEqual(continuation, calculation.InputParameters.IsForeshoreProfileInputSynchronized); Assert.AreEqual(!continuation, calculation.HasOutput); } } Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -r3d95e2d4d19772aab17604346c7a6def74bb1192 -r25b0a55f2aeac2edab0cd8b002309a63971e1db4 --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../WaveImpactAsphaltCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision 3d95e2d4d19772aab17604346c7a6def74bb1192) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../WaveImpactAsphaltCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision 25b0a55f2aeac2edab0cd8b002309a63971e1db4) @@ -686,25 +686,50 @@ } [Test] - [Combinatorial] - public void ContextMenuStripm_ForeshoreProfileStates_CreatesExpectedItem( - [Values(true, false)] bool hasForeshoreProfile, - [Values(true, false)] bool isSynchronized) + public void ContextMenuStrip_CalculationWithoutForeshoreProfile_ContextMenuItemUpdateForeshoreProfileDisabledAndToolTipSet() { // Setup var assessmentSection = mocks.Stub(); var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation(); - if (hasForeshoreProfile) + var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationContext(calculation, + failureMechanism, + assessmentSection); + + using (var treeViewControl = new TreeViewControl()) { - calculation.InputParameters.ForeshoreProfile = new TestForeshoreProfile(); - if (!isSynchronized) + var gui = mocks.Stub(); + gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { - calculation.InputParameters.UseBreakWater = true; + // Assert + TestHelper.AssertContextMenuStripContainsItem( + menu, + contextMenuUpdateForeshoreProfileIndex, + "&Bijwerken voorlandprofiel...", + "Er moet een voorlandprofiel geselecteerd zijn.", + RingtoetsCommonFormsResources.UpdateItemIcon, + false); } } + } + [Test] + public void ContextMenuStrip_CalculationWithForeshoreProfileAndInputInSync_ContextMenuItemUpdateForeshoreProfileDisabledAndToolTipSet() + { + // Setup + var assessmentSection = mocks.Stub(); + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation(); + calculation.InputParameters.ForeshoreProfile = new TestForeshoreProfile(); + var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationContext(calculation, failureMechanism, assessmentSection); @@ -722,43 +747,57 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // Assert - if (hasForeshoreProfile) - { - if (isSynchronized) - { - TestHelper.AssertContextMenuStripContainsItem( - menu, - contextMenuUpdateForeshoreProfileIndex, - "&Bijwerken voorlandprofiel...", - "Er zijn geen wijzigingen om bij te werken.", - RingtoetsCommonFormsResources.UpdateItemIcon, - false); - } - else - { - TestHelper.AssertContextMenuStripContainsItem( - menu, - contextMenuUpdateForeshoreProfileIndex, - "&Bijwerken voorlandprofiel...", - "Berekening bijwerken met het voorlandprofiel.", - RingtoetsCommonFormsResources.UpdateItemIcon); - } - } - else - { - TestHelper.AssertContextMenuStripContainsItem( - menu, - contextMenuUpdateForeshoreProfileIndex, - "&Bijwerken voorlandprofiel...", - "Er moet een voorlandprofiel geselecteerd zijn.", - RingtoetsCommonFormsResources.UpdateItemIcon, - false); - } + TestHelper.AssertContextMenuStripContainsItem( + menu, + contextMenuUpdateForeshoreProfileIndex, + "&Bijwerken voorlandprofiel...", + "Er zijn geen wijzigingen om bij te werken.", + RingtoetsCommonFormsResources.UpdateItemIcon, + false); } } } [Test] + public void ContextMenuStrip_CalculationWithForeshoreProfileAndInputOutSync_ContextMenuItemUpdateForeshoreProfileDisabledAndToolTipSet() + { + // Setup + var assessmentSection = mocks.Stub(); + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + + var foreshoreProfileInput = new TestForeshoreProfile(); + var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation(); + calculation.InputParameters.ForeshoreProfile = foreshoreProfileInput; + TestForeshoreProfile.ModifyForeshoreProfileProperties(foreshoreProfileInput); + + var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationContext(calculation, + failureMechanism, + assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocks.Stub(); + gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem( + menu, + contextMenuUpdateForeshoreProfileIndex, + "&Bijwerken voorlandprofiel...", + "Berekening bijwerken met het voorlandprofiel.", + RingtoetsCommonFormsResources.UpdateItemIcon); + } + } + } + + [Test] public void GivenCalculationWithoutOutputAndWithInputOutOfSync_WhenUpdateForeshoreProfileClicked_ThenNoInquiryAndCalculationUpdatedAndInputObserverNotified() { // Given @@ -769,11 +808,12 @@ var assessmentSection = mocks.Stub(); var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var foreshoreProfileInput = new TestForeshoreProfile(true); var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation { InputParameters = { - ForeshoreProfile = new TestForeshoreProfile(true) + ForeshoreProfile = foreshoreProfileInput } }; var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationContext(calculation, @@ -792,8 +832,11 @@ plugin.Gui = gui; - calculation.InputParameters.UseBreakWater = false; + TestForeshoreProfile.ModifyForeshoreProfileProperties(foreshoreProfileInput); + // Precondition + Assert.IsFalse(calculation.InputParameters.IsForeshoreProfileInputSynchronized); + using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // When @@ -816,11 +859,12 @@ var assessmentSectionStub = mocks.Stub(); var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var foreshoreProfileInput = new TestForeshoreProfile(true); var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation { InputParameters = { - ForeshoreProfile = new TestForeshoreProfile(true) + ForeshoreProfile = foreshoreProfileInput }, Output = new WaveImpactAsphaltCoverWaveConditionsOutput(Enumerable.Empty()) }; @@ -863,15 +907,18 @@ plugin.Gui = gui; - calculation.InputParameters.UseBreakWater = false; + TestForeshoreProfile.ModifyForeshoreProfileProperties(foreshoreProfileInput); + // Precondition + Assert.IsFalse(calculation.InputParameters.IsForeshoreProfileInputSynchronized); + using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // When contextMenuStrip.Items[contextMenuUpdateForeshoreProfileIndex].PerformClick(); // Then - Assert.AreEqual(continuation, calculation.InputParameters.UseBreakWater); + Assert.AreEqual(continuation, calculation.InputParameters.IsForeshoreProfileInputSynchronized); Assert.AreEqual(!continuation, calculation.HasOutput); } }