Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -rb6d165f6edddc4271e94c5f6d70c12d4ba0c60eb -r0bfd1f4e2a179c8575045e5af70dce2930665626 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs (.../PipingCalculationGroupContextTreeNodeInfoTest.cs) (revision b6d165f6edddc4271e94c5f6d70c12d4ba0c60eb) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs (.../PipingCalculationGroupContextTreeNodeInfoTest.cs) (revision 0bfd1f4e2a179c8575045e5af70dce2930665626) @@ -19,18 +19,13 @@ using RingtoetsFormsResources = Ringtoets.Common.Forms.Properties.Resources; using PipingFormsResources = Ringtoets.Piping.Forms.Properties.Resources; using CoreCommonGuiResources = Core.Common.Gui.Properties.Resources; +using TreeView = System.Windows.Forms.TreeView; namespace Ringtoets.Piping.Forms.Test.TreeNodeInfos { [TestFixture] public class PipingCalculationGroupContextTreeNodeInfoTest : NUnitFormTest { - private const int contextMenuAddCalculationGroupIndex = 0; - private const int contextMenuAddCalculationIndex = 1; - private const int contextMenuValidateAllIndex = 3; - private const int contextMenuCalculateAllIndex = 4; - private const int contextMenuClearOutputIndex = 5; - private MockRepository mocks; private PipingGuiPlugin plugin; private TreeNodeInfo info; @@ -117,7 +112,7 @@ PipingCalculationGroup targetGroup; PipingCalculationGroupContext targetGroupContext; CreatePipingCalculationGroupAndContext(out targetGroup, out targetGroupContext); - + var failureMechanism = new PipingFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(draggedItem); failureMechanism.CalculationsGroup.Children.Add(targetGroup); @@ -143,7 +138,6 @@ mocks.ReplayAll(); - switch (methodToTest) { case DragDropTestMethod.CanDrop: @@ -548,7 +542,7 @@ { // Setup var failureMechanism = new PipingFailureMechanism(); - + var parentNode = mocks.Stub(); parentNode.Tag = failureMechanism; @@ -643,8 +637,8 @@ var parentGroup = new PipingCalculationGroup(); parentGroup.Children.Add(group); var parentNodeData = new PipingCalculationGroupContext(parentGroup, - Enumerable.Empty(), - Enumerable.Empty()); + Enumerable.Empty(), + Enumerable.Empty()); mocks.ReplayAll(); @@ -667,8 +661,8 @@ var parentGroup = new PipingCalculationGroup(); var parentNodeData = new PipingCalculationGroupContext(parentGroup, - Enumerable.Empty(), - Enumerable.Empty()); + Enumerable.Empty(), + Enumerable.Empty()); // Precondition CollectionAssert.DoesNotContain(parentGroup.Children, group); @@ -697,10 +691,10 @@ var parentGroup = new PipingCalculationGroup(); parentGroup.Children.Add(group); var parentNodeData = new PipingCalculationGroupContext(parentGroup, - Enumerable.Empty(), - Enumerable.Empty()); + Enumerable.Empty(), + Enumerable.Empty()); parentNodeData.Attach(observer); - + // Precondition Assert.IsTrue(info.CanRemove(nodeData, parentNodeData)); @@ -728,8 +722,8 @@ }); var parentData = new PipingCalculationGroupContext(parentGroup, - Enumerable.Empty(), - Enumerable.Empty()); + Enumerable.Empty(), + Enumerable.Empty()); var nodeData = new PipingCalculationGroupContext(group, Enumerable.Empty(), @@ -755,7 +749,7 @@ mocks.ReplayAll(); plugin.Gui = gui; - + // Call ContextMenuStrip menu = info.ContextMenuStrip(nodeData, node, info); @@ -819,7 +813,14 @@ CoreCommonGuiResources.Properties_ToolTip, CoreCommonGuiResources.PropertiesIcon, false); - CollectionAssert.AllItemsAreInstancesOfType(new[] { menu.Items[2], menu.Items[6], menu.Items[9], menu.Items[12], menu.Items[15] }, typeof(ToolStripSeparator)); + CollectionAssert.AllItemsAreInstancesOfType(new[] + { + menu.Items[2], + menu.Items[6], + menu.Items[9], + menu.Items[12], + menu.Items[15] + }, typeof(ToolStripSeparator)); mocks.VerifyAll(); } @@ -921,7 +922,14 @@ CoreCommonGuiResources.Properties_ToolTip, CoreCommonGuiResources.PropertiesIcon, false); - CollectionAssert.AllItemsAreInstancesOfType(new[] { menu.Items[2], menu.Items[6], menu.Items[8], menu.Items[11], menu.Items[14] }, typeof(ToolStripSeparator)); + CollectionAssert.AllItemsAreInstancesOfType(new[] + { + menu.Items[2], + menu.Items[6], + menu.Items[8], + menu.Items[11], + menu.Items[14] + }, typeof(ToolStripSeparator)); mocks.VerifyAll(); } @@ -1019,7 +1027,13 @@ CoreCommonGuiResources.Properties_ToolTip, CoreCommonGuiResources.PropertiesIcon, false); - CollectionAssert.AllItemsAreInstancesOfType(new[] { menu.Items[2], menu.Items[6], menu.Items[9], menu.Items[12] }, typeof(ToolStripSeparator)); + CollectionAssert.AllItemsAreInstancesOfType(new[] + { + menu.Items[2], + menu.Items[6], + menu.Items[9], + menu.Items[12] + }, typeof(ToolStripSeparator)); mocks.VerifyAll(); } @@ -1053,7 +1067,6 @@ plugin.Gui = gui; - // Call ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, node, info); @@ -1068,7 +1081,6 @@ mocks.VerifyAll(); // Expect no calls on arguments } - [Test] public void GetContextMenu_ClickOnAddGroupItem_AddGroupToCalculationGroupAndNotifyObservers() { @@ -1089,7 +1101,7 @@ var newCalculationGroupContextNode = new TreeNode(); // Parent node of newly added item, should be expanded from collapsed state to show selected node: - var treeView = new System.Windows.Forms.TreeView(); + var treeView = new TreeView(); var parentNode = new TreeNode(); var node = new TreeNode { @@ -1111,7 +1123,7 @@ group.Children.Add(calculationItem); nodeData.Attach(observer); - + ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, node, info); // Precondition @@ -1125,10 +1137,10 @@ var newlyAddedItem = group.Children.Last(); Assert.IsInstanceOf(newlyAddedItem); Assert.AreEqual("Nieuwe map (1)", newlyAddedItem.Name, - "An item with the same name default name already exists, therefore '(1)' needs to be appended."); + "An item with the same name default name already exists, therefore '(1)' needs to be appended."); Assert.AreSame(newCalculationGroupContextNode, treeView.SelectedNode, - "The node of the newly added item should be selected."); + "The node of the newly added item should be selected."); mocks.VerifyAll(); } @@ -1153,15 +1165,15 @@ var newCalculationContextNode = new TreeNode(); // Parent node of newly added item, should be expanded from collapsed state to show selected node: - var treeView = new System.Windows.Forms.TreeView(); + var treeView = new TreeView(); var parentNode = new TreeNode(); var node = new TreeNode { Tag = nodeData }; node.Nodes.Add(newCalculationContextNode); node.Collapse(); - + parentNode.Nodes.Add(node); treeView.Nodes.Add(parentNode); @@ -1189,10 +1201,10 @@ var newlyAddedItem = group.Children.Last(); Assert.IsInstanceOf(newlyAddedItem); Assert.AreEqual("Nieuwe berekening (1)", newlyAddedItem.Name, - "An item with the same name default name already exists, therefore '(1)' needs to be appended."); + "An item with the same name default name already exists, therefore '(1)' needs to be appended."); Assert.AreSame(newCalculationContextNode, node.TreeView.SelectedNode, - "The node of the newly added item should be selected."); + "The node of the newly added item should be selected."); mocks.VerifyAll(); } @@ -1221,7 +1233,7 @@ var childGroup = new PipingCalculationGroup(); childGroup.Children.Add(validCalculation); - + var emptyChildGroup = new PipingCalculationGroup(); var group = new PipingCalculationGroup(); @@ -1233,7 +1245,7 @@ Enumerable.Empty()); var contextMenu = info.ContextMenuStrip(nodeData, node, info); - + // Call Action call = () => contextMenu.Items[contextMenuValidateAllIndex].PerformClick(); @@ -1336,7 +1348,7 @@ var childGroup = new PipingCalculationGroup(); childGroup.Children.Add(calculation1); - + var emptyChildGroup = new PipingCalculationGroup(); var group = new PipingCalculationGroup(); @@ -1398,11 +1410,11 @@ { // Setup var calculationItem = mocks.StrictMock(); - + mocks.ReplayAll(); var childCalculation = new PipingCalculation(); - + var childGroup = new PipingCalculationGroup(); var group = new PipingCalculationGroup(); @@ -1413,20 +1425,25 @@ Enumerable.Empty(), Enumerable.Empty()); - // Call var children = info.ChildNodeObjects(nodeData).ToArray(); // Assert Assert.AreEqual(group.Children.Count, children.Length); Assert.AreSame(calculationItem, children[0]); - var returnedCalculationContext = (PipingCalculationContext)children[1]; + var returnedCalculationContext = (PipingCalculationContext) children[1]; Assert.AreSame(childCalculation, returnedCalculationContext.WrappedData); - var returnedCalculationGroupContext = (PipingCalculationGroupContext)children[2]; + var returnedCalculationGroupContext = (PipingCalculationGroupContext) children[2]; Assert.AreSame(childGroup, returnedCalculationGroupContext.WrappedData); mocks.VerifyAll(); } + private const int contextMenuAddCalculationGroupIndex = 0; + private const int contextMenuAddCalculationIndex = 1; + private const int contextMenuValidateAllIndex = 3; + private const int contextMenuCalculateAllIndex = 4; + private const int contextMenuClearOutputIndex = 5; + /// /// Creates a stub that is in the expanded state. /// @@ -1482,7 +1499,7 @@ nodeToBeCollapsed.Nodes.AddRange(childNodes); return nodeToBeCollapsed; } - + /// /// Creates an stub that expects its /// method will be called once. @@ -1556,7 +1573,7 @@ } /// - /// Use to creates a stub tree node as a simple node-tree leaf. + /// Use to creates a stub tree node as a simple node-tree leaf. /// private TreeNode CreateStubTreeNode() { @@ -1584,6 +1601,7 @@ /// Indicates . /// CanDrop, + /// /// Indicates . /// @@ -1599,6 +1617,7 @@ /// Indicates . /// Calculation, + /// /// Indicates . ///