Пример #1
0
        public void Defect_MAGN_3599()
        {
            // Create the initial code block node.
            var codeBlockNode = CreateCodeBlockNode();

            UpdateCodeBlockNodeContent(codeBlockNode, @"Circle.ByCenterPointRadius(pt,5)");

            // Create the Point.Origin node.
            var nodeGuid = Guid.NewGuid();
            var command  = new DynCmd.CreateNodeCommand(
                nodeGuid, "Point.Origin", 0, 0, true, false);

            ViewModel.ExecuteCommand(command);
            var workspace       = ViewModel.Model.CurrentWorkspace;
            var pointOriginNode = workspace.NodeFromWorkspace <DSFunction>(nodeGuid);

            // Connect the two nodes
            ConnectorModel connector = ConnectorModel.Make(workspace, pointOriginNode, codeBlockNode,
                                                           0, 0, PortType.INPUT);

            workspace.Connectors.Add(connector);

            Assert.AreEqual(1, codeBlockNode.InPortData.Count);

            // Update the code block node
            UpdateCodeBlockNodeContent(codeBlockNode, "pt = Point.ByCoordinates(0,0,0);\nCircle.ByCenterPointRadius(pt,5)");

            Assert.AreEqual(0, codeBlockNode.InPortData.Count);
        }
Пример #2
0
        private CodeBlockNodeModel CreateCodeBlockNode()
        {
            var cbn = new CodeBlockNodeModel(ViewModel.Model.LibraryServices);

            var command = new DynCmd.CreateNodeCommand(cbn, 0, 0, true, false);

            ViewModel.ExecuteCommand(command);

            return(cbn);
        }
Пример #3
0
        private CodeBlockNodeModel CreateCodeBlockNode()
        {
            var cbn     = new CodeBlockNodeModel(CurrentDynamoModel.LibraryServices);
            var command = new DynCmd.CreateNodeCommand(cbn, 0, 0, true, false);

            CurrentDynamoModel.ExecuteCommand(command);

            Assert.IsNotNull(cbn);
            return(cbn);
        }
Пример #4
0
        private CodeBlockNodeModel CreateCodeBlockNode()
        {
            var nodeGuid = Guid.NewGuid();
            var command  = new DynCmd.CreateNodeCommand(
                nodeGuid, "Code Block", 0, 0, true, false);

            ViewModel.ExecuteCommand(command);
            var workspace = ViewModel.Model.CurrentWorkspace;
            var cbn       = workspace.NodeFromWorkspace <CodeBlockNodeModel>(nodeGuid);

            Assert.IsNotNull(cbn);
            return(cbn);
        }
Пример #5
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);
        }
Пример #6
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);
        }
Пример #7
0
        private CodeBlockNodeModel CreateCodeBlockNode()
        {
            var cbn = new CodeBlockNodeModel(CurrentDynamoModel.LibraryServices);
            var command = new DynCmd.CreateNodeCommand(cbn, 0, 0, true, false);

            CurrentDynamoModel.ExecuteCommand(command);

            Assert.IsNotNull(cbn);
            return cbn;
        }
Пример #8
0
        public void Defect_MAGN_3599()
        {
            // Create the initial code block node.
            var codeBlockNode = CreateCodeBlockNode();
            UpdateCodeBlockNodeContent(codeBlockNode, @"Circle.ByCenterPointRadius(pt,5)");

            // Create the Point.Origin node.
            var pointOriginNode =
                new DSFunction(CurrentDynamoModel.LibraryServices.GetFunctionDescriptor("Point.Origin"));

            var command = new DynCmd.CreateNodeCommand(pointOriginNode, 0, 0, true, false);

            CurrentDynamoModel.ExecuteCommand(command);

            // Connect the two nodes
            ConnectorModel.Make(pointOriginNode, codeBlockNode, 0, 0);

            Assert.AreEqual(1, codeBlockNode.InPortData.Count);

            // Update the code block node
            UpdateCodeBlockNodeContent(codeBlockNode, "pt = Point.ByCoordinates(0,0,0);\nCircle.ByCenterPointRadius(pt,5)");

            Assert.AreEqual(0, codeBlockNode.InPortData.Count);
        }
Пример #9
0
        public void Defect_MAGN_3580()
        {
            // Create the initial code block node.
            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);
            var workspace = CurrentDynamoModel.CurrentWorkspace;

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

            // Run
            Assert.DoesNotThrow(BeginRun);

            // Update the code block node
            UpdateCodeBlockNodeContent(codeBlockNode0, @"truuuue;");

            // Check
            Assert.AreEqual(1, codeBlockNode0.InPortData.Count);

            // Create the second code block node
            var codeBlockNode1 = CreateCodeBlockNode();
            UpdateCodeBlockNodeContent(codeBlockNode1, @"false;");

            // Connect the two code block nodes
            ConnectorModel.Make(codeBlockNode1, codeBlockNode0, 0, 0);

            // Run
            Assert.DoesNotThrow(BeginRun);

            UpdateCodeBlockNodeContent(codeBlockNode0, @"true;");

            // Check
            Assert.AreEqual(0, codeBlockNode0.InPortData.Count);

            // Run
            Assert.DoesNotThrow(BeginRun);

            // Delete the first code block node
            var nodes = new List<ModelBase> { codeBlockNode0 };
            CurrentDynamoModel.DeleteModelInternal(nodes);

            // Undo
            workspace.Undo();
        }
