public void ExpandOnCreate_Always_ReturnsTrue() { // Call bool expandOnCreate = info.ExpandOnCreate(null); // Assert Assert.IsTrue(expandOnCreate); }
public void ExpandOnCreate_Always_ReturnsTrue() { // Setup using (var plugin = new RiskeerPlugin()) { TreeNodeInfo info = GetInfo(plugin); // Call bool result = info.ExpandOnCreate(null); // Assert Assert.IsTrue(result); } }
public void ImplicitOperator_WithAllMethodsSet_InfoFullyConverted() { // Setup var onDropCounter = 0; var onNodeRenamedCounter = 0; var onNodeRemovedCounter = 0; var onNodeCheckedCounter = 0; var genericTreeNodeInfo = new TreeNodeInfo <int> { Text = o => "text", ForeColor = o => Color.Azure, Image = o => new Bitmap(16, 16), ContextMenuStrip = (o1, o2, tvc) => new ContextMenuStrip { Items = { new ToolStripButton() } }, EnsureVisibleOnCreate = (o, p) => true, ExpandOnCreate = o => true, ChildNodeObjects = o => new[] { new object() }, CanRename = (o1, o2) => true, OnNodeRenamed = (o, newName) => { onNodeRenamedCounter++; }, CanRemove = (o1, o2) => true, OnNodeRemoved = (o1, o2) => { onNodeRemovedCounter++; }, OnRemoveConfirmationText = o => "Confirmation message", OnRemoveChildNodesConfirmationText = o => "Confirmation message 2", CanCheck = o => true, CheckedState = o => TreeNodeCheckedState.Checked, OnNodeChecked = (o1, o2) => { onNodeCheckedCounter++; }, CanDrag = (o1, o2) => true, CanDrop = (o1, o2) => true, CanInsert = (o1, o2) => true, OnDrop = (o1, o2, o3, index, tvc) => { onDropCounter++; } }; // Precondition Assert.IsInstanceOf <TreeNodeInfo <int> >(genericTreeNodeInfo); // Call TreeNodeInfo treeNodeInfo = genericTreeNodeInfo; // Assert using (var treeViewControl = new TreeViewControl()) using (ContextMenuStrip contextMenuStrip = treeNodeInfo.ContextMenuStrip(0, 1, treeViewControl)) { Assert.AreEqual(1, contextMenuStrip.Items.Count); treeNodeInfo.OnDrop(0, 1, 2, 3, treeViewControl); Assert.AreEqual(1, onDropCounter); } Assert.AreEqual(typeof(int), treeNodeInfo.TagType); Assert.AreEqual("text", treeNodeInfo.Text(0)); Assert.AreEqual(Color.Azure, treeNodeInfo.ForeColor(0)); Assert.AreEqual(16, treeNodeInfo.Image(0).Height); Assert.IsTrue(treeNodeInfo.EnsureVisibleOnCreate(0, 1)); Assert.IsTrue(treeNodeInfo.ExpandOnCreate(0)); Assert.AreEqual(1, treeNodeInfo.ChildNodeObjects(0).Length); Assert.IsTrue(treeNodeInfo.CanRename(0, 1)); Assert.IsTrue(treeNodeInfo.CanRemove(0, 1)); Assert.AreEqual("Confirmation message", treeNodeInfo.OnRemoveConfirmationText(0)); Assert.AreEqual("Confirmation message 2", treeNodeInfo.OnRemoveChildNodesConfirmationText(0)); Assert.IsTrue(treeNodeInfo.CanCheck(0)); Assert.AreEqual(TreeNodeCheckedState.Checked, treeNodeInfo.CheckedState(0)); Assert.IsTrue(treeNodeInfo.CanDrag(0, 1)); Assert.IsTrue(treeNodeInfo.CanDrop(0, 1)); Assert.IsTrue(treeNodeInfo.CanInsert(0, 1)); treeNodeInfo.OnNodeRenamed(0, "newName"); Assert.AreEqual(1, onNodeRenamedCounter); treeNodeInfo.OnNodeRemoved(0, 1); Assert.AreEqual(1, onNodeRemovedCounter); treeNodeInfo.OnNodeChecked(0, 1); Assert.AreEqual(1, onNodeCheckedCounter); }