Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/TreeNodeInfos/ClosingStructuresCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -rc2f37ea8bfc69b7faf9ceb42adab29b658599af9 -r01e8d3f7c86b2cc7e52606d71e97bd40431a2b25 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/TreeNodeInfos/ClosingStructuresCalculationContextTreeNodeInfoTest.cs (.../ClosingStructuresCalculationContextTreeNodeInfoTest.cs) (revision c2f37ea8bfc69b7faf9ceb42adab29b658599af9) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/TreeNodeInfos/ClosingStructuresCalculationContextTreeNodeInfoTest.cs (.../ClosingStructuresCalculationContextTreeNodeInfoTest.cs) (revision 01e8d3f7c86b2cc7e52606d71e97bd40431a2b25) @@ -394,7 +394,7 @@ } [Test] - public void GivenCalculationWithStructureWithoutOutput_WhenStructureAndInputOutOfSyncAndUpdateClicked_ThenNoInquiryAndCalculationUpdatedAndInputObserverNotified() + public void GivenCalculationWithoutOutputAndWithInputOutOfSync_WhenUpdateStructureClicked_ThenNoInquiryAndCalculationUpdatedAndInputObserverNotified() { // Given var assessmentSection = mocks.Stub(); @@ -440,7 +440,7 @@ } [Test] - public void GivenCalculationWithStructureWithOutput_WhenStructureAndInputOutOfSyncAndUpdateClickedAndCancelled_ThenInquiryAndCalculationNotUpdatedAndObserversNotNotified() + public void GivenCalculationWithOutputAndInputInSync_WhenUpdateStructureClicked_ThenNoInquiryAndCalculationNotUpdatedAndObserversNotNotified() { // Given var assessmentSection = mocks.Stub(); @@ -464,6 +464,52 @@ var calculationObserver = mocks.StrictMock(); calculation.Attach(calculationObserver); + using (var treeViewControl = new TreeViewControl()) + { + var mainWindow = mocks.Stub(); + gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + gui.Stub(g => g.MainWindow).Return(mainWindow); + mocks.ReplayAll(); + + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, assessmentSection, treeViewControl)) + { + // When + menu.Items[contextMenuUpdateStructureIndex].PerformClick(); + + // Then + Assert.IsTrue(calculation.HasOutput); + Assert.IsTrue(calculation.InputParameters.IsStructureInputSynchronized); + + // Note: observer assertions are verified in the TearDown() + } + } + } + + [Test] + public void GivenCalculationWithOutputAndInputOutOfSync_WhenUpdateStructureClickedAndCancelled_ThenInquiryAndCalculationNotUpdatedAndObserversNotNotified() + { + // Given + var assessmentSection = mocks.Stub(); + var structure = new TestClosingStructure(); + var calculation = new StructuresCalculation + { + InputParameters = + { + Structure = structure + }, + Output = new TestStructuresOutput() + }; + + ClosingStructuresInput calculationInput = calculation.InputParameters; + var failureMechanism = new ClosingStructuresFailureMechanism(); + var nodeData = new ClosingStructuresCalculationContext(calculation, failureMechanism, assessmentSection); + + var inputObserver = mocks.StrictMock(); + calculationInput.Attach(inputObserver); + + var calculationObserver = mocks.StrictMock(); + calculation.Attach(calculationObserver); + string textBoxMessage = null; DialogBoxHandler = (name, wnd) => { @@ -500,7 +546,7 @@ } [Test] - public void GivenCalculationWithStructureWithOutput_WhenStructureAndInputOutOfSyncAndUpdateClickedAndContinued_ThenInquiryAndUpdatesCalculationAndObserversNotified() + public void GivenCalculationWithOutputAndInputOutOfSync_WhenUpdateStructureClickedAndContinued_ThenInquiryAndUpdatesCalculationAndObserversNotified() { // Given var assessmentSection = mocks.Stub();