Пример #1
0
        public void DynamoPrintLogsToConsole()
        {
            var expectedOutput = "Greeting CPython node: Hello from Python3!!!" + Environment.NewLine
                                 + "Greeting IronPython node: Hello from Python2!!!" + Environment.NewLine
                                 + "Greeting CPython String node: Hello from Python3!!!" + Environment.NewLine
                                 + "Greeting IronPython String node: Hello from Python2!!!" + Environment.NewLine
                                 + "Multiple print parameter node: Hello Dynamo Print !!!" + Environment.NewLine
                                 + "Print separator parameter node: Hello_Dynamo_Print_!!!" + Environment.NewLine
                                 + @"`!""£$%^&*()_+-[{]}#~'@;:|\,<.>/? Special character node: Lot's of special characters!!!" + Environment.NewLine;

            CurrentDynamoModel.OpenFileFromPath(Path.Combine(TestDirectory, "core", "python", "DynamoPrint.dyn"));
            StringAssert.EndsWith(expectedOutput, CurrentDynamoModel.Logger.LogText);
        }
Пример #2
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()));
            }
        }
Пример #3
0
        public void DynamoPrintLogsToConsole()
        {
            var expectedOutput = ".*Greeting CPython node: Hello from Python3!!!" + Environment.NewLine
                                 + ".*Greeting CPython String node: Hello from Python3!!!" + Environment.NewLine
                                 + ".*Greeting CPython String node: Hello from Python3!!!" + Environment.NewLine
                                 + ".*Multiple print parameter node: Hello Dynamo Print !!!" + Environment.NewLine
                                 + ".*Print separator parameter node: Hello_Dynamo_Print_!!!" + Environment.NewLine
                                 + ".*`!\"£\\$%\\^&\\*\\(\\)_\\+-\\[\\{\\]\\}#~'@;:\\|\\\\,<\\.>/\\? Special character node: Lot's of special characters!!!" + Environment.NewLine
                                 + ".*";

            CurrentDynamoModel.OpenFileFromPath(Path.Combine(TestDirectory, "core", "python", "DynamoPrint.dyn"));
            StringAssert.IsMatch(expectedOutput, CurrentDynamoModel.Logger.LogText);
        }
Пример #4
0
        public void TestCopyPasteGroup_IfItsNodeDeletedAfterCopying()
        {
            //Add a Node
            var ws      = CurrentDynamoModel.CurrentWorkspace;
            var addNode = new DSFunction(CurrentDynamoModel.LibraryServices.GetFunctionDescriptor("+"));

            ws.AddAndRegisterNode(addNode);
            Assert.AreEqual(ws.Nodes.Count(), 1);

            //Add a Note
            var addNote = ws.AddNote(false, 200, 200, "This is a test note", Guid.NewGuid());

            Assert.AreEqual(ws.Notes.Count(), 1);

            //Select the node and notes
            DynamoSelection.Instance.Selection.Add(addNode);
            DynamoSelection.Instance.Selection.Add(addNote);

            //create the group around selected nodes and notes
            var groupId    = Guid.NewGuid();
            var annotation = ws.AddAnnotation("This is a test group", groupId);

            Assert.AreEqual(ws.Annotations.Count(), 1);
            Assert.AreNotEqual(0, annotation.Width);

            //Add the group  selection
            DynamoSelection.Instance.Selection.Add(annotation);

            //Copy the group
            CurrentDynamoModel.Copy();

            var modelToDelete = new List <ModelBase> {
                addNode
            };

            //Delete the node
            CurrentDynamoModel.DeleteModelInternal(modelToDelete);

            // only the note should remain
            Assert.AreEqual(1, annotation.SelectedModels.Count());

            //paste the group
            CurrentDynamoModel.Paste();

            //there should be 2 groups in the workspace
            Assert.AreEqual(ws.Annotations.Count(), 2);
            var pastedGroup = ws.Annotations.First(g => g != annotation);

            // group has been copied with 1 node and 1 note
            Assert.AreEqual(2, pastedGroup.SelectedModels.Count());
        }
Пример #5
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());
        }
Пример #6
0
        public void MutateTestCommand_DeserializeCoreTest()
        {
            //Arrange
            var         command     = new DynamoModel.MutateTestCommand();
            XmlDocument xmlDocument = new XmlDocument();

            //Act
            CurrentDynamoModel.ExecuteCommand(command);
            XmlElement elemTest   = xmlDocument.CreateElement("TestCommand");
            var        xmlElement = command.Serialize(xmlDocument);

            //Assert
            Assert.IsNotNull(xmlElement);
        }
