Ejemplo n.º 1
0
        public void CanAdd100NodesToClipboardAndPaste3Times()
        {
            int numNodes = 100;

            // create 100 nodes, and select them as you go
            for (int i = 0; i < numNodes; i++)
            {
                var addNode = new DSFunction(CurrentDynamoModel.LibraryServices.GetFunctionDescriptor("+"));
                CurrentDynamoModel.CurrentWorkspace.AddAndRegisterNode(addNode, false);
                Assert.AreEqual(i + 1, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());

                CurrentDynamoModel.AddToSelection(CurrentDynamoModel.CurrentWorkspace.Nodes.Last());

                Assert.AreEqual(i + 1, DynamoSelection.Instance.Selection.Count);
            }

            CurrentDynamoModel.Copy();

            Assert.AreEqual(numNodes, CurrentDynamoModel.ClipBoard.Count);

            int numPastes = 3;

            for (int i = 1; i <= numPastes; i++)
            {
                CurrentDynamoModel.Paste();
                Assert.AreEqual(numNodes, CurrentDynamoModel.ClipBoard.Count);
                Assert.AreEqual(numNodes * (i + 1), CurrentDynamoModel.CurrentWorkspace.Nodes.Count());
            }
        }
Ejemplo n.º 2
0
        public void CanCopyAndPasteAndUndoOutputState()
        {
            var addNode = new DSFunction(CurrentDynamoModel.LibraryServices.GetFunctionDescriptor("+"));

            CurrentDynamoModel.CurrentWorkspace.AddAndRegisterNode(addNode, false);
            Assert.AreEqual(1, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());

            addNode.IsSetAsOutput = true;
            CurrentDynamoModel.AddToSelection(addNode);
            Assert.AreEqual(1, DynamoSelection.Instance.Selection.Count);

            CurrentDynamoModel.Copy();
            Assert.AreEqual(1, CurrentDynamoModel.ClipBoard.Count);

            CurrentDynamoModel.Paste();
            Assert.AreEqual(2, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());

            Assert.IsTrue(CurrentDynamoModel.CurrentWorkspace.Nodes.All(x => x.IsSetAsOutput));

            CurrentDynamoModel.CurrentWorkspace.Undo();
            Assert.AreEqual(1, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());
            addNode.IsSetAsOutput = false;

            CurrentDynamoModel.ExecuteCommand(
                new DynCmd.UpdateModelValueCommand(
                    Guid.Empty, addNode.GUID, nameof(NodeModel.IsSetAsOutput), "true"));
            Assert.IsTrue(addNode.IsSetAsOutput);

            CurrentDynamoModel.CurrentWorkspace.Undo();

            Assert.IsFalse(addNode.IsSetAsOutput);
        }
