예제 #1
0
 public void RunButtonDisabledInPeriodicRun()
 {
     var homeSpace = GetHomeSpace();
     var node = new DoubleInput();
     Model.AddNodeToCurrentWorkspace(node, true);
     node.CanUpdatePeriodically = true;
     homeSpace.RunSettings.RunType = RunType.Periodic;
     Assert.False((View.RunSettingsControl.RunButton.IsEnabled));
 }
예제 #2
0
        public void PeriodicEnabledWithPeriodicNodes()
        {
            var node = new DoubleInput { CanUpdatePeriodically = true };

            var homeSpace = GetHomeSpace();
            homeSpace.AddAndRegisterNode(node, true);
            
            var item = View.RunSettingsControl.RunTypesComboBox.Items[2] as RunTypeItem;
            Assert.True(item.Enabled);
        }
예제 #3
0
        public void TestNodeToCodeCommandState()
        {
            DynamoSelection.Instance.ClearSelection();
            Assert.IsFalse(ViewModel.CurrentSpaceViewModel.NodeToCodeCommand.CanExecute(null));

            var node = new DoubleInput();
            ViewModel.Model.CurrentWorkspace.AddAndRegisterNode(node, false);
            DynamoSelection.Instance.Selection.Add(node);
            Assert.IsTrue(ViewModel.CurrentSpaceViewModel.NodeToCodeCommand.CanExecute(null));

            DynamoSelection.Instance.ClearSelection();
            Assert.IsFalse(ViewModel.CurrentSpaceViewModel.NodeToCodeCommand.CanExecute(null));
        }
예제 #4
0
        private List<NodeModel> SetupNumberNodesAndPresets()
        {
            var model = CurrentDynamoModel;
            //create some numbers
            var numberNode1 = new DoubleInput();
            numberNode1.Value = "1";
            var numberNode2 = new DoubleInput();
            numberNode2.Value = "2";
            var addNode = new DSFunction(model.LibraryServices.GetFunctionDescriptor("+"));

            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode1,0,0,true,false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode2, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(addNode, 0, 0, true, false));

            //connect them up
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode1.GUID,0,PortType.Output,DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID,0,PortType.Input,DynCmd.MakeConnectionCommand.Mode.End));

            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode2.GUID,0,PortType.Output,DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID,1,PortType.Input,DynCmd.MakeConnectionCommand.Mode.End));

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

            DynamoSelection.Instance.ClearSelection();
            //create the first state with the numbers selected
            DynamoSelection.Instance.Selection.Add(numberNode1);
            DynamoSelection.Instance.Selection.Add(numberNode2);
            var ids = DynamoSelection.Instance.Selection.OfType<NodeModel>().Select(x => x.GUID).ToList();
            //create the preset from 2 nodes
            model.ExecuteCommand(new DynamoModel.AddPresetCommand("state1", "3", ids));

            //change values
            numberNode1.Value = "2";
            numberNode2.Value = "3";

            DynamoSelection.Instance.ClearSelection();
            DynamoSelection.Instance.Selection.Add(numberNode1);
            DynamoSelection.Instance.Selection.Add(numberNode2);
            ids = DynamoSelection.Instance.Selection.OfType<NodeModel>().Select(x => x.GUID).ToList();

            model.ExecuteCommand(new DynamoModel.AddPresetCommand("state2", "5", ids));

            return new List<NodeModel>() { numberNode1, numberNode2,addNode };
        }
예제 #5
0
        public void TestNewNodeFromSelectionCommandState()
        {
            Assert.IsFalse(ViewModel.CurrentSpaceViewModel.NodeFromSelectionCommand.CanExecute(null));

            var node = new DoubleInput();
            ViewModel.Model.CurrentWorkspace.AddAndRegisterNode(node, false);
            ViewModel.Model.AddToSelection(node);
            Assert.IsTrue(ViewModel.CurrentSpaceViewModel.NodeFromSelectionCommand.CanExecute(null));

            var ws = ViewModel.Model.CustomNodeManager.Collapse(
                DynamoSelection.Instance.Selection.OfType<NodeModel>(),
                ViewModel.Model.CurrentWorkspace,
                true,
                new FunctionNamePromptEventArgs
                {
                    Category = "Testing",
                    Description = "",
                    Name = "__CollapseTest2__",
                    Success = true
                });

            Assert.IsFalse(ViewModel.CurrentSpaceViewModel.NodeFromSelectionCommand.CanExecute(null));
        }
예제 #6
0
        public void AddPresetShouldSetDirtyFlag()

        {
            var model = CurrentDynamoModel;
            //create some numbers
            var numberNode1 = new DoubleInput();
            numberNode1.Value = "1";
            var numberNode2 = new DoubleInput();
            numberNode2.Value = "2";

            var addNode = new DSFunction(model.LibraryServices.GetFunctionDescriptor("+"));
           
            //Check for Dirty flag
            Assert.AreEqual(model.CurrentWorkspace.HasUnsavedChanges,false);

            //add the nodes
            model.CurrentWorkspace.AddAndRegisterNode(numberNode1, false);
            model.CurrentWorkspace.AddAndRegisterNode(numberNode2, false);
            model.CurrentWorkspace.AddAndRegisterNode(addNode, false);

            //Check for Dirty flag
            Assert.AreEqual(model.CurrentWorkspace.HasUnsavedChanges, true);

            //Set the dirty flag to false. Mocking the save.
            model.CurrentWorkspace.HasUnsavedChanges = false;
            Assert.AreEqual(model.CurrentWorkspace.HasUnsavedChanges, false);
            
            //connect them up
            ConnectorModel.Make(numberNode1, addNode, 0, 0);
            ConnectorModel.Make(numberNode2, addNode, 0, 1);

            //Check for Dirty flag - After the connection the dirty flag should be set.
            Assert.AreEqual(model.CurrentWorkspace.HasUnsavedChanges, true);

            //Set the dirty flag to false. Mocking the save.
            model.CurrentWorkspace.HasUnsavedChanges = false;
            Assert.AreEqual(model.CurrentWorkspace.HasUnsavedChanges, false);

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

            //create the first state with the numbers selected
            DynamoSelection.Instance.Selection.Add(numberNode1);
            DynamoSelection.Instance.Selection.Add(numberNode2);
            var ids = DynamoSelection.Instance.Selection.OfType<NodeModel>().Select(x => x.GUID).ToList();
            //create the preset from 2 nodes
            model.CurrentWorkspace.AddPreset(
                 "state1",
                 "3", ids);

            Assert.AreEqual(1, model.CurrentWorkspace.Presets.Count());
          
            //change values
            numberNode1.Value = "2";
            numberNode2.Value = "3";

            DynamoSelection.Instance.ClearSelection();
            DynamoSelection.Instance.Selection.Add(numberNode1);
            DynamoSelection.Instance.Selection.Add(numberNode2);
            ids = DynamoSelection.Instance.Selection.OfType<NodeModel>().Select(x => x.GUID).ToList();

            model.CurrentWorkspace.AddPreset(
            "state2",
            "5", ids);

            //Check for Dirty flag - After the Preset the dirty flag should be set.
            Assert.AreEqual(model.CurrentWorkspace.HasUnsavedChanges, true);
        }