Пример #7
0
        private void CreateNodeAndPorts(int count)
        {
            var          pointGuid = Guid.NewGuid().ToString();
            const string pointName = "List.Create";

            var commands = new List <DynamoModel.ModelBasedRecordableCommand>
            {
                new DynamoModel.CreateNodeCommand(pointGuid,
                                                  pointName, 0, 0, false, false),
                new DynamoModel.ModelEventCommand(pointGuid, "SetInPortCount", count),
            };

            commands.ForEach(c => { CurrentDynamoModel.ExecuteCommand(c); });
        }
Пример #8
0
        public void TestOnRefreshCompleted()
        {
            //Arrange
            //This will subscribe our local method to the RefreshCompleted event
            CurrentDynamoModel.RefreshCompleted += CurrentDynamoModel_RefreshCompleted;

            //Act
            CurrentDynamoModel.OnRefreshCompleted(CurrentDynamoModel.CurrentWorkspace, new EventArgs());

            //Assert
            CurrentDynamoModel.RefreshCompleted -= CurrentDynamoModel_RefreshCompleted;
            //This will validate that the local handler was executed and set the flag in true
            Assert.IsTrue(refreshCompleted);
        }
Пример #9
0
        public void TestOnRequestBugReport()
        {
            //Arrange
            //This will subscribe our local method to the RequestBugReport event
            CurrentDynamoModel.RequestBugReport += CurrentDynamoModel_RequestBugReport;

            //Act
            CurrentDynamoModel.OnRequestBugReport();

            //Assert
            CurrentDynamoModel.RequestBugReport -= CurrentDynamoModel_RequestBugReport;
            //This will validate that the local handler was executed and set the flag in true
            Assert.IsTrue(requestBugReport);
        }
Пример #10
0
        public void CanClearWorkspaceWithNodes()
        {
            Assert.AreEqual(0, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());

            var addNode = new DSFunction(CurrentDynamoModel.LibraryServices.GetFunctionDescriptor("+"));

            CurrentDynamoModel.CurrentWorkspace.AddAndRegisterNode(addNode, false);
            CurrentDynamoModel.CurrentWorkspace.AddAndRegisterNode(new DoubleInput(), false);
            CurrentDynamoModel.CurrentWorkspace.AddAndRegisterNode(new DoubleInput(), false);
            Assert.AreEqual(3, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());

            CurrentDynamoModel.ClearCurrentWorkspace();
            Assert.AreEqual(0, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());
        }
Пример #11
0
        public void PackageDependenciesUpdatedAfterNodesAdded()
        {
            Assert.AreEqual(CurrentDynamoModel.CurrentWorkspace.NodeLibraryDependencies.Count, 0);

            // Add one node from "Dynamo Samples" package
            var package1 = GetPackageInfo("Dynamo Samples");
            var node1    = GetNodeInstance("Examples.NEWBasicExample.Create@double,double,double");

            CurrentDynamoModel.AddNodeToCurrentWorkspace(node1, true);
            var packageDependencies = CurrentDynamoModel.CurrentWorkspace.NodeLibraryDependencies;

            Assert.AreEqual(1, packageDependencies.Count);

            // Add second node from "Dynamo Samples" package
            var node2 = GetNodeInstance("Examples.PeriodicIncrement.Increment");

            CurrentDynamoModel.AddNodeToCurrentWorkspace(node2, true);
            packageDependencies = CurrentDynamoModel.CurrentWorkspace.NodeLibraryDependencies;

            // Package dependencies count should still be 1 because both nodes are from the same package
            Assert.AreEqual(1, packageDependencies.Count);
            Assert.AreEqual(package1, packageDependencies.First());
            Assert.AreEqual(2, packageDependencies.First().Nodes.Count);

            // Add third node from a different package ("Custom Rounding")
            var package2   = GetPackageInfo("Custom Rounding");
            var guid       = new Guid("6d1e3caa-780d-40fd-a045-766b3170235d");
            var customNode = CurrentDynamoModel.CustomNodeManager.CreateCustomNodeInstance(guid);

            CurrentDynamoModel.AddNodeToCurrentWorkspace(customNode, true);

            // There should now be 2 package dependencies and 3 total dependent nodes
            packageDependencies = CurrentDynamoModel.CurrentWorkspace.NodeLibraryDependencies;
            Assert.AreEqual(2, packageDependencies.Count);
            foreach (var package in packageDependencies)
            {
                Assert.IsTrue(package.IsLoaded);
                if (package.Equals(package1))
                {
                    // Package 1 should have two nodes
                    Assert.AreEqual(2, package.Nodes.Count);
                }
                else
                {
                    // Package 2 should have one node
                    Assert.AreEqual(1, package.Nodes.Count);
                }
            }
        }
