Ejemplo n.º 1
0
        public void CustomNodeDependenciesPropertyGetTest()
        {
            OpenTestFile(@"core\CustomNodes", "add_Read_only.dyf");
            var customWorkspace = CurrentDynamoModel.Workspaces.FirstOrDefault(x => x is CustomNodeWorkspaceModel);

            Assert.IsNotNull(customWorkspace);

            var dependencyCount = customWorkspace.Dependencies.ToList().Count;

            Assert.AreEqual(0, dependencyCount);

            //Loads an e customWorkspace to use as dependency
            OpenTestFile(@"core\CustomNodes", "Centroid.dyf");
            var extraCustomWorkspace = CurrentDynamoModel.Workspaces.LastOrDefault(x => x is CustomNodeWorkspaceModel);

            Assert.IsNotNull(extraCustomWorkspace);
            var cnId       = (extraCustomWorkspace as CustomNodeWorkspaceModel).CustomNodeId;
            var customNode = CurrentDynamoModel.CustomNodeManager.CreateCustomNodeInstance(cnId);

            //Adds a custom node to customWorkspace to generate a dependency
            CurrentDynamoModel.CurrentWorkspace = customWorkspace;
            CurrentDynamoModel.AddNodeToCurrentWorkspace(customNode, false);
            dependencyCount = customWorkspace.Dependencies.ToList().Count;
            Assert.AreEqual(1, dependencyCount);

            //Adds the node again but should not increase dependencies
            CurrentDynamoModel.AddNodeToCurrentWorkspace(customNode, false);
            dependencyCount = customWorkspace.Dependencies.ToList().Count;
            Assert.AreEqual(1, dependencyCount);

            //assert that the guid we have stored is the custom nodes functionID
            Assert.AreEqual(customNode.FunctionSignature, CurrentDynamoModel.CurrentWorkspace.Dependencies.First());
        }
Ejemplo n.º 2
0
        public void PackageDependenciesClearedAfterWorkspaceCleared()
        {
            // Assert ZTTestPackage is not already loaded
            var pi = GetPackageInfo("ZTTestPackage");

            Assert.IsNull(pi);

            // Load package
            string packageDirectory = Path.Combine(TestDirectory, @"core\packageDependencyTests\ZTTestPackage");

            LoadPackage(packageDirectory);
            pi = GetPackageInfo("ZTTestPackage");

            // Add node from package
            var node = GetNodeInstance("ZTTestPackage.RRTestClass.RRTestClass");

            CurrentDynamoModel.AddNodeToCurrentWorkspace(node, true);

            // Assert new package dependency is collected
            var packageDependencies = CurrentDynamoModel.CurrentWorkspace.NodeLibraryDependencies;

            Assert.Contains(pi, packageDependencies);

            // Clear current workspace
            CurrentDynamoModel.ClearCurrentWorkspace();

            // Assert package dependency list is cleared
            Assert.IsTrue(CurrentDynamoModel.CurrentWorkspace.NodeLibraryDependencies.Count == 0);
        }
Ejemplo n.º 3
0
        public void DependencyWithTypeLoads()
        {
            // Load JSON file graph
            string path = Path.Combine(TestDirectory, @"core\packageDependencyTests\DependenciesWithType.dyn");

            OpenModel(path);

            // Assert ZTTestPackage is not loaded
            var pi = GetPackageInfo("ZTTestPackage");

            Assert.IsNull(pi);

            // Assert ZTTestPackage is still a package dependency
            var packageDependencies = CurrentDynamoModel.CurrentWorkspace.NodeLibraryDependencies;

            Assert.Contains(new PackageDependencyInfo("ZTTestPackage", new Version("0.0.1")), packageDependencies);
            Assert.IsTrue(packageDependencies.First().IsLoaded == false);

            string packageDirectory = Path.Combine(TestDirectory, @"core\packageDependencyTests\ZTTestPackage");

            LoadPackage(packageDirectory);

            // Add node from package
            var node = GetNodeInstance("ZTTestPackage.RRTestClass.RRTestClass");

            CurrentDynamoModel.AddNodeToCurrentWorkspace(node, true);

            pi = GetPackageInfo("ZTTestPackage");
            // Assert new package dependency is collected
            Assert.Contains(pi, packageDependencies);
        }
Ejemplo n.º 4
0
        public void PackageDependenciesUpdatedAfterPackageAndNodeAdded()
        {
            // Assert ZTTestPackage is not already loaded
            var pi = GetPackageInfo("ZTTestPackage");

            Assert.IsNull(pi);

            // Load package
            string packageDirectory = Path.Combine(TestDirectory, @"core\packageDependencyTests\ZTTestPackage");

            LoadPackage(packageDirectory);
            pi = GetPackageInfo("ZTTestPackage");

            // Add node from package
            var node = GetNodeInstance("ZTTestPackage.RRTestClass.RRTestClass");

            CurrentDynamoModel.AddNodeToCurrentWorkspace(node, true);

            // Assert new package dependency is collected
            var packageDependencies = CurrentDynamoModel.CurrentWorkspace.NodeLibraryDependencies;

            Assert.Contains(pi, packageDependencies);

            var package = packageDependencies.First();

            Assert.IsTrue(package.IsLoaded);

            if (package is PackageDependencyInfo)
            {
                var packageDependencyState = ((PackageDependencyInfo)package).State;
                Assert.AreEqual(PackageDependencyState.Loaded, packageDependencyState);
            }
        }