Ejemplo n.º 3
0
        public void CanCopydAndPaste2NodesWithRightOffset()
        {
            var addNode = new DSFunction(CurrentDynamoModel.LibraryServices.GetFunctionDescriptor("+"));

            addNode.Height  = 2;
            addNode.Width   = 2;
            addNode.CenterX = 3;
            addNode.CenterY = 2;

            CurrentDynamoModel.CurrentWorkspace.AddAndRegisterNode(addNode, false);
            CurrentDynamoModel.AddToSelection(addNode);

            addNode         = new DSFunction(CurrentDynamoModel.LibraryServices.GetFunctionDescriptor("+"));
            addNode.Height  = 2;
            addNode.Width   = 2;
            addNode.CenterX = 6;
            addNode.CenterY = 8;

            CurrentDynamoModel.CurrentWorkspace.AddAndRegisterNode(addNode, false);
            CurrentDynamoModel.AddToSelection(addNode);

            CurrentDynamoModel.Copy();
            Assert.AreEqual(2, CurrentDynamoModel.ClipBoard.Count);

            CurrentDynamoModel.Paste();
            Assert.AreEqual(4, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());

            Assert.AreEqual(22, CurrentDynamoModel.CurrentWorkspace.Nodes.ElementAt(2).X);
            Assert.AreEqual(21, CurrentDynamoModel.CurrentWorkspace.Nodes.ElementAt(2).Y);

            Assert.AreEqual(25, CurrentDynamoModel.CurrentWorkspace.Nodes.ElementAt(3).X);
            Assert.AreEqual(27, CurrentDynamoModel.CurrentWorkspace.Nodes.ElementAt(3).Y);
        }
        public void CanCopydAndPasteAndUndoPythonEngine()
        {
            var pyNode = new PythonNode();

            CurrentDynamoModel.ExecuteCommand(new Dynamo.Models.DynamoModel.CreateNodeCommand(pyNode, 0, 0, false, false));
            Assert.AreEqual(1, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());

            pyNode.Engine = PythonEngineVersion.CPython3;
            CurrentDynamoModel.AddToSelection(pyNode);

            CurrentDynamoModel.Copy();
            Assert.AreEqual(1, CurrentDynamoModel.ClipBoard.Count);

            CurrentDynamoModel.Paste();
            Assert.AreEqual(2, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());

            Assert.IsTrue(CurrentDynamoModel.CurrentWorkspace.Nodes.OfType <PythonNode>().All(x => x.Engine == PythonEngineVersion.CPython3));

            CurrentDynamoModel.ExecuteCommand(new UndoRedoCommand(UndoRedoCommand.Operation.Undo));
            Assert.AreEqual(1, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());
            pyNode.Engine = PythonEngineVersion.IronPython2;

            CurrentDynamoModel.ExecuteCommand(
                new UpdateModelValueCommand(
                    Guid.Empty, pyNode.GUID, nameof(PythonNode.Engine), PythonEngineVersion.CPython3.ToString()));
            Assert.AreEqual(pyNode.Engine, PythonEngineVersion.CPython3);

            CurrentDynamoModel.ExecuteCommand(new UndoRedoCommand(UndoRedoCommand.Operation.Undo));

            Assert.AreEqual(pyNode.Engine, PythonEngineVersion.IronPython2);
        }
Ejemplo n.º 5
0
        public void Defect_MAGN_2375_3487()
        {
            // This test case is addressing the following two defects:
            // Details are available in http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-2375
            //                      and http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-3487
            RunModel(@"core\dsevaluation\Defect_MAGN_2375_3487.dyn");

            // check all the nodes and connectors are loaded
            Assert.AreEqual(3, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());
            Assert.AreEqual(2, CurrentDynamoModel.CurrentWorkspace.Connectors.Count());

            CurrentDynamoModel.AddToSelection(CurrentDynamoModel.CurrentWorkspace.NodeFromWorkspace
                                                  ("5a7f7549-fbef-4c3f-8578-c67471eaa87f"));

            CurrentDynamoModel.Copy();
            CurrentDynamoModel.Paste();

            Assert.AreEqual(4, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());
            Assert.AreEqual(4, CurrentDynamoModel.CurrentWorkspace.Connectors.Count());

            //run the graph after copy paste
            BeginRun();

            var nodes = CurrentDynamoModel.CurrentWorkspace.Nodes.OfType <DSVarArgFunction>();

            foreach (var item in nodes)
            {
                AssertPreviewValue(item.GUID.ToString(), new string[] { "Dynamo", "DS" });
            }
        }
Ejemplo n.º 6
0
        public void CanCopyAndPasteAndUndoInputState()
        {
            var numberNode = new DoubleInput();

            CurrentDynamoModel.CurrentWorkspace.AddAndRegisterNode(numberNode, false);
            Assert.AreEqual(1, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());

            numberNode.IsSetAsInput = true;
            CurrentDynamoModel.AddToSelection(numberNode);
            Assert.AreEqual(1, DynamoSelection.Instance.Selection.Count);

            CurrentDynamoModel.Copy();
            Assert.AreEqual(1, CurrentDynamoModel.ClipBoard.Count);

            CurrentDynamoModel.Paste();
            Assert.AreEqual(2, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());

            Assert.IsTrue(CurrentDynamoModel.CurrentWorkspace.Nodes.All(x => x.IsSetAsInput));

            CurrentDynamoModel.CurrentWorkspace.Undo();
            Assert.AreEqual(1, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());
            numberNode.IsSetAsInput = false;

            CurrentDynamoModel.ExecuteCommand(
                new DynCmd.UpdateModelValueCommand(
                    Guid.Empty, numberNode.GUID, nameof(NodeModel.IsSetAsInput), "true"));
            Assert.IsTrue(numberNode.IsSetAsInput);

            CurrentDynamoModel.CurrentWorkspace.Undo();

            Assert.IsFalse(numberNode.IsSetAsInput);
        }
