public void Test_MoveStackedNodeAction_ToSameStack([Values] TestingMode mode) { var stack = GraphModel.CreateStack(string.Empty, Vector2.zero); var nodeA = stack.CreateStackedNode <Type0FakeNodeModel>("A"); var nodeB = stack.CreateStackedNode <Type0FakeNodeModel>("B"); var nodeC = stack.CreateStackedNode <Type0FakeNodeModel>("C"); var nodeD = stack.CreateStackedNode <Type0FakeNodeModel>("D"); TestPrereqActionPostreq(mode, () => { Assert.That(stack.NodeModels.Count, Is.EqualTo(4)); Assert.That(nodeA, Has.IndexInStack(0, stack)); Assert.That(nodeB, Has.IndexInStack(1, stack)); Assert.That(nodeC, Has.IndexInStack(2, stack)); Assert.That(nodeD, Has.IndexInStack(3, stack)); return(new MoveStackedNodesAction(new[] { nodeA }, stack, 2)); }, () => { Assert.That(stack.NodeModels.Count, Is.EqualTo(4)); Assert.That(nodeB, Has.IndexInStack(0, stack)); Assert.That(nodeC, Has.IndexInStack(1, stack)); Assert.That(nodeA, Has.IndexInStack(2, stack)); Assert.That(nodeD, Has.IndexInStack(3, stack)); }); TestPrereqActionPostreq(mode, () => { Assert.That(stack.NodeModels.Count, Is.EqualTo(4)); Assert.That(nodeB, Has.IndexInStack(0, stack)); Assert.That(nodeC, Has.IndexInStack(1, stack)); Assert.That(nodeA, Has.IndexInStack(2, stack)); Assert.That(nodeD, Has.IndexInStack(3, stack)); return(new MoveStackedNodesAction(new[] { nodeD }, stack, 0)); }, () => { Assert.That(stack.NodeModels.Count, Is.EqualTo(4)); Assert.That(nodeD, Has.IndexInStack(0, stack)); Assert.That(nodeB, Has.IndexInStack(1, stack)); Assert.That(nodeC, Has.IndexInStack(2, stack)); Assert.That(nodeA, Has.IndexInStack(3, stack)); }); }
public void Test_ChangeStackedNode_ToSameNodeModel([Values] TestingMode mode) { var stackModel = GraphModel.CreateStack(string.Empty, Vector2.zero); var nodeA = stackModel.CreateStackedNode <Type0FakeNodeModel>("A"); var unaryNode = stackModel.CreateUnaryStatementNode(UnaryOperatorKind.PostDecrement, 1); var nodeB = stackModel.CreateStackedNode <Type0FakeNodeModel>("B"); var variableNode = GraphModel.CreateVariableNode( ScriptableObject.CreateInstance <VariableDeclarationModel>(), Vector2.zero); GraphModel.CreateEdge(unaryNode.InputPort, variableNode.OutputPort); var db = new GraphElementSearcherDatabase(Stencil).AddUnaryOperators().Build(); var item = (StackNodeModelSearcherItem)db.Search("postincr", out _)[0]; TestPrereqActionPostreq(mode, () => { Assert.That(stackModel.NodeModels.Count, Is.EqualTo(3)); Assert.That(nodeA, Has.IndexInStack(0, stackModel)); var oldNode = GetStackedNode(0, 1) as UnaryOperatorNodeModel; Assert.NotNull(oldNode); Assert.That(nodeB, Has.IndexInStack(2, stackModel)); Assert.That(variableNode.OutputPort, Is.ConnectedTo(oldNode.InputPort)); return(new ChangeStackedNodeAction(oldNode, stackModel, item)); }, () => { Assert.That(stackModel.NodeModels.Count, Is.EqualTo(3)); Assert.That(nodeA, Has.IndexInStack(0, stackModel)); Assert.That(unaryNode.IsStacked, Is.False); Assert.That(nodeB, Has.IndexInStack(2, stackModel)); var newNode = GetStackedNode(0, 1); Assert.That(newNode, Is.Not.Null); Assert.That(newNode, Is.InstanceOf <UnaryOperatorNodeModel>()); var newUnaryNode = (UnaryOperatorNodeModel)newNode; Assert.That(newUnaryNode.kind, Is.EqualTo(UnaryOperatorKind.PostIncrement)); Assert.That(variableNode.OutputPort, Is.ConnectedTo(newUnaryNode.InputPort)); }); }
public void Test_MoveMultipleStackedNodesAction_ToDifferentStack([Values] TestingMode mode) { var stack0 = GraphModel.CreateStack(string.Empty, Vector2.zero); var nodeA = stack0.CreateStackedNode <Type0FakeNodeModel>("A"); var nodeB = stack0.CreateStackedNode <Type0FakeNodeModel>("B"); var nodeC = stack0.CreateStackedNode <Type0FakeNodeModel>("C"); var stack1 = GraphModel.CreateStack(string.Empty, Vector2.zero); var nodeD = stack1.CreateStackedNode <Type0FakeNodeModel>("D"); var nodeE = stack1.CreateStackedNode <Type0FakeNodeModel>("E"); var nodeF = stack1.CreateStackedNode <Type0FakeNodeModel>("F"); TestPrereqActionPostreq(mode, () => { Assert.That(stack0.NodeModels.Count, Is.EqualTo(3)); Assert.That(nodeA, Has.IndexInStack(0, stack0)); Assert.That(nodeB, Has.IndexInStack(1, stack0)); Assert.That(nodeC, Has.IndexInStack(2, stack0)); Assert.That(stack1.NodeModels.Count, Is.EqualTo(3)); Assert.That(nodeD, Has.IndexInStack(0, stack1)); Assert.That(nodeE, Has.IndexInStack(1, stack1)); Assert.That(nodeF, Has.IndexInStack(2, stack1)); return(new MoveStackedNodesAction(new[] { nodeA, nodeC }, stack1, 1)); }, () => { Assert.That(stack0.NodeModels.Count, Is.EqualTo(1)); Assert.That(nodeB, Has.IndexInStack(0, stack0)); Assert.That(stack1.NodeModels.Count, Is.EqualTo(5)); Assert.That(nodeD, Has.IndexInStack(0, stack1)); Assert.That(nodeA, Has.IndexInStack(1, stack1)); Assert.That(nodeC, Has.IndexInStack(2, stack1)); Assert.That(nodeE, Has.IndexInStack(3, stack1)); Assert.That(nodeF, Has.IndexInStack(4, stack1)); }); TestPrereqActionPostreq(mode, () => { Assert.That(stack0.NodeModels.Count, Is.EqualTo(1)); Assert.That(nodeB, Has.IndexInStack(0, stack0)); Assert.That(stack1.NodeModels.Count, Is.EqualTo(5)); Assert.That(nodeD, Has.IndexInStack(0, stack1)); Assert.That(nodeA, Has.IndexInStack(1, stack1)); Assert.That(nodeC, Has.IndexInStack(2, stack1)); Assert.That(nodeE, Has.IndexInStack(3, stack1)); Assert.That(nodeF, Has.IndexInStack(4, stack1)); return(new MoveStackedNodesAction(new[] { nodeF, nodeD }, stack0, 0)); }, () => { Assert.That(stack0.NodeModels.Count, Is.EqualTo(3)); Assert.That(nodeF, Has.IndexInStack(0, stack0)); Assert.That(nodeD, Has.IndexInStack(1, stack0)); Assert.That(nodeB, Has.IndexInStack(2, stack0)); Assert.That(stack1.NodeModels.Count, Is.EqualTo(3)); Assert.That(nodeA, Has.IndexInStack(0, stack1)); Assert.That(nodeC, Has.IndexInStack(1, stack1)); Assert.That(nodeE, Has.IndexInStack(2, stack1)); }); TestPrereqActionPostreq(mode, () => { Assert.That(stack0.NodeModels.Count, Is.EqualTo(3)); Assert.That(nodeF, Has.IndexInStack(0, stack0)); Assert.That(nodeD, Has.IndexInStack(1, stack0)); Assert.That(nodeB, Has.IndexInStack(2, stack0)); Assert.That(stack1.NodeModels.Count, Is.EqualTo(3)); Assert.That(nodeA, Has.IndexInStack(0, stack1)); Assert.That(nodeC, Has.IndexInStack(1, stack1)); Assert.That(nodeE, Has.IndexInStack(2, stack1)); return(new MoveStackedNodesAction(new[] { nodeF, nodeC }, stack1, 2)); }, () => { Assert.That(stack0.NodeModels.Count, Is.EqualTo(2)); Assert.That(nodeD, Has.IndexInStack(0, stack0)); Assert.That(nodeB, Has.IndexInStack(1, stack0)); Assert.That(stack1.NodeModels.Count, Is.EqualTo(4)); Assert.That(nodeA, Has.IndexInStack(0, stack1)); Assert.That(nodeE, Has.IndexInStack(1, stack1)); Assert.That(nodeF, Has.IndexInStack(2, stack1)); Assert.That(nodeC, Has.IndexInStack(3, stack1)); }); }