Пример #12
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);
            }
        }
Пример #13
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());
        }
Пример #14
0
        public void TestOnRequestSelect()
        {
            //Arrange
            //This will subscribe our local method to the RequestNodeSelect event
            CurrentDynamoModel.RequestNodeSelect += CurrentDynamoModel_RequestNodeSelect;

            //Act
            //This will execute the OnRequestSelect() method
            CurrentDynamoModel.OnRequestSelect(this, new ModelEventArgs(null));

            //Assert
            CurrentDynamoModel.RequestNodeSelect -= CurrentDynamoModel_RequestNodeSelect;
            //This will validate that the local handler was executed and set the flag in true
            Assert.IsTrue(requestNodeSelect);
        }
Пример #15
0
        public void EngineControllerReconcileTraceDataAndNotify()
        {
            //Arrange
            CurrentDynamoModel.EngineController.AstBuilt += EngineController_AstBuilt;

            //Act
            var codeBlockNodeOne = CreateCodeBlockNode();

            CurrentDynamoModel.AddNodeToCurrentWorkspace(codeBlockNodeOne, true);
            CurrentDynamoModel.EngineController.AstBuilt -= EngineController_AstBuilt;

            //Assert
            //Validates that the AstBuilt event was fired
            Assert.IsTrue(compiledAST);
        }
Пример #16
0
        public void TestOnWorkspaceRemoveStarted()
        {
            //Arrange
            //This will subscribe our local method to the WorkspaceRemoveStarted event
            CurrentDynamoModel.WorkspaceRemoveStarted += CurrentDynamoModel_WorkspaceRemoveStarted;

            //Act
            //Internally this will execute the OnWorkspaceRemoveStarted() method in DynamoModelEvents
            CurrentDynamoModel.RemoveWorkspace(CurrentDynamoModel.CurrentWorkspace);

            //Assert
            CurrentDynamoModel.WorkspaceRemoveStarted -= CurrentDynamoModel_WorkspaceRemoveStarted;
            //This will validate that the local handler was executed and set the flag in true
            Assert.IsTrue(workspaceRemoveStarted);
        }
Пример #17
0
        public void Reorder_7573()
        {
            // Original defect: http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-7573

            var dynFilePath = Path.Combine(TestDirectory, @"core\dsevaluation\reorder.dyn");

            RunModel(dynFilePath);

            AssertPreviewValue("c739b941-ece7-4b87-ae69-9a16f04dbe5d", new object[] { null, null, null, null });

            // Reset engine and mark all nodes as dirty. A.k.a., force re-execute.
            CurrentDynamoModel.ForceRun();

            AssertPreviewValue("79d158b3-fa40-4069-8bb5-153e6fb13858", new object[] { 2, 3, 6, 5 });
        }
        public void DelayedExecutionNodeToCodeTest()
        {
            DynamoSelection.Instance.ClearSelection();
            workspaceNodes().ForEach((ele) => DynamoSelection.Instance.Selection.Add(ele));

            var finalNodes = 117;// includes dummy nodes

            activateTaskCounter(finalNodes);
            CurrentDynamoModel.ExecuteCommand(new ConvertNodesToCodeCommand());
            Assert.AreEqual(wModel.Nodes.Count(), finalNodes);
            Assert.AreEqual(taskCounter, 1);
            deactivateTaskCounter();

            CurrentDynamoModel.ExecuteCommand(new UndoRedoCommand(UndoRedoCommand.Operation.Undo));
        }
Пример #19
0
        public void TestOnWorkspaceClearing()
        {
            //Arrange
            //This will subscribe our local method to the RequestLayoutUpdate event
            CurrentDynamoModel.WorkspaceClearing += CurrentDynamoModel_WorkspaceClearing;

            //Act
            //Internally this will execute the OnWorkspaceClearing() method in DynamoModelEvents
            CurrentDynamoModel.ClearCurrentWorkspace();

            //Assert
            CurrentDynamoModel.WorkspaceClearing -= CurrentDynamoModel_WorkspaceClearing;
            //This will validate that the local handler was executed and set the flag in true
            Assert.IsTrue(workspaceClearing);
        }