Ejemplo n.º 7
0
        public void CanCollapseNodesAndGetSameResult()
        {
            string openPath = Path.Combine(TestDirectory, @"core\collapse\collapse.dyn");

            OpenModel(openPath);

            var watchNode = CurrentDynamoModel.CurrentWorkspace.FirstNodeFromWorkspace <Watch>();

            var numNodesPreCollapse = CurrentDynamoModel.CurrentWorkspace.Nodes.Count();

            BeginRun();

            var valuePreCollapse = watchNode.CachedValue;

            var nodesToCollapse = new[]
            {
                "1da395b9-2539-4705-a479-1f6e575df01d",
                "b8130bf5-dd14-4784-946d-9f4705df604e",
                "a54c7cfa-450a-4edc-b7a5-b3e15145a9e1"
            };

            foreach (
                var node in nodesToCollapse.Select(CurrentDynamoModel.CurrentWorkspace.NodeFromWorkspace))
            {
                CurrentDynamoModel.AddToSelection(node);
            }

            CurrentDynamoModel.CustomNodeManager.Collapse(
                DynamoSelection.Instance.Selection.OfType <NodeModel>(),
                Enumerable.Empty <NoteModel>(),
                CurrentDynamoModel.CurrentWorkspace,
                true,
                new FunctionNamePromptEventArgs
            {
                Category    = "Testing",
                Description = "",
                Name        = "__CollapseTest__",
                Success     = true
            });

            var numNodesPostCollapse = CurrentDynamoModel.CurrentWorkspace.Nodes.Count();

            Assert.AreNotEqual(numNodesPreCollapse, numNodesPostCollapse);
            Assert.AreEqual(nodesToCollapse.Length, numNodesPreCollapse - numNodesPostCollapse + 1);

            BeginRun();

            var valuePostCollapse = watchNode.CachedValue;

            // Ensure the values are equal and both 65.
            Assert.AreEqual(65, valuePreCollapse);
            Assert.AreEqual(65, valuePostCollapse);
        }
Ejemplo n.º 8
0
        public void CanAddToSelectionAndNotThrowExceptionWhenPassedIncorrectType()
        {
            int numNodes = 100;

            // select all of them one by one
            for (int i = 0; i < numNodes; i++)
            {
                Assert.DoesNotThrow(() => CurrentDynamoModel.AddToSelection(null));
                Assert.DoesNotThrow(() => CurrentDynamoModel.AddToSelection(5));
                Assert.DoesNotThrow(() => CurrentDynamoModel.AddToSelection("noodle"));
                Assert.DoesNotThrow(() => CurrentDynamoModel.AddToSelection(new StringBuilder()));
            }
        }
Ejemplo n.º 9
0
        public void TestGroupsOnCustomNodes()
        {
            string openPath = Path.Combine(TestDirectory, @"core\collapse\collapse.dyn");

            OpenModel(openPath);

            var nodesToCollapse = new[]
            {
                "1da395b9-2539-4705-a479-1f6e575df01d",
                "b8130bf5-dd14-4784-946d-9f4705df604e",
                "a54c7cfa-450a-4edc-b7a5-b3e15145a9e1"
            };

            foreach (
                var node in
                nodesToCollapse.Select(CurrentDynamoModel.CurrentWorkspace.NodeFromWorkspace))
            {
                CurrentDynamoModel.AddToSelection(node);
            }

            //create the group around selected nodes
            Guid groupid    = Guid.NewGuid();
            var  annotation = CurrentDynamoModel.CurrentWorkspace.AddAnnotation("This is a test group", groupid);

            Assert.AreEqual(CurrentDynamoModel.CurrentWorkspace.Annotations.Count(), 1);
            Assert.AreEqual(CurrentDynamoModel.CurrentWorkspace.Annotations.First().Nodes.Count(), 3);

            CurrentDynamoModel.AddToSelection(annotation);

            var ws = CurrentDynamoModel.CustomNodeManager.Collapse(
                DynamoSelection.Instance.Selection.OfType <NodeModel>(),
                Enumerable.Empty <NoteModel>(),
                CurrentDynamoModel.CurrentWorkspace,
                true,
                new FunctionNamePromptEventArgs
            {
                Category    = "Testing",
                Description = "",
                Name        = "__CollapseTest2__",
                Success     = true
            });

            CurrentDynamoModel.AddCustomNodeWorkspace(ws);

            SelectTabByGuid(ws.CustomNodeId);

            Assert.AreEqual(6, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());

            //Check whether the group is copied to custom workspace
            Assert.AreEqual(1, CurrentDynamoModel.CurrentWorkspace.Annotations.Count());
        }
