public void CanAdd100NodesToClipboardAndPaste3Times() { int numNodes = 100; // create 100 nodes, and select them as you go for (int i = 0; i < numNodes; i++) { var addNode = new DSFunction(CurrentDynamoModel.LibraryServices.GetFunctionDescriptor("+")); CurrentDynamoModel.CurrentWorkspace.AddAndRegisterNode(addNode, false); Assert.AreEqual(i + 1, CurrentDynamoModel.CurrentWorkspace.Nodes.Count()); CurrentDynamoModel.AddToSelection(CurrentDynamoModel.CurrentWorkspace.Nodes.Last()); Assert.AreEqual(i + 1, DynamoSelection.Instance.Selection.Count); } CurrentDynamoModel.Copy(); Assert.AreEqual(numNodes, CurrentDynamoModel.ClipBoard.Count); int numPastes = 3; for (int i = 1; i <= numPastes; i++) { CurrentDynamoModel.Paste(); Assert.AreEqual(numNodes, CurrentDynamoModel.ClipBoard.Count); Assert.AreEqual(numNodes * (i + 1), CurrentDynamoModel.CurrentWorkspace.Nodes.Count()); } }
public void CanCopydAndPaste2NodesWithRightOffset() { var addNode = new DSFunction(CurrentDynamoModel.LibraryServices.GetFunctionDescriptor("+")); addNode.Height = 2; addNode.Width = 2; addNode.CenterX = 3; addNode.CenterY = 2; CurrentDynamoModel.CurrentWorkspace.AddAndRegisterNode(addNode, false); CurrentDynamoModel.AddToSelection(addNode); addNode = new DSFunction(CurrentDynamoModel.LibraryServices.GetFunctionDescriptor("+")); addNode.Height = 2; addNode.Width = 2; addNode.CenterX = 6; addNode.CenterY = 8; CurrentDynamoModel.CurrentWorkspace.AddAndRegisterNode(addNode, false); CurrentDynamoModel.AddToSelection(addNode); CurrentDynamoModel.Copy(); Assert.AreEqual(2, CurrentDynamoModel.ClipBoard.Count); CurrentDynamoModel.Paste(); Assert.AreEqual(4, CurrentDynamoModel.CurrentWorkspace.Nodes.Count()); Assert.AreEqual(17, CurrentDynamoModel.CurrentWorkspace.Nodes.ElementAt(2).X); Assert.AreEqual(17, CurrentDynamoModel.CurrentWorkspace.Nodes.ElementAt(2).Y); Assert.AreEqual(20, CurrentDynamoModel.CurrentWorkspace.Nodes.ElementAt(3).X); Assert.AreEqual(23, CurrentDynamoModel.CurrentWorkspace.Nodes.ElementAt(3).Y); }
public void Defect_MAGN_2375_3487() { // This test case is addressing the following two defects: // Details are available in http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-2375 // and http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-3487 RunModel(@"core\dsevaluation\Defect_MAGN_2375_3487.dyn"); // check all the nodes and connectors are loaded Assert.AreEqual(3, CurrentDynamoModel.CurrentWorkspace.Nodes.Count()); Assert.AreEqual(2, CurrentDynamoModel.CurrentWorkspace.Connectors.Count()); CurrentDynamoModel.AddToSelection(CurrentDynamoModel.CurrentWorkspace.NodeFromWorkspace ("5a7f7549-fbef-4c3f-8578-c67471eaa87f")); CurrentDynamoModel.Copy(); CurrentDynamoModel.Paste(); Assert.AreEqual(4, CurrentDynamoModel.CurrentWorkspace.Nodes.Count()); Assert.AreEqual(4, CurrentDynamoModel.CurrentWorkspace.Connectors.Count()); //run the graph after copy paste BeginRun(); var nodes = CurrentDynamoModel.CurrentWorkspace.Nodes.OfType <DSVarArgFunction>(); foreach (var item in nodes) { AssertPreviewValue(item.GUID.ToString(), new string[] { "Dynamo", "DS" }); } }
public void CanCopydAndPasteAndUndoPythonEngine() { var pyNode = new PythonNode(); CurrentDynamoModel.ExecuteCommand(new Dynamo.Models.DynamoModel.CreateNodeCommand(pyNode, 0, 0, false, false)); Assert.AreEqual(1, CurrentDynamoModel.CurrentWorkspace.Nodes.Count()); pyNode.EngineName = PythonEngineManager.CPython3EngineName; CurrentDynamoModel.AddToSelection(pyNode); CurrentDynamoModel.Copy(); Assert.AreEqual(1, CurrentDynamoModel.ClipBoard.Count); CurrentDynamoModel.Paste(); Assert.AreEqual(2, CurrentDynamoModel.CurrentWorkspace.Nodes.Count()); Assert.IsTrue(CurrentDynamoModel.CurrentWorkspace.Nodes.OfType <PythonNode>().All(x => x.EngineName == PythonEngineManager.CPython3EngineName)); CurrentDynamoModel.ExecuteCommand(new UndoRedoCommand(UndoRedoCommand.Operation.Undo)); Assert.AreEqual(1, CurrentDynamoModel.CurrentWorkspace.Nodes.Count()); pyNode.EngineName = PythonEngineManager.IronPython2EngineName; CurrentDynamoModel.ExecuteCommand( new UpdateModelValueCommand( Guid.Empty, pyNode.GUID, nameof(PythonNode.EngineName), PythonEngineManager.CPython3EngineName)); Assert.AreEqual(pyNode.EngineName, PythonEngineManager.CPython3EngineName); CurrentDynamoModel.ExecuteCommand(new UndoRedoCommand(UndoRedoCommand.Operation.Undo)); Assert.AreEqual(pyNode.EngineName, PythonEngineManager.IronPython2EngineName); }
public void CanCopyAndPasteAndUndoOutputState() { var addNode = new DSFunction(CurrentDynamoModel.LibraryServices.GetFunctionDescriptor("+")); CurrentDynamoModel.CurrentWorkspace.AddAndRegisterNode(addNode, false); Assert.AreEqual(1, CurrentDynamoModel.CurrentWorkspace.Nodes.Count()); addNode.IsSetAsOutput = true; CurrentDynamoModel.AddToSelection(addNode); Assert.AreEqual(1, DynamoSelection.Instance.Selection.Count); CurrentDynamoModel.Copy(); Assert.AreEqual(1, CurrentDynamoModel.ClipBoard.Count); CurrentDynamoModel.Paste(); Assert.AreEqual(2, CurrentDynamoModel.CurrentWorkspace.Nodes.Count()); Assert.IsTrue(CurrentDynamoModel.CurrentWorkspace.Nodes.All(x => x.IsSetAsOutput)); CurrentDynamoModel.CurrentWorkspace.Undo(); Assert.AreEqual(1, CurrentDynamoModel.CurrentWorkspace.Nodes.Count()); addNode.IsSetAsOutput = false; CurrentDynamoModel.ExecuteCommand( new DynCmd.UpdateModelValueCommand( Guid.Empty, addNode.GUID, nameof(NodeModel.IsSetAsOutput), "true")); Assert.IsTrue(addNode.IsSetAsOutput); CurrentDynamoModel.CurrentWorkspace.Undo(); Assert.IsFalse(addNode.IsSetAsOutput); }
public void CanCopyAndPasteAndUndoInputState() { var numberNode = new DoubleInput(); CurrentDynamoModel.CurrentWorkspace.AddAndRegisterNode(numberNode, false); Assert.AreEqual(1, CurrentDynamoModel.CurrentWorkspace.Nodes.Count()); numberNode.IsSetAsInput = true; CurrentDynamoModel.AddToSelection(numberNode); Assert.AreEqual(1, DynamoSelection.Instance.Selection.Count); CurrentDynamoModel.Copy(); Assert.AreEqual(1, CurrentDynamoModel.ClipBoard.Count); CurrentDynamoModel.Paste(); Assert.AreEqual(2, CurrentDynamoModel.CurrentWorkspace.Nodes.Count()); Assert.IsTrue(CurrentDynamoModel.CurrentWorkspace.Nodes.All(x => x.IsSetAsInput)); CurrentDynamoModel.CurrentWorkspace.Undo(); Assert.AreEqual(1, CurrentDynamoModel.CurrentWorkspace.Nodes.Count()); numberNode.IsSetAsInput = false; CurrentDynamoModel.ExecuteCommand( new DynCmd.UpdateModelValueCommand( Guid.Empty, numberNode.GUID, nameof(NodeModel.IsSetAsInput), "true")); Assert.IsTrue(numberNode.IsSetAsInput); CurrentDynamoModel.CurrentWorkspace.Undo(); Assert.IsFalse(numberNode.IsSetAsInput); }
public void DelayedExecutionOnCopyPaste() { DynamoSelection.Instance.ClearSelection(); workspaceNodes().ForEach((ele) => DynamoSelection.Instance.Selection.Add(ele)); CurrentDynamoModel.Copy(); activateTaskCounter(originalNodeCount * 2); CurrentDynamoModel.Paste(); Assert.AreEqual(wModel.Nodes.Count(), originalNodeCount * 2); Assert.AreEqual(taskCounter, 1); deactivateTaskCounter(); }
public void TestCopyPasteGroup_IfItsNodeDeletedAfterCopying() { //Add a Node var ws = CurrentDynamoModel.CurrentWorkspace; var addNode = new DSFunction(CurrentDynamoModel.LibraryServices.GetFunctionDescriptor("+")); ws.AddAndRegisterNode(addNode); Assert.AreEqual(ws.Nodes.Count(), 1); //Add a Note var addNote = ws.AddNote(false, 200, 200, "This is a test note", Guid.NewGuid()); Assert.AreEqual(ws.Notes.Count(), 1); //Select the node and notes DynamoSelection.Instance.Selection.Add(addNode); DynamoSelection.Instance.Selection.Add(addNote); //create the group around selected nodes and notes var groupId = Guid.NewGuid(); var annotation = ws.AddAnnotation("This is a test group", groupId); Assert.AreEqual(ws.Annotations.Count(), 1); Assert.AreNotEqual(0, annotation.Width); //Add the group selection DynamoSelection.Instance.Selection.Add(annotation); //Copy the group CurrentDynamoModel.Copy(); var modelToDelete = new List <ModelBase> { addNode }; //Delete the node CurrentDynamoModel.DeleteModelInternal(modelToDelete); // only the note should remain Assert.AreEqual(1, annotation.SelectedModels.Count()); //paste the group CurrentDynamoModel.Paste(); //there should be 2 groups in the workspace Assert.AreEqual(ws.Annotations.Count(), 2); var pastedGroup = ws.Annotations.First(g => g != annotation); // group has been copied with 1 node and 1 note Assert.AreEqual(2, pastedGroup.SelectedModels.Count()); }
public void MAGN_5029_CopyPasteWarning() { // Details are available in defect // http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-5029 // Cutting and pasting Curve.PointAtParameter in run automatically // causes "variable has not yet been defined" warning message string openPath = Path.Combine(TestDirectory, @"core\WorkflowTestFiles\\GeometryDefects\MAGN_5029_CopyPasteWarning.dyn"); RunModel(openPath); AssertNoDummyNodes(); // check all the nodes and connectors are loaded Assert.AreEqual(4, CurrentDynamoModel.CurrentWorkspace.Nodes.Count); Assert.AreEqual(5, CurrentDynamoModel.CurrentWorkspace.Connectors.Count()); //CGet Curve.PointAtParameter node and copy paste it. string nodeID = "de3e5067-d7e2-4e47-aca3-7f2531614892"; var pointAtParameterNode = CurrentDynamoModel.CurrentWorkspace.NodeFromWorkspace(nodeID); // Copy and paste the PointAtParameter Node CurrentDynamoModel.AddToSelection(pointAtParameterNode); CurrentDynamoModel.Copy(); // Copy the selected node. CurrentDynamoModel.Paste(); // Paste the copied node. RunCurrentModel(); // check all the nodes and connectors are updated Assert.AreEqual(5, CurrentDynamoModel.CurrentWorkspace.Nodes.Count); Assert.AreEqual(7, CurrentDynamoModel.CurrentWorkspace.Connectors.Count()); // Make sure we are able to get copy pasted PointAtParameter node. var newPointAtPArameterNode = CurrentDynamoModel.CurrentWorkspace.Nodes[4]; var guid = newPointAtPArameterNode.GUID.ToString(); // Checking there is no Warning or Error on node after copy paste. Assert.AreNotEqual(ElementState.Error, newPointAtPArameterNode.State); Assert.AreNotEqual(ElementState.Warning, newPointAtPArameterNode.State); AssertPreviewCount(guid, 10); for (int i = 0; i <= 9; i++) { var extractedCurves = GetPreviewValueAtIndex(guid, i) as Point; Assert.IsNotNull(extractedCurves); } }
public void PasteInputAndOutputNodeInHomeWorkspace() { const string name = "Custom Node Creation Test"; const string description = "Description"; const string category = "Custom Node Category"; CurrentDynamoModel.ExecuteCommand(new DynamoModel.CreateCustomNodeCommand( Guid.NewGuid(), name, category, description, true)); CurrentDynamoModel.ExecuteCommand(new DynamoModel.CreateNodeCommand( new Symbol(), 0, 0, true, true)); CurrentDynamoModel.ExecuteCommand(new DynamoModel.CreateNodeCommand( new Output(), 0, 0, true, true)); foreach (var node in CurrentDynamoModel.CurrentWorkspace.Nodes) { CurrentDynamoModel.AddToSelection(node); } CurrentDynamoModel.Copy(); var home = CurrentDynamoModel.Workspaces.OfType <HomeWorkspaceModel>().FirstOrDefault(); Assert.NotNull(home); SelectTabByGuid(home.Guid); CurrentDynamoModel.Paste(); var homeNodes = home.Nodes; Assert.AreEqual(2, homeNodes.Count()); Assert.IsInstanceOf <CodeBlockNodeModel>(homeNodes.ElementAt(0)); Assert.IsInstanceOf <CodeBlockNodeModel>(homeNodes.ElementAt(1)); }
public void DelayedExecutionUndoRedoTest() { DynamoSelection.Instance.ClearSelection(); workspaceNodes().ForEach((ele) => DynamoSelection.Instance.Selection.Add(ele)); CurrentDynamoModel.Copy(); CurrentDynamoModel.Paste(); Assert.AreEqual(wModel.Nodes.Count(), originalNodeCount * 2); CurrentDynamoModel.ExecuteCommand(new UndoRedoCommand(UndoRedoCommand.Operation.Undo)); Assert.AreEqual(wModel.Nodes.Count(), originalNodeCount); activateTaskCounter(originalNodeCount); CurrentDynamoModel.ExecuteCommand(new UndoRedoCommand(UndoRedoCommand.Operation.Redo)); Assert.AreEqual(wModel.Nodes.Count(), originalNodeCount * 2); Assert.AreEqual(taskCounter, 1); deactivateTaskCounter(); CurrentDynamoModel.ExecuteCommand(new UndoRedoCommand(UndoRedoCommand.Operation.Undo)); Assert.IsTrue(wModel.Nodes.Count() == originalNodeCount); }
public void TestCopyPasteNestedGroup() { // Arrange var nestedGroupTitle = "Nested Group"; var parentGroupNode = new DummyNode(); var nestedGroupNode = new DummyNode(); CurrentDynamoModel.CurrentWorkspace.AddAndRegisterNode(parentGroupNode, false); CurrentDynamoModel.CurrentWorkspace.AddAndRegisterNode(nestedGroupNode, false); // Created nested group DynamoSelection.Instance.Selection.Add(nestedGroupNode); var nestedGroupId = Guid.NewGuid(); var nestedGroup = CurrentDynamoModel.CurrentWorkspace.AddAnnotation(nestedGroupTitle, "A group inside another group", nestedGroupId); // Create parent group var parentGroup = new AnnotationModel( new NodeModel[] { parentGroupNode }, new NoteModel[] { }, new AnnotationModel[] { nestedGroup }); CurrentDynamoModel.CurrentWorkspace.AddAnnotation(parentGroup); // Act DynamoSelection.Instance.Selection.Add(nestedGroup); CurrentDynamoModel.Copy(); CurrentDynamoModel.Paste(); var copiedGroups = CurrentDynamoModel.CurrentWorkspace.Annotations .Where(x => x.AnnotationText == nestedGroupTitle); var copiedGroup = copiedGroups.Where(x => x.GUID != nestedGroupId); // Assert Assert.That(parentGroup.Nodes.Contains(nestedGroup)); Assert.That(CurrentDynamoModel.CurrentWorkspace.Annotations.Count() == 3); Assert.That(copiedGroups.Count() == 2); Assert.That(copiedGroup.Count() == 1); Assert.IsFalse(parentGroup.Nodes.Contains(copiedGroup.FirstOrDefault())); }
public void CanCopyPasteJSONDummyNodeAndRetainsOriginalJSON() { string openPath = Path.Combine(TestDirectory, testFileWithDummyNode); OpenModel(openPath); Assert.AreEqual(1, CurrentDynamoModel.CurrentWorkspace.Nodes.OfType <DummyNode>().Count()); //select the dummy node CurrentDynamoModel.AddToSelection(CurrentDynamoModel.CurrentWorkspace.Nodes.OfType <DummyNode>().First()); CurrentDynamoModel.Copy(); CurrentDynamoModel.Paste(); //get both dummyNodes Assert.AreEqual(2, CurrentDynamoModel.CurrentWorkspace.Nodes.OfType <DummyNode>().Count()); var dummies = CurrentDynamoModel.CurrentWorkspace.Nodes.OfType <DummyNode>().ToList(); var oc1 = (dummies[0].OriginalNodeContent as JObject).ToString(); var oc2 = (dummies[1].OriginalNodeContent as JObject).ToString(); Console.WriteLine(oc1); Console.WriteLine(oc2); //assert that originalData are the same string Assert.AreEqual(oc1, oc2); }
public void CanCopyAndPasteDSVarArgFunctionNode() { Assert.AreEqual(0, CurrentDynamoModel.CurrentWorkspace.Nodes.Count()); const string dsVarArgFunctionName = "DSCore.String.Split@string,string[]"; var node = new DSVarArgFunction(CurrentDynamoModel.LibraryServices.GetFunctionDescriptor(dsVarArgFunctionName)); CurrentDynamoModel.CurrentWorkspace.AddAndRegisterNode(node, false); // Here we check to see if we do get a DSVarArgFunction node (which // is what this test case is written for, other nodes will render the // test case meaningless). // Assert.AreEqual(1, CurrentDynamoModel.CurrentWorkspace.Nodes.Count()); CurrentDynamoModel.AddToSelection(node); // Select the only DSVarArgFunction node. CurrentDynamoModel.Copy(); // Copy the only DSVarArgFunction node. Assert.DoesNotThrow(() => { CurrentDynamoModel.Paste(); // Nope, paste should not crash Dynamo. }); }