Пример #20
0
        public void TestOnDeletionStarted()
        {
            //Arrange
            //This will subscribe our local method to the DeletionStarted event
            CurrentDynamoModel.DeletionStarted += CurrentDynamoModel_DeletionStarted;

            //This create a new Code Block node and update the content
            var codeBlockNode0 = CreateCodeBlockNode();

            UpdateCodeBlockNodeContent(codeBlockNode0, @"true;");

            // Create the watch node.
            var watch   = new Watch();
            var command = new DynCmd.CreateNodeCommand(
                watch, 0, 0, true, false);

            CurrentDynamoModel.ExecuteCommand(command);

            // Connect the two nodes
            ConnectorModel.Make(codeBlockNode0, watch, 0, 0);

            // Run
            Assert.DoesNotThrow(BeginRun);

            // Check that we have two nodes in the current workspace, the Watch node and the CodeBlock
            Assert.AreEqual(2, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());

            // Delete the code block node, internally this will call the OnDeletionStarted() method
            var nodeCodeBlock = new List <ModelBase> {
                codeBlockNode0
            };

            CurrentDynamoModel.DeleteModelInternal(nodeCodeBlock);

            // Check that we have only the watch in the current workspace
            Assert.AreEqual(1, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());
            Assert.AreEqual("Watch", CurrentDynamoModel.CurrentWorkspace.Nodes.FirstOrDefault().GetType().Name);

            // Try to delete the Watch node
            var nodeWatch = new List <ModelBase> {
                watch
            };

            CurrentDynamoModel.DeleteModelInternal(nodeWatch);

            CurrentDynamoModel.DeletionStarted -= CurrentDynamoModel_DeletionStarted;
            Assert.IsTrue(deletionStarted);
        }
Пример #21
0
        public void Regress_Magn_4837()
        {
            // Test nested custom node: run and reset engine and re-run.
            // Original defect: http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-4837

            var dynFilePath = Path.Combine(TestDirectory, @"core\CustomNodes\Regress_Magn_4837.dyn");

            RunModel(dynFilePath);

            AssertPreviewValue("42693721-622d-475e-a82e-bfe793ddc153", new object[] { 2, 3, 4, 5, 6 });

            // Reset engine and mark all nodes as dirty. A.k.a., force re-execute.
            CurrentDynamoModel.ForceRun();

            AssertPreviewValue("42693721-622d-475e-a82e-bfe793ddc153", new object[] { 2, 3, 4, 5, 6 });
        }
Пример #22
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);
            }
        }
Пример #23
0
        public void TestOnRequestTaskDialog()
        {
            //Arrange
            //This will subscribe our local method to the RequestTaskDialog event
            CurrentDynamoModel.RequestTaskDialog += CurrentDynamoModel_RequestTaskDialog;
            var args = new TaskDialogEventArgs(
                new Uri("localhost", UriKind.Relative), "Test Dialog", "Summary", "Description");

            //Act
            CurrentDynamoModel.OnRequestTaskDialog(null, args);

            //Assert
            CurrentDynamoModel.RequestTaskDialog -= CurrentDynamoModel_RequestTaskDialog;
            //This will validate that the local handler was executed and set the flag in true
            Assert.IsTrue(requestTaskDialog);
        }
Пример #24
0
        public void CreateNodeCommand_ExecuteCore()
        {
            //Arrange
            var         cbn         = CreateCodeBlockNode();
            var         command     = new DynCmd.CreateNodeCommand(cbn, 0, 0, true, true);
            XmlDocument xmlDocument = new XmlDocument();

            //Act
            CurrentDynamoModel.ExecuteCommand(command);
            XmlElement elemTest = xmlDocument.CreateElement("TestCommand");

            var xmlElement = command.Serialize(xmlDocument);

            //Assert
            Assert.IsNotNull(xmlElement);
        }
Пример #25
0
        public void SelectModelImplShouldNotCrashTest()
        {
            //Assert
            Assert.DoesNotThrow(
                () => {
                //Insert a node GUID that does not exist in workspace
                var ids = new System.Collections.Generic.List <Guid>()
                {
                    Guid.NewGuid()
                };
                var selectCommand = new DynamoModel.SelectModelCommand(ids, ModifierKeys.Shift);

                //Act
                CurrentDynamoModel.ExecuteCommand(selectCommand);
            });
        }
Пример #26
0
        public void TestAddStandardLibraryPath()
        {
            // Get the default custom package folders
            List <string> customPackageFolders = CurrentDynamoModel.PreferenceSettings.CustomPackageFolders;

            // Test that the default number of folders is correct
            Assert.IsTrue(customPackageFolders.Count == 1);

            // Test that the path is added as expected
            CurrentDynamoModel.AddPackagePath(TestDirectory, "");
            Assert.IsTrue(customPackageFolders.Count == 2);

            // Test that the path is not duplicated
            CurrentDynamoModel.AddPackagePath(TestDirectory, "");
            Assert.IsTrue(customPackageFolders.Count == 2);
        }
