Пример #1
0
        public void TestBasicNode2CodeWorkFlow2()
        {
            // 1 -> Point.ByCoordinates ---+
            //                             |---------------------------+
            //                             +-- List.Create (index0)    |-> Line.ByStartPointEndPoint
            //                             +--> List.Create (index1)   |
            //                             |---------------------------+
            // 2 -> Point.ByCoordinates ---+
            OpenModel(@"core\node2code\workflow2.dyn");
            var nodes = CurrentDynamoModel.CurrentWorkspace.Nodes;

            SelectAll(nodes);
            var command = new DynamoModel.ConvertNodesToCodeCommand();

            CurrentDynamoModel.ExecuteCommand(command);

            Assert.AreEqual(2, CurrentDynamoModel.CurrentWorkspace.Connectors.Count());
            Assert.AreEqual(2, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());

            var undo = new DynamoModel.UndoRedoCommand(DynamoModel.UndoRedoCommand.Operation.Undo);

            CurrentDynamoModel.ExecuteCommand(undo);

            Assert.AreEqual(6, CurrentDynamoModel.CurrentWorkspace.Connectors.Count());
            Assert.AreEqual(6, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());
        }
Пример #2
0
        /// <summary>
        /// Run the dyn file and get all preview values in string representation.
        /// Then, iterate all nodes, for each iteration, choose a node and convert
        /// the remaining nodes to code, and compare the preview value of this
        /// node against with its original value.
        /// </summary>
        /// <param name="dynFilePath"></param>
        protected void MutationTest(string dynFilePath)
        {
            Dictionary <Guid, string> previewMap = new Dictionary <Guid, string>();

            RunModel(dynFilePath);

            foreach (var node in CurrentDynamoModel.CurrentWorkspace.Nodes)
            {
                previewMap[node.GUID] = GetStringData(node.GUID);
            }

            var nodes = CurrentDynamoModel.CurrentWorkspace.Nodes.Select(n => n.GUID).ToList();

            foreach (var node in nodes)
            {
                SelectAllExcept(node);
                var command = new DynamoModel.ConvertNodesToCodeCommand();
                CurrentDynamoModel.ExecuteCommand(command);
                CurrentDynamoModel.ForceRun();

                var preValue     = previewMap[node];
                var currentValue = GetStringData(node);
                Assert.AreEqual(preValue, currentValue);

                var undo = new DynamoModel.UndoRedoCommand(DynamoModel.UndoRedoCommand.Operation.Undo);
                CurrentDynamoModel.ExecuteCommand(undo);
            }
        }
Пример #3
0
        public void TestBasicNode2CodeWorkFlow2()
        {
            // 1 -> Point.ByCoordinates ---+
            //                             |---------------------------+
            //                             +-- List.Create (index0)    |-> Line.ByStartPointEndPoint
            //                             +--> List.Create (index1)   |
            //                             |---------------------------+
            // 2 -> Point.ByCoordinates ---+
            OpenModel(@"core\node2code\workflow2.dyn");
            var nodes  = ViewModel.CurrentSpaceViewModel.Model.Nodes;
            var engine = ViewModel.Model.EngineController;

            ViewModel.SelectAll(null);
            var command = new DynamoModel.ConvertNodesToCodeCommand();

            ViewModel.ExecuteCommand(command);

            Assert.IsTrue(ViewModel.CurrentSpace.Connectors.Count() == 2);
            Assert.IsTrue(ViewModel.CurrentSpace.Nodes.Count == 2);

            var undo = new DynamoModel.UndoRedoCommand(DynamoModel.UndoRedoCommand.Operation.Undo);

            ViewModel.ExecuteCommand(undo);

            Assert.IsTrue(ViewModel.CurrentSpace.Connectors.Count() == 6);
            Assert.IsTrue(ViewModel.CurrentSpace.Nodes.Count == 6);
        }
Пример #4
0
        /// <summary>
        /// After command framework is implemented, this method should now be only 
        /// called from a menu item (i.e. Ctrl + W). It should not be used as a 
        /// way for any other code paths to convert nodes to code programmatically. 
        /// For that we now have ConvertNodesToCodeInternal which takes in more 
        /// configurable arguments.
        /// </summary>
        /// <param name="parameters">This is not used and should always be null,
        /// otherwise an ArgumentException will be thrown.</param>
        /// 
        internal void NodeToCode(object parameters)
        {
            if (null != parameters) // See above for details of this exception.
            {
                const string message = "Internal error, argument must be null";
                throw new ArgumentException(message, "parameters");
            }

            var command = new DynamoModel.ConvertNodesToCodeCommand();
            this.DynamoViewModel.ExecuteCommand(command);
        }