Ejemplo n.º 10
0
        public void MAGN_5029_CopyPasteWarning()
        {
            // Details are available in defect
            // http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-5029
            // Cutting and pasting Curve.PointAtParameter in run automatically
            // causes "variable has not yet been defined" warning message

            string openPath = Path.Combine(TestDirectory,
                                           @"core\WorkflowTestFiles\\GeometryDefects\MAGN_5029_CopyPasteWarning.dyn");

            RunModel(openPath);

            AssertNoDummyNodes();

            // check all the nodes and connectors are loaded
            Assert.AreEqual(4, CurrentDynamoModel.CurrentWorkspace.Nodes.Count);
            Assert.AreEqual(5, CurrentDynamoModel.CurrentWorkspace.Connectors.Count());

            //CGet Curve.PointAtParameter node and copy paste it.
            string nodeID = "de3e5067-d7e2-4e47-aca3-7f2531614892";
            var    pointAtParameterNode = CurrentDynamoModel.CurrentWorkspace.NodeFromWorkspace(nodeID);

            // Copy and paste the PointAtParameter Node
            CurrentDynamoModel.AddToSelection(pointAtParameterNode);
            CurrentDynamoModel.Copy();  // Copy the selected node.
            CurrentDynamoModel.Paste(); // Paste the copied node.

            RunCurrentModel();

            // check all the nodes and connectors are updated
            Assert.AreEqual(5, CurrentDynamoModel.CurrentWorkspace.Nodes.Count);
            Assert.AreEqual(7, CurrentDynamoModel.CurrentWorkspace.Connectors.Count());

            // Make sure we are able to get copy pasted PointAtParameter node.
            var newPointAtPArameterNode = CurrentDynamoModel.CurrentWorkspace.Nodes[4];
            var guid = newPointAtPArameterNode.GUID.ToString();

            // Checking there is no Warning or Error on node after copy paste.
            Assert.AreNotEqual(ElementState.Error, newPointAtPArameterNode.State);
            Assert.AreNotEqual(ElementState.Warning, newPointAtPArameterNode.State);

            AssertPreviewCount(guid, 10);

            for (int i = 0; i <= 9; i++)
            {
                var extractedCurves = GetPreviewValueAtIndex(guid, i) as Point;
                Assert.IsNotNull(extractedCurves);
            }
        }
Ejemplo n.º 11
0
        public void GitHub_461_DeleteNodesFromCustomNodeWorkspaceAfterCollapse()
        {
            string openPath = Path.Combine(TestDirectory, @"core\collapse\collapse.dyn");

            OpenModel(openPath);

            var nodesToCollapse = new[]
            {
                "1da395b9-2539-4705-a479-1f6e575df01d",
                "b8130bf5-dd14-4784-946d-9f4705df604e",
                "a54c7cfa-450a-4edc-b7a5-b3e15145a9e1"
            };

            foreach (
                var node in
                nodesToCollapse.Select(CurrentDynamoModel.CurrentWorkspace.NodeFromWorkspace))
            {
                CurrentDynamoModel.AddToSelection(node);
            }

            var ws = CurrentDynamoModel.CustomNodeManager.Collapse(
                DynamoSelection.Instance.Selection.OfType <NodeModel>(),
                Enumerable.Empty <NoteModel>(),
                CurrentDynamoModel.CurrentWorkspace,
                true,
                new FunctionNamePromptEventArgs
            {
                Category    = "Testing",
                Description = "",
                Name        = "__CollapseTest2__",
                Success     = true
            });

            CurrentDynamoModel.AddCustomNodeWorkspace(ws);

            SelectTabByGuid(ws.CustomNodeId);

            Assert.AreEqual(6, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());

            var modelsToDelete = new List <ModelBase>();
            var addition       = CurrentDynamoModel.CurrentWorkspace.FirstNodeFromWorkspace <DSFunction>();

            Assert.IsNotNull(addition);
            Assert.AreEqual("+", addition.Name);

            modelsToDelete.Add(addition);
            CurrentDynamoModel.DeleteModelInternal(modelsToDelete);
            Assert.AreEqual(5, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());
        }