Ejemplo n.º 5
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 is PackageDependencyInfo)
                {
                    var packageDependencyState = ((PackageDependencyInfo)package).State;
                    Assert.AreEqual(PackageDependencyState.Loaded, packageDependencyState);
                }

                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);
                }
            }
        }
Ejemplo n.º 6
0
        public void TestDynamoAnalyticsSession_Dispose()
        {
            //Simulating that the system crashed by some reason
            DynamoModel.IsCrashing = true; //This will allow to execute the  StabilityCookie.WriteCrashingShutdown(); method inside the Dispose method

            //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 workspace assigment event
            //The DynamoAnalyticsSession.Dispose() is executed automatically inside the Model and it will go to the crashing section.
            CurrentDynamoModel.OpenCustomNodeWorkspace(customWorkspace.CustomNodeId);

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

            CurrentDynamoModel.AddNodeToCurrentWorkspace(customNode, false);

            //This will get the value recorded in Registry about the crash/shoutdown
            string foundRegValue = (string)Registry.GetValue(REG_KEY, SHUTDOWN_TYPE_NAME, DEFAULT_RETURN_VALUE);

            DynamoModel.IsCrashing = false;

            //Assert
            Assert.AreEqual(CurrentDynamoModel.CurrentWorkspace.Nodes.Count(), InitialNodesCount + 1);
            Assert.IsFalse(string.IsNullOrEmpty(foundRegValue));
        }
Ejemplo n.º 7
0
        public void PackageDependenciesUpdatedAfterNodeRemoved()
        {
            // Load JSON file graph
            string path = Path.Combine(TestDirectory, @"core\packageDependencyTests\TwoDependentNodes_OnePackage.dyn");

            OpenModel(path);

            // Get the two dependent nodes
            Assert.AreEqual(2, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());
            var node1 = CurrentDynamoModel.CurrentWorkspace.Nodes.ToList()[0];
            var node2 = CurrentDynamoModel.CurrentWorkspace.Nodes.ToList()[1];

            // Verify package dependencies
            var packageDependencies = CurrentDynamoModel.CurrentWorkspace.NodeLibraryDependencies;

            Assert.AreEqual(1, packageDependencies.Count);
            Assert.AreEqual(2, packageDependencies.First().Nodes.Count);

            // Remove one node and assert is is no longer listed as a dependent node
            CurrentDynamoModel.CurrentWorkspace.RemoveAndDisposeNode(node1);
            packageDependencies = CurrentDynamoModel.CurrentWorkspace.NodeLibraryDependencies;
            Assert.AreEqual(1, packageDependencies.Count);
            Assert.AreEqual(1, packageDependencies.First().Nodes.Count);
            Assert.True(!packageDependencies.First().Nodes.Contains(node1.GUID));

            var package = packageDependencies.First();

            Assert.IsTrue(package.IsLoaded);

            if (package is PackageDependencyInfo)
            {
                var packageDependencyState = ((PackageDependencyInfo)package).State;
                Assert.AreEqual(PackageDependencyState.Loaded, packageDependencyState);
            }

            // Remove te second node and assert package dependencies is now empty
            CurrentDynamoModel.CurrentWorkspace.RemoveAndDisposeNode(node2);
            packageDependencies = CurrentDynamoModel.CurrentWorkspace.NodeLibraryDependencies;
            Assert.AreEqual(0, packageDependencies.Count);

            // Add another node from the "Dynamo Samples" package
            // and assert that the two removed nodes do not return
            var node3 = GetNodeInstance("Examples.PeriodicIncrement.Increment");

            CurrentDynamoModel.AddNodeToCurrentWorkspace(node3, true);
            packageDependencies = CurrentDynamoModel.CurrentWorkspace.NodeLibraryDependencies;
            Assert.AreEqual(1, packageDependencies.Count);
            Assert.AreEqual(1, packageDependencies.First().Nodes.Count);
            Assert.True(!packageDependencies.First().Nodes.Contains(node1.GUID));
            Assert.True(!packageDependencies.First().Nodes.Contains(node2.GUID));
            Assert.True(packageDependencies.First().Nodes.Contains(node3.GUID));
        }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