Пример #5
0
        public void TestBasicNode2CodeWorkFlow4()
        {
            OpenModel(@"core\node2code\workflow4.dyn");
            var nodes  = ViewModel.CurrentSpaceViewModel.Model.Nodes;
            var engine = ViewModel.Model.EngineController;

            ViewModel.SelectAll(null);
            var command = new DynamoModel.ConvertNodesToCodeCommand();

            ViewModel.ExecuteCommand(command);

            Assert.IsTrue(ViewModel.CurrentSpace.Connectors.Count() == 3);
            Assert.IsTrue(ViewModel.CurrentSpace.Nodes.Count == 3);
        }
Пример #6
0
        public void TestBasicNode2CodeWorkFlow4()
        {
            OpenModel(@"core\node2code\workflow4.dyn");
            var nodes = CurrentDynamoModel.CurrentWorkspace.Nodes;

            SelectAll(nodes);
            var command = new DynamoModel.ConvertNodesToCodeCommand();

            CurrentDynamoModel.ExecuteCommand(command);

            Assert.AreEqual(3, CurrentDynamoModel.CurrentWorkspace.Connectors.Count());
            Assert.AreEqual(3, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());

            var undo = new DynamoModel.UndoRedoCommand(DynamoModel.UndoRedoCommand.Operation.Undo);

            CurrentDynamoModel.ExecuteCommand(undo);

            Assert.AreEqual(4, CurrentDynamoModel.CurrentWorkspace.Connectors.Count());
            Assert.AreEqual(4, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());
        }
Пример #7
0
        private void TestNodeToCodeUndoBase(string filePath)
        {
            // Verify after undo all nodes and connectors should be resotored back
            // to original state.
            OpenModel(filePath);

            var wp        = CurrentDynamoModel.CurrentWorkspace;
            var nodeGuids = wp.Nodes.Select(n => n.GUID).ToList();

            nodeGuids.Sort();

            var connectorGuids = wp.Connectors.Select(c => c.GUID).ToList();

            connectorGuids.Sort();

            SelectAll(wp.Nodes);
            var command = new DynamoModel.ConvertNodesToCodeCommand();

            CurrentDynamoModel.ExecuteCommand(command);

            var undo = new DynamoModel.UndoRedoCommand(DynamoModel.UndoRedoCommand.Operation.Undo);

            CurrentDynamoModel.ExecuteCommand(undo);

            var curNodeGuids = wp.Nodes.Select(n => n.GUID).ToList();

            curNodeGuids.Sort();

            var curConnectorGuids = wp.Connectors.Select(c => c.GUID).ToList();

            curConnectorGuids.Sort();

            Assert.AreEqual(curNodeGuids.Count, nodeGuids.Count);
            Assert.IsTrue(nodeGuids.SequenceEqual(curNodeGuids));

            Assert.AreEqual(curConnectorGuids.Count, connectorGuids.Count);
            Assert.IsTrue(connectorGuids.SequenceEqual(curConnectorGuids));
        }
Пример #8
0
        /// <summary>
        /// Run the dyn file and get all preview values in string representation.
        /// Undo, force run and get all preview values in string representation.
        /// These two sets of preview value should be the same.
        /// </summary>
        /// <param name="dynFilePath"></param>
        protected void UndoTest(string dynFilePath)
        {
            Dictionary <Guid, string> previewMap = new Dictionary <Guid, string>();

            RunModel(dynFilePath);

            foreach (var node in CurrentDynamoModel.CurrentWorkspace.Nodes)
            {
                previewMap[node.GUID] = GetStringData(node.GUID);
            }

            int nodeCount      = CurrentDynamoModel.CurrentWorkspace.Nodes.Count();
            int connectorCount = CurrentDynamoModel.CurrentWorkspace.Connectors.Count();

            SelectAll();
            var command = new DynamoModel.ConvertNodesToCodeCommand();

            CurrentDynamoModel.ExecuteCommand(command);
            CurrentDynamoModel.ForceRun();

            var undo = new DynamoModel.UndoRedoCommand(DynamoModel.UndoRedoCommand.Operation.Undo);

            CurrentDynamoModel.ExecuteCommand(undo);
            CurrentDynamoModel.ForceRun();

            // Verify after undo everything is OK
            Assert.AreEqual(nodeCount, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());
            Assert.AreEqual(connectorCount, CurrentDynamoModel.CurrentWorkspace.Connectors.Count());

            foreach (var node in CurrentDynamoModel.CurrentWorkspace.Nodes)
            {
                Assert.IsTrue(previewMap.ContainsKey(node.GUID));
                var preValue     = previewMap[node.GUID];
                var currentValue = GetStringData(node.GUID);
                Assert.AreEqual(preValue, currentValue);
            }
        }