Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/TreeNodeInfos/HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -rc2f37ea8bfc69b7faf9ceb42adab29b658599af9 -r01e8d3f7c86b2cc7e52606d71e97bd40431a2b25 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/TreeNodeInfos/HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision c2f37ea8bfc69b7faf9ceb42adab29b658599af9) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/TreeNodeInfos/HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision 01e8d3f7c86b2cc7e52606d71e97bd40431a2b25) @@ -1325,7 +1325,7 @@ } [Test] - public void GivenCalculationWithStructureWithoutOutput_WhenStructureChangedAndUpdateClicked_ThenNoInquiryAndCalculationUpdatedAndInputObserverNotified() + public void GivenCalculationWithoutOutputAndWithInputOutOfSync_WhenUpdateStructuresClicked_ThenNoInquiryAndCalculationUpdatedAndInputObserverNotified() { // Given var assessmentSection = mocks.Stub(); @@ -1373,7 +1373,7 @@ } [Test] - public void GivenCalculationWithStructureWithOutput_WhenStructureChangedAndUpdateClickedAndCancelled_ThenInquiryAndCalculationNotUpdatedAndObserversNotNotified() + public void GivenCalculationWithOutputAndInputInSync_WhenUpdateStructuresClicked_ThenNoInquiryAndCalculationNotUpdatedAndObserversNotNotified() { // Given var assessmentSection = mocks.Stub(); @@ -1398,6 +1398,53 @@ var calculationObserver = mocks.StrictMock(); calculation.Attach(calculationObserver); + using (var treeViewControl = new TreeViewControl()) + { + var mainWindow = mocks.Stub(); + guiStub.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + guiStub.Stub(g => g.MainWindow).Return(mainWindow); + mocks.ReplayAll(); + + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, assessmentSection, treeViewControl)) + { + // When + menu.Items[contextMenuUpdateStructureAllIndexRootGroup].PerformClick(); + + // Then + Assert.IsTrue(calculation.HasOutput); + Assert.IsTrue(calculation.InputParameters.IsStructureInputSynchronized); + + // Note: observer assertions are verified in the TearDown() + } + } + } + + [Test] + public void GivenCalculationWithOutputAndInputOutOfSync_WhenUpdateStructuresClickedAndCancelled_ThenInquiryAndCalculationNotUpdatedAndObserversNotNotified() + { + // Given + var assessmentSection = mocks.Stub(); + var structure = new TestHeightStructure(); + var calculation = new StructuresCalculation + { + InputParameters = + { + Structure = structure + }, + Output = new TestStructuresOutput() + }; + + var failureMechanism = new HeightStructuresFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(calculation); + + var nodeData = new HeightStructuresCalculationGroupContext(failureMechanism.CalculationsGroup, failureMechanism, assessmentSection); + + var inputObserver = mocks.StrictMock(); + calculation.InputParameters.Attach(inputObserver); + + var calculationObserver = mocks.StrictMock(); + calculation.Attach(calculationObserver); + string textBoxMessage = null; DialogBoxHandler = (name, wnd) => { @@ -1434,7 +1481,7 @@ } [Test] - public void GivenCalculationWithStructureWithOutput_WhenStructureChangedAndUpdateStructureClickedAndContinued_ThenInquiryAndUpdatesCalculationAndObserversNotified() + public void GivenCalculationWithOutputAndInputOutOfSync_WhenUpdateStructuresClickedAndContinued_ThenInquiryAndUpdatesCalculationAndObserversNotified() { // Given var assessmentSection = mocks.Stub();