Example #1
0
        void CheckNodeList(IReadOnlyList <INodeModel> nodeModels, Dictionary <GUID, int> existingGuids = null)
        {
            if (existingGuids == null)
            {
                existingGuids = new Dictionary <GUID, int>(nodeModels.Count * 4); // wild guess of total number of nodes, including stacked nodes
            }
            for (var i = 0; i < nodeModels.Count; i++)
            {
                INodeModel node = nodeModels[i];

                Assert.IsTrue(node.NodeAssetReference != null, $"Node asset {i} is null");
                Assert.IsNotNull(node, $"Node {i} is null");
                Assert.IsTrue(AssetModel.IsSameAsset(node.AssetModel), $"Node {i} asset is not matching its actual asset");
                Assert.IsFalse(node.Guid.Empty(), $"Node {i} ({node.GetType()}) has an empty Guid");
                Assert.IsFalse(existingGuids.TryGetValue(node.Guid, out var oldIndex), $"duplicate GUIDs: Node {i} ({node.GetType()}) and Node {oldIndex}");
                existingGuids.Add(node.Guid, i);

                if (node.Destroyed)
                {
                    continue;
                }
                CheckNodePorts(node.InputsById);
                CheckNodePorts(node.OutputsById);
                if (node is IStackModel stackModel)
                {
                    CheckNodeList(stackModel.NodeModels, existingGuids);
                }
            }
        }
Example #2
0
        void CheckNodeList(IList <INodeModel> nodeModels, Dictionary <GUID, int> existingGuids = null)
        {
            if (existingGuids == null)
            {
                existingGuids = new Dictionary <GUID, int>(nodeModels.Count * 4); // wild guess of total number of nodes, including stacked nodes
            }
            for (var i = 0; i < nodeModels.Count; i++)
            {
                INodeModel node = nodeModels[i];

                Assert.IsTrue(node.GraphModel != null, $"Node {i} {node} graph is null");
                Assert.IsTrue(node.SerializableAsset != null, $"Node {i} {node} asset is null");
                Assert.IsNotNull(node, $"Node {i} is null");
                Assert.IsTrue(AssetModel.IsSameAsset(node.AssetModel), $"Node {i} asset is not matching its actual asset");
                Assert.IsFalse(node.Guid.Empty(), $"Node {i} ({node.GetType()}) has an empty Guid");
                Assert.IsFalse(existingGuids.TryGetValue(node.Guid, out var oldIndex), $"duplicate GUIDs: Node {i} ({node.GetType()}) and Node {oldIndex} have the same guid {node.Guid}");
                existingGuids.Add(node.Guid, i);

                if (node.Destroyed)
                {
                    continue;
                }
                CheckNodePorts(node.InputsById);
                CheckNodePorts(node.OutputsById);
                if (node is IStackModel stackModel)
                {
                    CheckNodeList(stackModel.NodeModels, existingGuids);
                }

                if (node is VariableNodeModel variableNode)
                {
                    Assert.IsNotNull(variableNode.DeclarationModel, $"Variable Node {i} {variableNode.Title} has a null declaration model");
                    if (variableNode.DeclarationModel.VariableType == VariableType.GraphVariable)
                    {
                        var originalDeclarations = GraphVariableModels.Where(d => d.GetId() == variableNode.DeclarationModel.GetId());
                        Assert.IsTrue(originalDeclarations.Count() <= 1);
                        var originalDeclaration = originalDeclarations.SingleOrDefault();
                        Assert.IsNotNull(originalDeclaration, $"Variable Node {i} {variableNode.Title} has a declaration model, but it was not present in the graph's variable declaration list");
                        Assert.IsTrue(ReferenceEquals(originalDeclaration, variableNode.DeclarationModel), $"Variable Node {i} {variableNode.Title} has a declaration model that was not ReferenceEquals() to the matching one in the graph");
                    }
                }
            }
        }
Example #3
0
        void CheckNodeList(IReadOnlyList <INodeModel> nodeModels)
        {
            for (var i = 0; i < nodeModels.Count; i++)
            {
                INodeModel node = nodeModels[i];

                Assert.IsTrue(node.NodeAssetReference != null, $"Node asset {i} is null");
                Assert.IsNotNull(node, $"Node {i} is null");
                Assert.IsTrue(AssetModel.IsSameAsset(node.AssetModel), $"Node {i} asset is not matching its actual asset");

                if (node.NodeAssetReference == null)
                {
                    continue;
                }
                CheckNodePorts(node.InputsById);
                CheckNodePorts(node.OutputsById);
                if (node is IStackModel stackModel)
                {
                    CheckNodeList(stackModel.NodeModels);
                }
            }
        }