0
        public void PackageDependencyIsCollectedForNewWorkspace()
        {
            // Add one node from "Dynamo Samples" package
            var pi   = GetPackageInfo("Dynamo Samples");
            var node = GetNodeInstance("Examples.NEWBasicExample.Create@double,double,double");

            CurrentDynamoModel.AddNodeToCurrentWorkspace(node, true);

            // Assert that "Dynamo Samples" has been added to the workspace's package dependencies
            var packageDependencies = CurrentDynamoModel.CurrentWorkspace.PackageDependencies;

            Assert.AreEqual(1, packageDependencies.Count);
            var package = packageDependencies.First();

            Assert.AreEqual(pi, package);
            Assert.AreEqual(1, package.Nodes.Count);
        }
Ejemplo n.º 11
0
        public void CustomNodePackageDependencyIsCollected()
        {
            // Add "Round Down To Precision" custom node from the "Custom Rounding" package to a new workspace
            var guid       = new Guid("6d1e3caa-780d-40fd-a045-766b3170235d");
            var customNode = CurrentDynamoModel.CustomNodeManager.CreateCustomNodeInstance(guid);

            CurrentDynamoModel.AddNodeToCurrentWorkspace(customNode, true);

            // Assert package dependency is collected
            var packageDependencies = CurrentDynamoModel.CurrentWorkspace.PackageDependencies;

            Assert.AreEqual(1, packageDependencies.Count);
            var package = packageDependencies.First();

            Assert.AreEqual(new PackageDependencyInfo("Custom Rounding", new Version("0.1.4")), package);
            Assert.AreEqual(1, package.Nodes.Count);
        }
Ejemplo n.º 12
0
        public void WorkspaceModelHasCorrectDependencies()
        {
            var addNode    = new DSFunction(CurrentDynamoModel.LibraryServices.GetFunctionDescriptor("+"));
            var ws         = this.CurrentDynamoModel.CustomNodeManager.CreateCustomNode("someNode", "someCategory", "");
            var csid       = (ws as CustomNodeWorkspaceModel).CustomNodeId;
            var customNode = this.CurrentDynamoModel.CustomNodeManager.CreateCustomNodeInstance(csid);

            Assert.AreEqual(0, CurrentDynamoModel.CurrentWorkspace.Dependencies.ToList().Count());

            CurrentDynamoModel.AddNodeToCurrentWorkspace(customNode, false);
            CurrentDynamoModel.CurrentWorkspace.AddAndRegisterNode(addNode, false);
            Assert.AreEqual(1, CurrentDynamoModel.CurrentWorkspace.Dependencies.ToList().Count());
            //assert that we still only record one dep even though custom node is in graph twice.
            CurrentDynamoModel.AddNodeToCurrentWorkspace(customNode, false);
            Assert.AreEqual(1, CurrentDynamoModel.CurrentWorkspace.Dependencies.ToList().Count());

            //assert that guid we have stored is is the custom nodes functionID
            Assert.AreEqual(customNode.FunctionSignature, CurrentDynamoModel.CurrentWorkspace.Dependencies.First());
        }
Ejemplo n.º 13
0
        public void PackageDependenciesUpdatedAfterPackageAndNodeAdded()
        {
            // Assert ZTTestPackage is not already loaded
            var pi = GetPackageInfo("ZTTestPackage");

            Assert.IsNull(pi);

            // Load package
            string packageDirectory = Path.Combine(TestDirectory, @"core\packageDependencyTests\ZTTestPackage");

            LoadPackage(packageDirectory);
            pi = GetPackageInfo("ZTTestPackage");

            // Add node from package
            var node = GetNodeInstance("ZTTestPackage.RRTestClass.RRTestClass");

            CurrentDynamoModel.AddNodeToCurrentWorkspace(node, true);

            // Assert new package dependency is collected
            var packageDependencies = CurrentDynamoModel.CurrentWorkspace.PackageDependencies;

            Assert.Contains(pi, packageDependencies);
        }
Ejemplo n.º 14
0
        public void PackageDependencyIsCollectedForNewWorkspace()
        {
            // Add one node from "Dynamo Samples" package
            var pi   = GetPackageInfo("Dynamo Samples");
            var node = GetNodeInstance("Examples.BasicExample.Create@double,double,double");

            CurrentDynamoModel.AddNodeToCurrentWorkspace(node, true);

            // Assert that "Dynamo Samples" has been added to the workspace's package dependencies
            var packageDependencies = CurrentDynamoModel.CurrentWorkspace.NodeLibraryDependencies;

            Assert.AreEqual(1, packageDependencies.Count);
            var package = packageDependencies.First();

            Assert.AreEqual(pi, package);
            Assert.AreEqual(1, package.Nodes.Count);
            Assert.IsTrue(package.IsLoaded);

            if (package is PackageDependencyInfo)
            {
                var packageDependencyState = ((PackageDependencyInfo)package).State;
                Assert.AreEqual(PackageDependencyState.Loaded, packageDependencyState);
            }
        }