public void CanDrop_TargetIsSameAsSourceParent_ReturnsTrue()
        {
            // Setup
            var mapDataCollection             = new MapDataCollection("test 1");
            MapDataCollectionContext context1 = GetContext(mapDataCollection);
            MapDataCollectionContext context2 = GetContext(new MapDataCollection("test 2"), context1);

            // Call
            bool canDrop = info.CanDrop(context2, context1);

            // Assert
            Assert.IsTrue(canDrop);
        }
        public void CanDrop_TargetParentIsSameAsSourceParent_ReturnsTrue()
        {
            // Setup
            ChartData chartData           = new TestChartData();
            var       chartDataCollection = new ChartDataCollection("test");

            ChartDataContext context = GetContext(chartData, chartDataCollection);

            // Call
            bool canDrop = info.CanDrop(context, chartDataCollection);

            // Assert
            Assert.IsTrue(canDrop);
        }
Exemple #3
0
        public void CanDrop_DraggedDataPartOfGroupContext_ReturnsTrue()
        {
            // Setup
            using (var plugin = new RiskeerPlugin())
            {
                TreeNodeInfo info = GetInfo(plugin);

                var assessmentSectionStub            = new AssessmentSectionStub();
                var calculationsForTargetProbability = new HydraulicBoundaryLocationCalculationsForTargetProbability(0.1);

                var targetData = new WaveHeightCalculationsForUserDefinedTargetProbabilitiesGroupContext(
                    new ObservableList <HydraulicBoundaryLocationCalculationsForTargetProbability>
                {
                    calculationsForTargetProbability
                },
                    assessmentSectionStub);

                var draggedData = new WaveHeightCalculationsForUserDefinedTargetProbabilityContext(
                    calculationsForTargetProbability,
                    assessmentSectionStub);

                // Call
                bool canDrop = info.CanDrop(draggedData, targetData);

                // Assert
                Assert.IsTrue(canDrop);
            }
        }
Exemple #4
0
        public void CanDrop_DraggedDataPartOfGroupContext_ReturnsTrue()
        {
            // Setup
            using (var plugin = new DuneErosionPlugin())
            {
                TreeNodeInfo info = GetInfo(plugin);

                var assessmentSectionStub            = new AssessmentSectionStub();
                var failureMechanism                 = new DuneErosionFailureMechanism();
                var calculationsForTargetProbability = new DuneLocationCalculationsForTargetProbability(0.1);

                var targetData = new DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext(
                    new ObservableList <DuneLocationCalculationsForTargetProbability>
                {
                    calculationsForTargetProbability
                },
                    failureMechanism,
                    assessmentSectionStub);

                var draggedData = new DuneLocationCalculationsForUserDefinedTargetProbabilityContext(
                    calculationsForTargetProbability,
                    failureMechanism,
                    assessmentSectionStub);

                // Call
                bool canDrop = info.CanDrop(draggedData, targetData);

                // Assert
                Assert.IsTrue(canDrop);
            }
        }
Exemple #5
0
        public void CanDrop_DraggedDataOfUnsupportedDataType_ReturnsFalse()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanisms = new ObservableList <SpecificFailureMechanism>();
            var targetData        = new SpecificFailureMechanismsContext(failureMechanisms, assessmentSection);

            // Call
            bool canDrop = info.CanDrop(new object(), targetData);

            // Assert
            Assert.IsFalse(canDrop);
        }
Exemple #6
0
        public void CanDrop_DraggedDataOfUnsupportedDataType_ReturnsFalse()
        {
            // Setup
            using (var plugin = new RiskeerPlugin())
            {
                TreeNodeInfo info = GetInfo(plugin);

                var targetData = new WaveHeightCalculationsForUserDefinedTargetProbabilitiesGroupContext(
                    new ObservableList <HydraulicBoundaryLocationCalculationsForTargetProbability>(),
                    new AssessmentSectionStub());

                // Call
                bool canDrop = info.CanDrop(new object(), targetData);

                // Assert
                Assert.IsFalse(canDrop);
            }
        }
Exemple #7
0
        public void CanDrop_DraggedDataOfUnsupportedDataType_ReturnsFalse()
        {
            // Setup
            using (var plugin = new DuneErosionPlugin())
            {
                TreeNodeInfo info = GetInfo(plugin);

                var targetData = new DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext(
                    new ObservableList <DuneLocationCalculationsForTargetProbability>(),
                    new DuneErosionFailureMechanism(),
                    new AssessmentSectionStub());

                // Call
                bool canDrop = info.CanDrop(new object(), targetData);

                // Assert
                Assert.IsFalse(canDrop);
            }
        }
Exemple #8
0
        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);
        }