Ejemplo n.º 12
0
        public void CanAddToSelectionCommand()
        {
            int numNodes = 100;

            // create 100 nodes, and select them as you go
            for (int i = 0; i < numNodes; i++)
            {
                var addNode = new DSFunction(CurrentDynamoModel.LibraryServices.GetFunctionDescriptor("+"));
                CurrentDynamoModel.CurrentWorkspace.AddAndRegisterNode(addNode, false);

                Assert.AreEqual(i + 1, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());

                CurrentDynamoModel.AddToSelection(addNode);
                Assert.AreEqual(i + 1, DynamoSelection.Instance.Selection.Count);
            }
        }
Ejemplo n.º 13
0
        public void TestCustomNodeInputType2()
        {
            string openPath = Path.Combine(TestDirectory, @"core\collapse\collapse-input-type.dyn");

            OpenModel(openPath);

            var nodesToCollapse = new[]
            {
                "fb066324-1ca0-400f-8dee-cbb0e1d27719",
            };

            foreach (
                var node in
                nodesToCollapse.Select(CurrentDynamoModel.CurrentWorkspace.NodeFromWorkspace))
            {
                CurrentDynamoModel.AddToSelection(node);
            }

            var ws = CurrentDynamoModel.CustomNodeManager.Collapse(
                DynamoSelection.Instance.Selection.OfType <NodeModel>(),
                Enumerable.Empty <NoteModel>(),
                CurrentDynamoModel.CurrentWorkspace,
                true,
                new FunctionNamePromptEventArgs
            {
                Category    = "Testing",
                Description = "",
                Name        = "__CollapseTestForInputType1__",
                Success     = true
            });

            CurrentDynamoModel.AddCustomNodeWorkspace(ws);
            CurrentDynamoModel.OpenCustomNodeWorkspace(ws.CustomNodeId);
            var inputs = CurrentDynamoModel.CurrentWorkspace.Nodes.OfType <Symbol>();

            Assert.IsNotNull(inputs);

            var curveParam = inputs.FirstOrDefault();

            Assert.IsNotNull(curveParam);

            Assert.AreEqual("Curve", curveParam.Parameter.DisplayTypeName);
        }
Ejemplo n.º 14
0
        public void CanAddOneNodeToClipboard()
        {
            int numNodes = 1;

            // create 100 nodes, and select them as you go
            for (int i = 0; i < numNodes; i++)
            {
                var addNode = new DSFunction(CurrentDynamoModel.LibraryServices.GetFunctionDescriptor("+"));
                CurrentDynamoModel.CurrentWorkspace.AddNode(addNode, false);

                Assert.AreEqual(i + 1, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());

                CurrentDynamoModel.AddToSelection(CurrentDynamoModel.CurrentWorkspace.Nodes.Last());
                Assert.AreEqual(i + 1, DynamoSelection.Instance.Selection.Count);
            }

            CurrentDynamoModel.Copy();
            Assert.AreEqual(numNodes, CurrentDynamoModel.ClipBoard.Count);
        }
