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