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); } }