Ejemplo n.º 15
0
        public void PasteInputAndOutputNodeInHomeWorkspace()
        {
            const string name        = "Custom Node Creation Test";
            const string description = "Description";
            const string category    = "Custom Node Category";

            CurrentDynamoModel.ExecuteCommand(new DynamoModel.CreateCustomNodeCommand(
                                                  Guid.NewGuid(),
                                                  name,
                                                  category,
                                                  description,
                                                  true));

            CurrentDynamoModel.ExecuteCommand(new DynamoModel.CreateNodeCommand(
                                                  new Symbol(),
                                                  0, 0,
                                                  true, true));

            CurrentDynamoModel.ExecuteCommand(new DynamoModel.CreateNodeCommand(
                                                  new Output(),
                                                  0, 0,
                                                  true, true));

            foreach (var node in CurrentDynamoModel.CurrentWorkspace.Nodes)
            {
                CurrentDynamoModel.AddToSelection(node);
            }

            CurrentDynamoModel.Copy();

            var home = CurrentDynamoModel.Workspaces.OfType <HomeWorkspaceModel>().FirstOrDefault();

            Assert.NotNull(home);
            SelectTabByGuid(home.Guid);

            CurrentDynamoModel.Paste();

            var homeNodes = home.Nodes;

            Assert.AreEqual(2, homeNodes.Count());
            Assert.IsInstanceOf <CodeBlockNodeModel>(homeNodes.ElementAt(0));
            Assert.IsInstanceOf <CodeBlockNodeModel>(homeNodes.ElementAt(1));
        }
Ejemplo n.º 16
0
        public void ValidateConnectionsDoesNotClearError()
        {
            CurrentDynamoModel.CurrentWorkspace.AddAndRegisterNode(
                new CodeBlockNodeModel("30", 100.0, 100.0, CurrentDynamoModel.LibraryServices, CurrentDynamoModel.CurrentWorkspace.ElementResolver),
                false);

            Assert.AreEqual(1, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());

            // Make sure we have the number node created in active state.
            var codeBlockNode = CurrentDynamoModel.CurrentWorkspace.Nodes.First() as CodeBlockNodeModel;

            Assert.IsNotNull(codeBlockNode);
            Assert.AreEqual(ElementState.Active, codeBlockNode.State);

            // Entering an invalid value will cause it to be erroneous.
            var elementResolver = CurrentDynamoModel.CurrentWorkspace.ElementResolver;

            codeBlockNode.SetCodeContent("--", elementResolver); // Invalid numeric value.
            Assert.AreEqual(ElementState.Error, codeBlockNode.State);
            Assert.IsNotEmpty(codeBlockNode.ToolTipText);        // Error tooltip text.

            // Ensure the number node is not selected now.
            Assert.AreEqual(false, codeBlockNode.IsSelected);

            // Try to select the node and make sure it is still erroneous.
            CurrentDynamoModel.AddToSelection(codeBlockNode);
            Assert.AreEqual(true, codeBlockNode.IsSelected);
            Assert.AreEqual(ElementState.Error, codeBlockNode.State);
            Assert.IsNotEmpty(codeBlockNode.ToolTipText); // Error tooltip text.

            // Deselect the node and ensure its error state isn't cleared.
            DynamoSelection.Instance.Selection.Remove(codeBlockNode);
            Assert.AreEqual(false, codeBlockNode.IsSelected);
            Assert.AreEqual(ElementState.Error, codeBlockNode.State);
            Assert.IsNotEmpty(codeBlockNode.ToolTipText); // Error tooltip text.

            // Update to valid numeric value, should cause the node to be active.
            codeBlockNode.SetCodeContent("1234;", elementResolver);
            Assert.AreEqual(ElementState.Active, codeBlockNode.State);
            Assert.IsEmpty(codeBlockNode.ToolTipText); // Error tooltip is gone.
        }
Ejemplo n.º 17
0
        public void SelectionDoesNotChangeWhenAddingAlreadySelectedNode()
        {
            int numNodes = 100;

            // create 100 nodes, and select them as you go
            for (int i = 0; i < numNodes; i++)
            {
                var addNode = new DSFunction(CurrentDynamoModel.LibraryServices.GetFunctionDescriptor("+"));
                CurrentDynamoModel.CurrentWorkspace.AddAndRegisterNode(addNode, false);
                Assert.AreEqual(i + 1, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());

                CurrentDynamoModel.AddToSelection(CurrentDynamoModel.CurrentWorkspace.Nodes.Last());
                Assert.AreEqual(i + 1, DynamoSelection.Instance.Selection.Count);
            }

            // the number selected stays the same
            for (int i = 0; i < numNodes; i++)
            {
                CurrentDynamoModel.AddToSelection(CurrentDynamoModel.CurrentWorkspace.Nodes.Last());
                Assert.AreEqual(numNodes, DynamoSelection.Instance.Selection.Count);
            }
        }
