Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuItemFactoryTest.cs =================================================================== diff -u -rf64dceaa32788bad28dcf09f4a1c3150595f1327 -r776558d53b8a73cf16bdd5b50ff4d1eeff933b2f --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuItemFactoryTest.cs (.../RingtoetsContextMenuItemFactoryTest.cs) (revision f64dceaa32788bad28dcf09f4a1c3150595f1327) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuItemFactoryTest.cs (.../RingtoetsContextMenuItemFactoryTest.cs) (revision 776558d53b8a73cf16bdd5b50ff4d1eeff933b2f) @@ -21,6 +21,7 @@ using System.Linq; using Core.Common.Base; +using Core.Common.Gui.Commands; using Core.Common.Gui.ContextMenu; using Core.Common.TestUtil; using NUnit.Extensions.Forms; @@ -1315,22 +1316,32 @@ public void CreateRemoveAllChildrenFromGroupItem_NoChildren_CreatesDisabledItemWithTooltipSet() { // Setup + var mocks = new MockRepository(); + var viewCommandsMock = mocks.StrictMock(); + mocks.ReplayAll(); + var calculationGroup = new CalculationGroup(); // Call - StrictContextMenuItem toolStripItem = RingtoetsContextMenuItemFactory.CreateRemoveAllChildrenFromGroupItem(calculationGroup); + StrictContextMenuItem toolStripItem = RingtoetsContextMenuItemFactory.CreateRemoveAllChildrenFromGroupItem(calculationGroup, viewCommandsMock); // Assert Assert.AreEqual("Berekeningen map &leegmaken...", toolStripItem.Text); Assert.AreEqual("Er zijn geen berekeningen of mappen om te verwijderen.", toolStripItem.ToolTipText); TestHelper.AssertImagesAreEqual(RingtoetsFormsResources.RemoveAllIcon, toolStripItem.Image); Assert.IsFalse(toolStripItem.Enabled); + + mocks.VerifyAll(); } [Test] public void CreateRemoveAllChildrenFromGroupItem_WithChildren_CreatesEnabledItem() { // Setup + var mocks = new MockRepository(); + var viewCommandsMock = mocks.StrictMock(); + mocks.ReplayAll(); + var calculation = new TestCalculation(); var calculationGroup = new CalculationGroup { @@ -1341,19 +1352,25 @@ }; // Call - StrictContextMenuItem toolStripItem = RingtoetsContextMenuItemFactory.CreateRemoveAllChildrenFromGroupItem(calculationGroup); + StrictContextMenuItem toolStripItem = RingtoetsContextMenuItemFactory.CreateRemoveAllChildrenFromGroupItem(calculationGroup, viewCommandsMock); // Assert Assert.AreEqual("Berekeningen map &leegmaken...", toolStripItem.Text); Assert.AreEqual("Verwijder alle berekeningen en mappen binnen deze Berekeningen map.", toolStripItem.ToolTipText); TestHelper.AssertImagesAreEqual(RingtoetsFormsResources.RemoveAllIcon, toolStripItem.Image); Assert.IsTrue(toolStripItem.Enabled); + + mocks.VerifyAll(); } [Test] public void CreateRemoveAllChildrenFromGroupItem_WithChildrenPerformClickOnCreatedItemAndCancelChange_GroupUnchanged() { // Setup + var mocks = new MockRepository(); + var viewCommandsMock = mocks.StrictMock(); + mocks.ReplayAll(); + var calculation = new TestCalculation(); var calculationGroup = new CalculationGroup { @@ -1363,7 +1380,7 @@ } }; - StrictContextMenuItem toolStripItem = RingtoetsContextMenuItemFactory.CreateRemoveAllChildrenFromGroupItem(calculationGroup); + StrictContextMenuItem toolStripItem = RingtoetsContextMenuItemFactory.CreateRemoveAllChildrenFromGroupItem(calculationGroup, viewCommandsMock); DialogBoxHandler = (name, wnd) => { @@ -1380,22 +1397,36 @@ { calculation }, calculationGroup.Children); + + mocks.VerifyAll(); } [Test] - public void CreateRemoveAllChildrenFromGroupItem_WithChildrenPerformClickOnCreatedItemAndConfirmChange_ClearsGroup() + public void CreateRemoveAllChildrenFromGroupItem_WithNestedChildrenPerformClickOnCreatedItemAndConfirmChange_ClearsGroup() { // Setup var calculation = new TestCalculation(); + + var mocks = new MockRepository(); + var viewCommandsMock = mocks.StrictMock(); + viewCommandsMock.Expect(vc => vc.RemoveAllViewsForItem(calculation)); + mocks.ReplayAll(); + var calculationGroup = new CalculationGroup { Children = { - calculation + new CalculationGroup + { + Children = + { + calculation + } + } } }; - StrictContextMenuItem toolStripItem = RingtoetsContextMenuItemFactory.CreateRemoveAllChildrenFromGroupItem(calculationGroup); + StrictContextMenuItem toolStripItem = RingtoetsContextMenuItemFactory.CreateRemoveAllChildrenFromGroupItem(calculationGroup, viewCommandsMock); DialogBoxHandler = (name, wnd) => { @@ -1409,6 +1440,8 @@ // Assert CollectionAssert.IsEmpty(calculationGroup.Children); + + mocks.VerifyAll(); } #endregion