Exemple #1
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));
        }
Exemple #2
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);
        }
Exemple #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);
        }