Example #1
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());
        }
Example #2
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());
        }
Example #3
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);
        }
Example #4
0
        public void CollapsedNodeWOrkspaceIsAddedToDynamoWithUnsavedChanges()
        {
            NodeModel node;

            if (!CurrentDynamoModel.NodeFactory.CreateNodeFromTypeName("CoreNodeModels.Input.DoubleInput", out node))
            {
                throw new Exception("Failed to create node!");
            }

            var selectionSet = new[] { node };

            DynamoModel.FunctionNamePromptRequestHandler del = (sender, args) =>
            {
                args.Category    = "Testing";
                args.Description = "";
                args.Name        = "__CollapseTest__";
                args.Success     = true;
            };

            CurrentDynamoModel.RequestsFunctionNamePrompt += del;

            var arg = new FunctionNamePromptEventArgs();

            CurrentDynamoModel.OnRequestsFunctionNamePrompt(null, arg);
            Assert.IsTrue(arg.Success);

            CurrentDynamoModel.AddCustomNodeWorkspace(
                CurrentDynamoModel.CustomNodeManager.Collapse(
                    selectionSet, Enumerable.Empty <NoteModel>(),
                    CurrentDynamoModel.CurrentWorkspace, DynamoModel.IsTestMode, arg));

            Assert.IsNotNull(CurrentDynamoModel.CurrentWorkspace.FirstNodeFromWorkspace <Function>());

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

            var customWorkspace = CurrentDynamoModel.Workspaces.ElementAt(1);

            Assert.AreEqual("__CollapseTest__", customWorkspace.Name);
            Assert.IsTrue(customWorkspace.HasUnsavedChanges);
        }