Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingCalculationScenarioContextTreeNodeInfoTest.cs =================================================================== diff -u -rc2f37ea8bfc69b7faf9ceb42adab29b658599af9 -r9ac9793e704fce8e72b49a0575c47ae1628044af --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingCalculationScenarioContextTreeNodeInfoTest.cs (.../PipingCalculationScenarioContextTreeNodeInfoTest.cs) (revision c2f37ea8bfc69b7faf9ceb42adab29b658599af9) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingCalculationScenarioContextTreeNodeInfoTest.cs (.../PipingCalculationScenarioContextTreeNodeInfoTest.cs) (revision 9ac9793e704fce8e72b49a0575c47ae1628044af) @@ -524,7 +524,7 @@ } [Test] - public void GivenCalculationWithSurfaceLineWithoutOutput_WhenSurfaceLineChangedAndUpdateClicked_ThenNoInquiryAndPointsUpdatedAndObserversNotified() + public void GivenCalculationWithoutOutputAndWithInputOutOfSync_WhenUpdateEntryAndExitPointClicked_ThenNoInquiryAndCalculationUpdatedAndInputObserverNotified() { using (var treeViewControl = new TreeViewControl()) { @@ -573,11 +573,70 @@ } [Test] - public void GivenCalculationWithSurfaceLineAndOutput_WhenSurfaceLineChangedAndUpdateClickedAndContinued_ThenPointsUpdatedOutputsRemovedAndObserversNotified() + public void GivenCalculationWithOutputAndInputInSync_WhenUpdateEntryAndExitPointClicked_ThenNoInquiryAndCalculationNotUpdatedAndObserversNotNotified() { using (var treeViewControl = new TreeViewControl()) { // Given + var surfaceLine = new RingtoetsPipingSurfaceLine(); + surfaceLine.SetGeometry(new[] + { + new Point3D(1, 2, 3), + new Point3D(4, 5, 6) + }); + + var calculation = new PipingCalculationScenario(new GeneralPipingInput()) + { + InputParameters = + { + SurfaceLine = surfaceLine + }, + Output = new TestPipingOutput(), + SemiProbabilisticOutput = new TestPipingSemiProbabilisticOutput() + }; + + var pipingFailureMechanism = new TestPipingFailureMechanism(); + var assessmentSection = mocks.Stub(); + var nodeData = new PipingCalculationScenarioContext(calculation, + Enumerable.Empty(), + Enumerable.Empty(), + pipingFailureMechanism, + assessmentSection); + + var inputObserver = mocks.StrictMock(); + calculation.InputParameters.Attach(inputObserver); + + var calculationObserver = mocks.StrictMock(); + calculation.Attach(calculationObserver); + + var mainWindow = mocks.Stub(); + var gui = mocks.Stub(); + gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + gui.Stub(g => g.MainWindow).Return(mainWindow); + mocks.ReplayAll(); + + plugin.Gui = gui; + + using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // When + contextMenuStrip.Items[contextMenuUpdateEntryAndExitPointIndex].PerformClick(); + + // Then + Assert.IsTrue(calculation.HasOutput); + Assert.IsTrue(calculation.InputParameters.IsEntryAndExitPointInputSynchronized); + + // Note: observer assertions are verified in TearDown + } + } + } + + [Test] + public void GivenCalculationWithOutputAndInputOutOfSync_WhenUpdateEntryAndExitPointClickedAndCancelled_ThenInquiryAndCalculationNotUpdatedAndObserversNotNotified() + { + using (var treeViewControl = new TreeViewControl()) + { + // Given RingtoetsPipingSurfaceLine surfaceLine; PipingCalculationScenario calculation; CreateCalculationWithSurfaceLine(out calculation, out surfaceLine); @@ -592,11 +651,9 @@ assessmentSection); var inputObserver = mocks.StrictMock(); - inputObserver.Expect(obs => obs.UpdateObserver()); calculation.InputParameters.Attach(inputObserver); var calculationObserver = mocks.StrictMock(); - calculationObserver.Expect(obs => obs.UpdateObserver()); calculation.Attach(calculationObserver); var mainWindow = mocks.Stub(); @@ -612,7 +669,7 @@ { var helper = new MessageBoxTester(wnd); textBoxMessage = helper.Text; - helper.ClickOk(); + helper.ClickCancel(); }; ChangeSurfaceLine(surfaceLine); @@ -623,8 +680,8 @@ contextMenuStrip.Items[contextMenuUpdateEntryAndExitPointIndex].PerformClick(); // Then - Assert.IsFalse(calculation.HasOutput); - Assert.IsTrue(calculation.InputParameters.IsEntryAndExitPointInputSynchronized); + Assert.IsTrue(calculation.HasOutput); + Assert.IsFalse(calculation.InputParameters.IsEntryAndExitPointInputSynchronized); string expectedMessage = "Als u kiest voor bijwerken, dan wordt het resultaat van deze berekening " + $"verwijderd.{Environment.NewLine}{Environment.NewLine}Weet u zeker dat u wilt doorgaan?"; @@ -636,7 +693,7 @@ } [Test] - public void GivenCalculationWithSurfaceLineAndOutput_WhenSurfaceLineChangedAndUpdateClickedAndCancelled_ThenCalculationNotUpdatedAndObserversNotUpdated() + public void GivenCalculationWithOutputAndInputOutOfSync_WhenUpdateEntryAndExitPointClickedAndContinued_ThenInquiryAndUpdatesCalculationAndObserversNotified() { using (var treeViewControl = new TreeViewControl()) { @@ -655,9 +712,11 @@ assessmentSection); var inputObserver = mocks.StrictMock(); + inputObserver.Expect(obs => obs.UpdateObserver()); calculation.InputParameters.Attach(inputObserver); var calculationObserver = mocks.StrictMock(); + calculationObserver.Expect(obs => obs.UpdateObserver()); calculation.Attach(calculationObserver); var mainWindow = mocks.Stub(); @@ -673,7 +732,7 @@ { var helper = new MessageBoxTester(wnd); textBoxMessage = helper.Text; - helper.ClickCancel(); + helper.ClickOk(); }; ChangeSurfaceLine(surfaceLine); @@ -684,8 +743,8 @@ contextMenuStrip.Items[contextMenuUpdateEntryAndExitPointIndex].PerformClick(); // Then - Assert.IsTrue(calculation.HasOutput); - Assert.IsFalse(calculation.InputParameters.IsEntryAndExitPointInputSynchronized); + Assert.IsFalse(calculation.HasOutput); + Assert.IsTrue(calculation.InputParameters.IsEntryAndExitPointInputSynchronized); string expectedMessage = "Als u kiest voor bijwerken, dan wordt het resultaat van deze berekening " + $"verwijderd.{Environment.NewLine}{Environment.NewLine}Weet u zeker dat u wilt doorgaan?";