Ejemplo n.º 18
0
        public void CanCollapseWith1NodeHoleInSelection()
        {
            //   http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-5603
            string openPath = Path.Combine(TestDirectory, @"core\collapse\collapse-function.dyn");

            RunModel(openPath);

            var mulNode = CurrentDynamoModel.CurrentWorkspace.NodeFromWorkspace("7bae9908-6e44-41a4-8b9a-e6cd58791194");

            AssertPreviewValue(mulNode.GUID.ToString(), 0);

            foreach (var node in
                     CurrentDynamoModel.CurrentWorkspace.Nodes.Where(
                         x => x.GUID.ToString() != "34d7a656-338d-43bd-bb3d-224515a855eb"))
            {
                CurrentDynamoModel.AddToSelection(node);
            }

            CurrentDynamoModel.CustomNodeManager.Collapse(
                DynamoSelection.Instance.Selection.OfType <NodeModel>(),
                Enumerable.Empty <NoteModel>(),
                CurrentDynamoModel.CurrentWorkspace,
                true,
                new FunctionNamePromptEventArgs
            {
                Category    = "Testing",
                Description = "",
                Name        = "__CollapseTest__",
                Success     = true
            });

            Assert.AreEqual(2, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());

            BeginRun();

            var collapsedNode = CurrentDynamoModel.CurrentWorkspace.FirstNodeFromWorkspace <Function>();

            AssertPreviewValue(collapsedNode.GUID.ToString(), 0);
        }
Ejemplo n.º 19
0
        public void CanCollapseNodesWithDefaultValues()
        {
            string openPath = Path.Combine(TestDirectory, @"core\collapse\collapse-defaults.dyn");

            RunModel(openPath);

            var minNode = CurrentDynamoModel.CurrentWorkspace.NodeFromWorkspace("13f58ca4-4e48-4757-b16a-45b971a6d7fc");
            var numNode = CurrentDynamoModel.CurrentWorkspace.NodeFromWorkspace("4b6487e1-1bcf-47a6-a6fb-ea3122a303af");

            Assert.AreEqual(2, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());
            Assert.AreEqual(1, CurrentDynamoModel.CurrentWorkspace.Connectors.Count());

            AssertPreviewValue("13f58ca4-4e48-4757-b16a-45b971a6d7fc", 10);

            CurrentDynamoModel.AddToSelection(minNode);
            CurrentDynamoModel.AddToSelection(numNode);

            CurrentDynamoModel.CustomNodeManager.Collapse(
                DynamoSelection.Instance.Selection.OfType <NodeModel>(),
                Enumerable.Empty <NoteModel>(),
                CurrentDynamoModel.CurrentWorkspace,
                true,
                new FunctionNamePromptEventArgs
            {
                Category    = "Testing",
                Description = "",
                Name        = "__CollapseTest__",
                Success     = true
            });

            Assert.AreEqual(1, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());

            BeginRun();

            var collapsedNode = CurrentDynamoModel.CurrentWorkspace.FirstNodeFromWorkspace <Function>();

            AssertPreviewValue(collapsedNode.GUID.ToString(), 10);
        }
Ejemplo n.º 20
0
        public void CanCopyPasteJSONDummyNodeAndRetainsOriginalJSON()
        {
            string openPath = Path.Combine(TestDirectory, testFileWithDummyNode);

            OpenModel(openPath);

            Assert.AreEqual(1, CurrentDynamoModel.CurrentWorkspace.Nodes.OfType <DummyNode>().Count());
            //select the dummy node
            CurrentDynamoModel.AddToSelection(CurrentDynamoModel.CurrentWorkspace.Nodes.OfType <DummyNode>().First());
            CurrentDynamoModel.Copy();
            CurrentDynamoModel.Paste();
            //get both dummyNodes
            Assert.AreEqual(2, CurrentDynamoModel.CurrentWorkspace.Nodes.OfType <DummyNode>().Count());
            var dummies = CurrentDynamoModel.CurrentWorkspace.Nodes.OfType <DummyNode>().ToList();

            var oc1 = (dummies[0].OriginalNodeContent as JObject).ToString();
            var oc2 = (dummies[1].OriginalNodeContent as JObject).ToString();

            Console.WriteLine(oc1);
            Console.WriteLine(oc2);
            //assert that originalData are the same string
            Assert.AreEqual(oc1, oc2);
        }
