コード例 #1
0
        public void CanDrag_ParentContextNotNull_ReturnsTrue()
        {
            // Setup
            MapDataCollectionContext context = GetContext(new MapDataCollection("test"));

            // Call
            bool canDrag = info.CanDrag(context, null);

            // Assert
            Assert.IsTrue(canDrag);
        }
コード例 #2
0
        public void CanDrag_WrappedDataChartMultipleAreaData_ReturnsFalse()
        {
            // Setup
            var multipleChartAreaData = new ChartMultipleAreaData("test");
            ChartDataContext context  = GetContext(multipleChartAreaData);

            // Call
            bool canDrag = info.CanDrag(context, null);

            // Assert
            Assert.IsFalse(canDrag);
        }
コード例 #3
0
        public void CanDrag_Always_ReturnsTrue()
        {
            // Call
            bool canDrag = info.CanDrag(null, null);

            // Assert
            Assert.IsTrue(canDrag);
        }
コード例 #4
0
        public void CanDrag_Always_ReturnsTrue()
        {
            // Setup
            mocks.ReplayAll();

            // Call
            bool canDrag = info.CanDrag(null, null);

            // Assert
            Assert.IsTrue(canDrag);
        }
コード例 #5
0
ファイル: TreeNodeInfoTest.cs プロジェクト: Deltares/Riskeer
        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);
        }