Пример #27
0
        public void TestOnRequestsCrashPrompt()
        {
            //Arrange
            //This will subscribe our local method to the RequestsCrashPrompt event
            CurrentDynamoModel.RequestsCrashPrompt += CurrentDynamoModel_RequestsCrashPrompt;
            var crashArgs = new Dynamo.Core.CrashPromptArgs("Crash Event", "Test Message");

            //Act
            CurrentDynamoModel.OnRequestsCrashPrompt(this, crashArgs);

            //Assert
            //Unsubcribe from event
            CurrentDynamoModel.RequestsCrashPrompt -= CurrentDynamoModel_RequestsCrashPrompt;
            //This will validate that the local handler was executed and set the flag in true
            Assert.IsTrue(requestsCrashPrompt);
        }
Пример #28
0
        public void TestOnRunCompleted()
        {
            //Arrange
            //This will subscribe our local method to the RunCompleted event
            CurrentDynamoModel.RunCompleted += CurrentDynamoModel_RunCompleted;

            //Act
            //This will execute the OnRunCompleted() method
            CurrentDynamoModel.OnRunCompleted(this, true);

            //Assert
            //Unsubcribe from event
            CurrentDynamoModel.RunCompleted -= CurrentDynamoModel_RunCompleted;
            //This will validate that the local handler was executed and set the flag in true
            Assert.IsTrue(runCompleted);
        }
Пример #29
0
        public void TestOnWorkspaceAdded()
        {
            //Arrange
            // Open/Run XML test graph
            string openPath = Path.Combine(TestDirectory, @"core\Angle.dyn");

            RunModel(openPath);
            int InitialNodesCount = CurrentDynamoModel.CurrentWorkspace.Nodes.Count();

            // Convert a DSFunction node Line.ByPointDirectionLength to custom node.
            var workspace = CurrentDynamoModel.CurrentWorkspace;
            var node      = workspace.Nodes.OfType <DSFunction>().First();

            List <NodeModel> selectionSet = new List <NodeModel>()
            {
                node
            };
            var customWorkspace = CurrentDynamoModel.CustomNodeManager.Collapse(
                selectionSet.AsEnumerable(),
                Enumerable.Empty <Dynamo.Graph.Notes.NoteModel>(),
                CurrentDynamoModel.CurrentWorkspace,
                true,
                new FunctionNamePromptEventArgs
            {
                Category    = "Testing",
                Description = "",
                Name        = "__AnalyticsServiceTest__",
                Success     = true
            }) as CustomNodeWorkspaceModel;

            //Act
            //This will execute the custom workspace assigment and trigger the added workspace assigment event
            CurrentDynamoModel.OpenCustomNodeWorkspace(customWorkspace.CustomNodeId);

            //This will add a new custom node to the workspace
            var addNode    = new DSFunction(CurrentDynamoModel.LibraryServices.GetFunctionDescriptor("+"));
            var ws         = CurrentDynamoModel.CustomNodeManager.CreateCustomNode("someNode", "someCategory", "");
            var csid       = (ws as CustomNodeWorkspaceModel).CustomNodeId;
            var customNode = CurrentDynamoModel.CustomNodeManager.CreateCustomNodeInstance(csid);

            CurrentDynamoModel.AddNodeToCurrentWorkspace(customNode, false);
            CurrentDynamoModel.CurrentWorkspace.AddAndRegisterNode(addNode, false);

            //Assert
            //At the begining the CurrentWorkspace.Nodes has 4 nodes but two new nodes were added, then verify we have 5 nodes.
            Assert.AreEqual(CurrentDynamoModel.CurrentWorkspace.Nodes.Count(), InitialNodesCount + 2);
        }
Пример #30
0
        public void Removekey_7573()
        {
            // Original defect: http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-7573

            var dynFilePath = Path.Combine(TestDirectory, @"core\dsevaluation\removekey.dyn");

            RunModel(dynFilePath);
            // Fix expected result after MAGN-7639 is fixed.

            AssertPreviewValue("bd89982a-c3e6-4a4e-898c-2bdc8f1f8c3e", false);

            // Reset engine and mark all nodes as dirty. A.k.a., force re-execute.
            CurrentDynamoModel.ForceRun();

            // Fix expected result after MAGN-7639 is fixed.
            AssertPreviewValue("980dcd47-84e7-412c-8d9e-d66f166d2370", true);
        }