Ejemplo n.º 21
0
        public void CanCopyAndPasteDSVarArgFunctionNode()
        {
            Assert.AreEqual(0, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());

            const string dsVarArgFunctionName = "DSCore.String.Split@string,string[]";
            var          node = new DSVarArgFunction(CurrentDynamoModel.LibraryServices.GetFunctionDescriptor(dsVarArgFunctionName));

            CurrentDynamoModel.CurrentWorkspace.AddAndRegisterNode(node, false);

            // Here we check to see if we do get a DSVarArgFunction node (which
            // is what this test case is written for, other nodes will render the
            // test case meaningless).
            //
            Assert.AreEqual(1, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());

            CurrentDynamoModel.AddToSelection(node); // Select the only DSVarArgFunction node.
            CurrentDynamoModel.Copy();               // Copy the only DSVarArgFunction node.

            Assert.DoesNotThrow(() =>
            {
                CurrentDynamoModel.Paste(); // Nope, paste should not crash Dynamo.
            });
        }
Ejemplo n.º 22
0
        public void ModificationUITesting()
        {
            // Re-use code for creating a custom node
            CanCreateAndPlaceNewCustomNode();

            var instance = CurrentDynamoModel.CurrentWorkspace.Nodes.First() as Function;

            SelectTabByGuid(instance.Definition.FunctionId);

            var currentInPortAmt  = 0;
            var currentOutPortAmt = 0;

            #region Adding
            Func <string, Symbol> addInput = label =>
            {
                var node = new Symbol();
                CurrentDynamoModel.ExecuteCommand(new DynamoModel.CreateNodeCommand(node, 0, 0, true, true));
                node.InputSymbol = label;

                Assert.AreEqual(++currentInPortAmt, instance.InPorts.Count);
                Assert.AreEqual(label, instance.InPorts.Last().Name);

                return(node);
            };

            Func <string, Output> addOutput = label =>
            {
                var node = new Output();

                CurrentDynamoModel.ExecuteCommand(new DynamoModel.CreateNodeCommand(node, 0, 0, true, true));
                node.Symbol = label;

                Assert.AreEqual(++currentOutPortAmt, instance.OutPorts.Count);
                Assert.AreEqual(label, instance.OutPorts.Last().Name);

                return(node);
            };
            #endregion

            #region Renaming
            Action <Symbol, int, string> renameInput = (input, idx, s) =>
            {
                input.InputSymbol = s;
                Assert.AreEqual(s, instance.InPorts[idx].Name);
            };

            Action <Output, int, string> renameOutput = (output, idx, s) =>
            {
                output.Symbol = s;
                Assert.AreEqual(s, instance.OutPorts[idx].Name);
            };
            #endregion

            #region Deleting
            Action <NodeModel> deleteNode = nodeModel =>
            {
                DynamoSelection.Instance.ClearSelection();
                CurrentDynamoModel.AddToSelection(nodeModel);
                var command = new DynamoModel.DeleteModelCommand(Guid.Empty);
                CurrentDynamoModel.ExecuteCommand(command);
            };

            Action <Symbol> deleteInput = input =>
            {
                deleteNode(input);
                Assert.AreEqual(--currentInPortAmt, instance.InPorts.Count);
            };

            Action <Output> deleteOutput = output =>
            {
                deleteNode(output);
                Assert.AreEqual(--currentOutPortAmt, instance.OutPorts.Count);
            };
            #endregion

            //Add some outputs
            var out1 = addOutput("output1");
            var out2 = addOutput("output2");

            //Add some inputs
            var in1 = addInput("input1");
            var in2 = addInput("input2");

            //Change some names
            renameInput(in1, 0, "test");
            renameOutput(out2, 1, "something");

            //Delete some ports
            deleteInput(in2);
            deleteOutput(out1);
        }