Пример #10
0
        public void Defect_MAGN_3580()
        {
            // Create the initial code block node.
            var codeBlockNode0 = CreateCodeBlockNode();

            UpdateCodeBlockNodeContent(codeBlockNode0, @"true;");

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

            ViewModel.ExecuteCommand(command);
            var workspace = ViewModel.Model.CurrentWorkspace;
            var watchNode = workspace.NodeFromWorkspace <Watch>(nodeGuid);

            // Connect the two nodes
            ConnectorModel connector0 = ConnectorModel.Make(workspace, codeBlockNode0, watchNode,
                                                            0, 0, PortType.INPUT);

            workspace.Connectors.Add(connector0);

            // Run
            Assert.DoesNotThrow(() => ViewModel.Model.RunExpression());

            // Update the code block node
            UpdateCodeBlockNodeContent(codeBlockNode0, @"truuuue;");

            // Check
            Assert.AreEqual(1, codeBlockNode0.InPortData.Count);

            // Create the second code block node
            var codeBlockNode1 = CreateCodeBlockNode();

            UpdateCodeBlockNodeContent(codeBlockNode1, @"false;");

            // Connect the two code block nodes
            ConnectorModel connector1 = ConnectorModel.Make(workspace, codeBlockNode1, codeBlockNode0,
                                                            0, 0, PortType.INPUT);

            workspace.Connectors.Add(connector1);

            // Run
            Assert.DoesNotThrow(() => ViewModel.Model.RunExpression());

            UpdateCodeBlockNodeContent(codeBlockNode0, @"true;");

            // Check
            Assert.AreEqual(0, codeBlockNode0.InPortData.Count);

            // Run
            Assert.DoesNotThrow(() => ViewModel.Model.RunExpression());

            // Delete the first code block node
            List <ModelBase> nodes = new List <ModelBase>();

            nodes.Add(codeBlockNode0);
            ViewModel.Model.DeleteModelInternal(nodes);

            // Undo
            workspace.Undo();
        }
Пример #11
0
        private CodeBlockNodeModel CreateCodeBlockNode()
        {
            var nodeGuid = Guid.NewGuid();
            var command = new DynCmd.CreateNodeCommand(
                nodeGuid, "Code Block", 0, 0, true, false);

            ViewModel.ExecuteCommand(command);
            var workspace = ViewModel.Model.CurrentWorkspace;
            var cbn = workspace.NodeFromWorkspace<CodeBlockNodeModel>(nodeGuid);

            Assert.IsNotNull(cbn);
            return cbn;
        }
Пример #12
0
        public void Defect_MAGN_3599()
        {
            // Create the initial code block node.
            var codeBlockNode = CreateCodeBlockNode();
            UpdateCodeBlockNodeContent(codeBlockNode, @"Circle.ByCenterPointRadius(pt,5)");

            // Create the Point.Origin node.
            var nodeGuid = Guid.NewGuid();
            var command = new DynCmd.CreateNodeCommand(
                nodeGuid, "Point.Origin", 0, 0, true, false);

            ViewModel.ExecuteCommand(command);
            var workspace = ViewModel.Model.CurrentWorkspace;
            var pointOriginNode = workspace.NodeFromWorkspace<DSFunction>(nodeGuid);

            // Connect the two nodes
            ConnectorModel connector = ConnectorModel.Make(workspace, pointOriginNode, codeBlockNode,
                0, 0, PortType.INPUT);
            workspace.Connectors.Add(connector);

            Assert.AreEqual(1, codeBlockNode.InPortData.Count);

            // Update the code block node
            UpdateCodeBlockNodeContent(codeBlockNode, "pt = Point.ByCoordinates(0,0,0);\nCircle.ByCenterPointRadius(pt,5)");

            Assert.AreEqual(0, codeBlockNode.InPortData.Count);
        }
Пример #13
0
        public void Defect_MAGN_3580()
        {
            // Create the initial code block node.
            var codeBlockNode0 = CreateCodeBlockNode();
            UpdateCodeBlockNodeContent(codeBlockNode0, @"true;");

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

            ViewModel.ExecuteCommand(command);
            var workspace = ViewModel.Model.CurrentWorkspace;
            var watchNode = workspace.NodeFromWorkspace<Watch>(nodeGuid);

            // Connect the two nodes
            ConnectorModel connector0 = ConnectorModel.Make(workspace, codeBlockNode0, watchNode,
                0, 0, PortType.INPUT);
            workspace.Connectors.Add(connector0);

            // Run
            Assert.DoesNotThrow(() => ViewModel.Model.RunExpression());

            // Update the code block node
            UpdateCodeBlockNodeContent(codeBlockNode0, @"truuuue;");

            // Check
            Assert.AreEqual(1, codeBlockNode0.InPortData.Count);

            // Create the second code block node
            var codeBlockNode1 = CreateCodeBlockNode();
            UpdateCodeBlockNodeContent(codeBlockNode1, @"false;");

            // Connect the two code block nodes
            ConnectorModel connector1 = ConnectorModel.Make(workspace, codeBlockNode1, codeBlockNode0,
                0, 0, PortType.INPUT);
            workspace.Connectors.Add(connector1);

            // Run
            Assert.DoesNotThrow(() => ViewModel.Model.RunExpression());

            UpdateCodeBlockNodeContent(codeBlockNode0, @"true;");

            // Check
            Assert.AreEqual(0, codeBlockNode0.InPortData.Count);

            // Run
            Assert.DoesNotThrow(() => ViewModel.Model.RunExpression());

            // Delete the first code block node
            List<ModelBase> nodes = new List<ModelBase>();
            nodes.Add(codeBlockNode0);
            ViewModel.Model.DeleteModelInternal(nodes);

            // Undo
            workspace.Undo();
        }