Index: Riskeer/ClosingStructures/src/Riskeer.ClosingStructures.Plugin/ClosingStructuresPlugin.cs =================================================================== diff -u -r4fe11c4a270a7e56254082366223320f86d0f6c0 -r9c88e0dae51cb591f71c556ecf69348af38ffba0 --- Riskeer/ClosingStructures/src/Riskeer.ClosingStructures.Plugin/ClosingStructuresPlugin.cs (.../ClosingStructuresPlugin.cs) (revision 4fe11c4a270a7e56254082366223320f86d0f6c0) +++ Riskeer/ClosingStructures/src/Riskeer.ClosingStructures.Plugin/ClosingStructuresPlugin.cs (.../ClosingStructuresPlugin.cs) (revision 9c88e0dae51cb591f71c556ecf69348af38ffba0) @@ -283,28 +283,25 @@ private static bool CloseClosingStructuresFailureMechanismViewForData(ClosingStructuresFailureMechanismView view, object data) { - var assessmentSection = data as IAssessmentSection; var failureMechanism = data as ClosingStructuresFailureMechanism; - return assessmentSection != null + return data is IAssessmentSection assessmentSection ? ReferenceEquals(view.AssessmentSection, assessmentSection) : ReferenceEquals(view.FailureMechanism, failureMechanism); } private static bool CloseFailureMechanismResultViewForData(ClosingStructuresFailureMechanismResultView view, object o) { - var assessmentSection = o as IAssessmentSection; - var failureMechanism = o as ClosingStructuresFailureMechanism; - var failureMechanismContext = o as IFailureMechanismContext; - if (assessmentSection != null) + if (o is IAssessmentSection assessmentSection) { return assessmentSection .GetFailureMechanisms() .OfType() .Any(fm => ReferenceEquals(view.FailureMechanism.SectionResults, fm.SectionResults)); } - if (failureMechanismContext != null) + var failureMechanism = o as ClosingStructuresFailureMechanism; + if (o is IFailureMechanismContext failureMechanismContext) { failureMechanism = failureMechanismContext.WrappedData; } @@ -725,18 +722,22 @@ object parentData, TreeViewControl treeViewControl) { - StructuresCalculation calculation = context.WrappedData; + StructuresCalculationScenario calculation = context.WrappedData; var changeHandler = new ClearIllustrationPointsOfStructuresCalculationHandler(GetInquiryHelper(), calculation); + IInquiryHelper inquiryHelper = GetInquiryHelper(); + IViewCommands viewCommands = Gui.ViewCommands; + var builder = new RiskeerContextMenuBuilder(Gui.Get(context, treeViewControl)); return builder.AddExportItem() .AddSeparator() .AddDuplicateCalculationItem(calculation, context) .AddSeparator() .AddRenameItem() - .AddUpdateForeshoreProfileOfCalculationItem(calculation, - GetInquiryHelper(), - SynchronizeCalculationWithForeshoreProfileHelper.UpdateForeshoreProfileDerivedCalculationInput) + .AddUpdateForeshoreProfileOfCalculationItem( + calculation, + inquiryHelper, + SynchronizeCalculationWithForeshoreProfileHelper.UpdateForeshoreProfileDerivedCalculationInput) .AddCustomItem(CreateUpdateStructureItem(context)) .AddSeparator() .AddValidateCalculationItem( @@ -748,7 +749,12 @@ Calculate, EnableValidateAndCalculateMenuItemForCalculation) .AddSeparator() - .AddClearCalculationOutputItem(calculation) + .AddClearCalculationOutputItem( + () => calculation.HasOutput, + CreateClearCalculationOutputChangeHandler(new[] + { + calculation + }, inquiryHelper, viewCommands)) .AddClearIllustrationPointsOfCalculationItem(() => IllustrationPointsHelper.HasIllustrationPoints(calculation), changeHandler) .AddDeleteItem() .AddSeparator() Index: Riskeer/ClosingStructures/test/Riskeer.ClosingStructures.Plugin.Test/TreeNodeInfos/ClosingStructuresCalculationScenarioContextTreeNodeInfoTest.cs =================================================================== diff -u -rf4359dde195c85255ac1aa2373710dc709f65a56 -r9c88e0dae51cb591f71c556ecf69348af38ffba0 --- Riskeer/ClosingStructures/test/Riskeer.ClosingStructures.Plugin.Test/TreeNodeInfos/ClosingStructuresCalculationScenarioContextTreeNodeInfoTest.cs (.../ClosingStructuresCalculationScenarioContextTreeNodeInfoTest.cs) (revision f4359dde195c85255ac1aa2373710dc709f65a56) +++ Riskeer/ClosingStructures/test/Riskeer.ClosingStructures.Plugin.Test/TreeNodeInfos/ClosingStructuresCalculationScenarioContextTreeNodeInfoTest.cs (.../ClosingStructuresCalculationScenarioContextTreeNodeInfoTest.cs) (revision 9c88e0dae51cb591f71c556ecf69348af38ffba0) @@ -27,6 +27,7 @@ using Core.Common.Base; using Core.Common.Controls.TreeView; using Core.Common.Gui; +using Core.Common.Gui.Commands; using Core.Common.Gui.ContextMenu; using Core.Common.Gui.Forms.MainWindow; using Core.Common.Gui.TestUtil.ContextMenu; @@ -184,8 +185,9 @@ using (var treeViewControl = new TreeViewControl()) { - gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.ViewCommands).Return(mocks.Stub()); mocks.ReplayAll(); // Call @@ -220,8 +222,9 @@ using (var treeViewControl = new TreeViewControl()) { - gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.ViewCommands).Return(mocks.Stub()); mocks.ReplayAll(); // Call @@ -286,8 +289,9 @@ using (var treeViewControl = new TreeViewControl()) { - gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.ViewCommands).Return(mocks.Stub()); mocks.ReplayAll(); // Call @@ -324,8 +328,9 @@ using (var treeViewControl = new TreeViewControl()) { - gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.ViewCommands).Return(mocks.Stub()); mocks.ReplayAll(); // Call @@ -364,8 +369,9 @@ using (var treeViewControl = new TreeViewControl()) { - gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.ViewCommands).Return(mocks.Stub()); mocks.ReplayAll(); // Call @@ -407,9 +413,9 @@ 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); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.ViewCommands).Return(mocks.Stub()); mocks.ReplayAll(); ChangeStructure(structure); @@ -463,9 +469,9 @@ 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); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.ViewCommands).Return(mocks.Stub()); mocks.ReplayAll(); ChangeStructure(structure); @@ -524,9 +530,9 @@ 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); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.ViewCommands).Return(mocks.Stub()); mocks.ReplayAll(); ChangeStructure(structure); @@ -561,8 +567,9 @@ using (var treeViewControl = new TreeViewControl()) { - gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); - gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.ViewCommands).Return(mocks.Stub()); mocks.ReplayAll(); // Call @@ -596,8 +603,9 @@ using (var treeViewControl = new TreeViewControl()) { - gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); - gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.ViewCommands).Return(mocks.Stub()); mocks.ReplayAll(); // Call @@ -644,8 +652,9 @@ using (var treeViewControl = new TreeViewControl()) { - gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); - gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.ViewCommands).Return(mocks.Stub()); mocks.ReplayAll(); // Call @@ -681,8 +690,9 @@ using (var treeViewControl = new TreeViewControl()) { - gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); - gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.ViewCommands).Return(mocks.Stub()); mocks.ReplayAll(); plugin.Gui = gui; @@ -724,8 +734,9 @@ using (var treeViewControl = new TreeViewControl()) { - gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); - gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.ViewCommands).Return(mocks.Stub()); mocks.ReplayAll(); plugin.Gui = gui; @@ -770,8 +781,9 @@ using (var treeViewControl = new TreeViewControl()) { - gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); - gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.ViewCommands).Return(mocks.Stub()); mocks.ReplayAll(); plugin.Gui = gui; @@ -821,7 +833,8 @@ using (var treeViewControl = new TreeViewControl()) { gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); - gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.ViewCommands).Return(mocks.Stub()); mocks.ReplayAll(); plugin.Gui = gui; @@ -897,7 +910,8 @@ using (var treeViewControl = new TreeViewControl()) { gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); - gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.ViewCommands).Return(mocks.Stub()); mocks.ReplayAll(); plugin.Gui = gui; @@ -928,7 +942,6 @@ public void GivenValidCalculation_WhenCalculatingFromContextMenu_ThenOutputSetLogMessagesAddedAndUpdateObserver() { // Given - var mainWindow = mocks.Stub(); var observer = mocks.StrictMock(); observer.Expect(o => o.UpdateObserver()); @@ -965,7 +978,8 @@ using (var treeViewControl = new TreeViewControl()) { gui.Stub(g => g.Get(calculationContext, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); - gui.Stub(g => g.MainWindow).Return(mainWindow); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.ViewCommands).Return(mocks.Stub()); var calculatorFactory = mocks.Stub(); calculatorFactory.Expect(cf => cf.CreateStructuresCalculator( @@ -1050,7 +1064,8 @@ using (var treeViewControl = new TreeViewControl()) { gui.Stub(g => g.Get(calculationContext, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); - gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.ViewCommands).Return(mocks.Stub()); mocks.ReplayAll(); using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(calculationContext, null, treeViewControl)) @@ -1071,6 +1086,169 @@ } [Test] + public void ContextMenuStrip_CalculationGroupWithCalculationsWithoutOutput_ContextMenuItemClearCalculationsOutputEnabled() + { + // Setup + var calculation = new StructuresCalculationScenario + { + Output = new TestStructuresOutput() + }; + + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(null, mocks, "invalidFilePath"); + + var nodeData = new ClosingStructuresCalculationScenarioContext( + calculation, new CalculationGroup(), new ClosingStructuresFailureMechanism(), assessmentSection); + + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + using (var treeViewControl = new TreeViewControl()) + { + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.ViewCommands).Return(mocks.Stub()); + mocks.ReplayAll(); + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Call + ToolStripItem toolStripItem = contextMenu.Items[contextMenuClearIndex]; + + // Assert + Assert.IsTrue(toolStripItem.Enabled); + } + } + } + + [Test] + public void ContextMenuStrip_CalculationGroupWithCalculationsWithoutOutput_ContextMenuItemClearCalculationsOutputDisabled() + { + // Setup + var calculation = new StructuresCalculationScenario(); + + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(null, mocks, "invalidFilePath"); + + var nodeData = new ClosingStructuresCalculationScenarioContext( + calculation, new CalculationGroup(), new ClosingStructuresFailureMechanism(), assessmentSection); + + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + using (var treeViewControl = new TreeViewControl()) + { + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.ViewCommands).Return(mocks.Stub()); + mocks.ReplayAll(); + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Call + ToolStripItem toolStripItem = contextMenu.Items[contextMenuClearIndex]; + + // Assert + Assert.IsFalse(toolStripItem.Enabled); + } + } + } + + [Test] + public void GivenCalculationsWithOutput_WhenClearAllCalculationsOutputClickedAndAborted_ThenInquiryAndCalculationsOutputNotCleared() + { + // Given + var calculation = new StructuresCalculationScenario + { + Output = new TestStructuresOutput() + }; + + var calculationObserver = mocks.StrictMock(); + calculation.Attach(calculationObserver); + + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(null, mocks, "invalidFilePath"); + + var nodeData = new ClosingStructuresCalculationScenarioContext( + calculation, new CalculationGroup(), new ClosingStructuresFailureMechanism(), assessmentSection); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + var messageBoxText = ""; + DialogBoxHandler = (name, wnd) => + { + var helper = new MessageBoxTester(wnd); + messageBoxText = helper.Text; + + helper.ClickCancel(); + }; + + using (var treeViewControl = new TreeViewControl()) + { + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.ViewCommands).Return(mocks.StrictMock()); + mocks.ReplayAll(); + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // When + contextMenu.Items[contextMenuClearIndex].PerformClick(); + + // Then + Assert.AreEqual("Weet u zeker dat u de uitvoer van deze berekening wilt wissen?", messageBoxText); + + Assert.IsTrue(calculation.HasOutput); + } + } + } + + [Test] + public void GivenCalculationsWithOutput_WhenClearAllCalculationsOutputClickedAndContinued_ThenInquiryAndOutputViewsClosedAndCalculationsOutputCleared() + { + // Given + var calculation = new StructuresCalculationScenario + { + Output = new TestStructuresOutput() + }; + + var calculationObserver = mocks.StrictMock(); + calculationObserver.Expect(o => o.UpdateObserver()); + calculation.Attach(calculationObserver); + + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(null, mocks, "invalidFilePath"); + + var nodeData = new ClosingStructuresCalculationScenarioContext( + calculation, new CalculationGroup(), new ClosingStructuresFailureMechanism(), assessmentSection); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + var messageBoxText = ""; + DialogBoxHandler = (name, wnd) => + { + var helper = new MessageBoxTester(wnd); + messageBoxText = helper.Text; + + helper.ClickOk(); + }; + + using (var treeViewControl = new TreeViewControl()) + { + var viewCommands = mocks.StrictMock(); + viewCommands.Expect(vc => vc.RemoveAllViewsForItem(calculation.Output)); + + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.ViewCommands).Return(viewCommands); + mocks.ReplayAll(); + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // When + contextMenu.Items[contextMenuClearIndex].PerformClick(); + + // Then + Assert.AreEqual("Weet u zeker dat u de uitvoer van deze berekening wilt wissen?", messageBoxText); + + Assert.IsFalse(calculation.HasOutput); + } + } + } + + [Test] public void ContextMenuStrip_CalculationWithIllustrationPoints_ContextMenuItemClearIllustrationPointsEnabled() { // Setup @@ -1087,8 +1265,9 @@ using (var treeViewControl = new TreeViewControl()) { - gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.ViewCommands).Return(mocks.Stub()); mocks.ReplayAll(); using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, assessmentSection, treeViewControl)) @@ -1119,8 +1298,9 @@ using (var treeViewControl = new TreeViewControl()) { - gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.ViewCommands).Return(mocks.Stub()); mocks.ReplayAll(); using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, assessmentSection, treeViewControl)) @@ -1163,8 +1343,9 @@ using (var treeViewControl = new TreeViewControl()) { - gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.ViewCommands).Return(mocks.Stub()); mocks.ReplayAll(); using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, assessmentSection, treeViewControl)) @@ -1209,8 +1390,9 @@ using (var treeViewControl = new TreeViewControl()) { - gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.ViewCommands).Return(mocks.Stub()); mocks.ReplayAll(); using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, assessmentSection, treeViewControl))