Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/CalculationTreeNodeInfoFactoryTest.cs =================================================================== diff -u -r2dfa240103a7c54e4dde46bbb64357a51c27173e -r623084c4429d7818397e4e27e58cfbb4f22c06d5 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/CalculationTreeNodeInfoFactoryTest.cs (.../CalculationTreeNodeInfoFactoryTest.cs) (revision 2dfa240103a7c54e4dde46bbb64357a51c27173e) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/CalculationTreeNodeInfoFactoryTest.cs (.../CalculationTreeNodeInfoFactoryTest.cs) (revision 623084c4429d7818397e4e27e58cfbb4f22c06d5) @@ -191,17 +191,17 @@ var exportImportHandler = mocks.Stub(); var viewCommandsHandler = mocks.StrictMock(); var treeViewControl = mocks.StrictMock(); - var calculationWithOutput = mocks.StrictMock(); + var calculationWithoutOutput = mocks.StrictMock(); - calculationWithOutput.Expect(c => c.HasOutput).Return(false); + calculationWithoutOutput.Expect(c => c.HasOutput).Return(false); mocks.ReplayAll(); var calculationGroup = new CalculationGroup { Children = { - calculationWithOutput + calculationWithoutOutput } }; @@ -335,6 +335,99 @@ mocks.VerifyAll(); } + [Test] + public void AddPerformAllCalculationsInGroupItem_GroupWithCalculations_CreatesDecoratedAndEnabledPerformItem() + { + // Setup + var mocks = new MockRepository(); + var applicationFeatureCommandHandler = mocks.Stub(); + var exportImportHandler = mocks.Stub(); + var viewCommandsHandler = mocks.StrictMock(); + var treeViewControl = mocks.StrictMock(); + var calculation = mocks.StrictMock(); + + mocks.ReplayAll(); + + var calculationGroup = new CalculationGroup + { + Children = + { + calculation + } + }; + + var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler, exportImportHandler, viewCommandsHandler, calculationGroup, treeViewControl); + + // Call + CalculationTreeNodeInfoFactory.AddPerformAllCalculationsInGroupItem(menuBuilder, calculationGroup, null); + + // Assert + TestHelper.AssertContextMenuStripContainsItem(menuBuilder.Build(), 0, + RingtoetsFormsResources.Calculate_all, + RingtoetsFormsResources.CalculationGroup_CalculateAll_ToolTip, + RingtoetsFormsResources.CalculateAllIcon); + } + + [Test] + public void AddPerformAllCalculationsInGroupItem_GroupWithoutCalculations_CreatesDecoratedAndDisabledPerformItem() + { + // Setup + var mocks = new MockRepository(); + var applicationFeatureCommandHandler = mocks.Stub(); + var exportImportHandler = mocks.Stub(); + var viewCommandsHandler = mocks.StrictMock(); + var treeViewControl = mocks.StrictMock(); + + mocks.ReplayAll(); + + var calculationGroup = new CalculationGroup(); + var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler, exportImportHandler, viewCommandsHandler, calculationGroup, treeViewControl); + + // Call + CalculationTreeNodeInfoFactory.AddPerformAllCalculationsInGroupItem(menuBuilder, calculationGroup, null); + + // Assert + TestHelper.AssertContextMenuStripContainsItem(menuBuilder.Build(), 0, + RingtoetsFormsResources.Calculate_all, + RingtoetsFormsResources.CalculationGroup_CalculateAll_No_calculations_to_run, + RingtoetsFormsResources.CalculateAllIcon, + false); + } + + [Test] + public void AddPerformAllCalculationsInGroupItem_PerformClickOnCreatedItem_PerformAllCalculationMethodPerformed() + { + // Setup + var mocks = new MockRepository(); + var applicationFeatureCommandHandler = mocks.Stub(); + var exportImportHandler = mocks.Stub(); + var viewCommandsHandler = mocks.StrictMock(); + var treeViewControl = mocks.StrictMock(); + var calculation = mocks.StrictMock(); + + mocks.ReplayAll(); + + var counter = 0; + var calculationGroup = new CalculationGroup + { + Children = + { + calculation + } + }; + + var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler, exportImportHandler, viewCommandsHandler, calculationGroup, treeViewControl); + + CalculationTreeNodeInfoFactory.AddPerformAllCalculationsInGroupItem(menuBuilder, calculationGroup, context => counter++); + var contextMenuItem = menuBuilder.Build().Items[0]; + + // Call + contextMenuItem.PerformClick(); + + // Assert + Assert.AreEqual(1, counter); + } + # region CreateCalculationGroupContextTreeNodeInfo [Test]