Ejemplo n.º 1
0
        public void CollapsedNodeWOrkspaceIsAddedToDynamoWithUnsavedChanges()
        {
            NodeModel node;

            if (!CurrentDynamoModel.NodeFactory.CreateNodeFromTypeName("Dynamo.Nodes.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, 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);
        }