public void TestDeserializeNullException()
        {
            IGraphController graphController = new GraphController(null);
            IStorage storage = null;
            IVisualNode node = new IdentifierNode(graphController, "a");

            Assert.Throws<ArgumentNullException>(() =>
            {
                node.Deserialize(storage);
            });
        }
        public void TestDeserializeNullException()
        {
            IGraphController graphController = new GraphController(null);
            IStorage         storage         = null;
            IVisualNode      node            = new IdentifierNode(graphController, "a");

            Assert.Throws <ArgumentNullException>(() =>
            {
                node.Deserialize(storage);
            });
        }
        public void TestDeserilaizeOperationException()
        {
            IGraphController graphController = new GraphController(null);
            IStorage         storage         = new BinaryStorage();
            IVisualNode      node            = new IdentifierNode(graphController, "a");

            ulong signature = Utilities.MakeEightCC('T', 'E', 'S', 'T', ' ', ' ', ' ', ' ');

            storage.WriteUnsignedInteger(signature, 21);
            storage.Seek(0, SeekOrigin.Begin);

            bool result = node.Deserialize(storage);

            Assert.AreEqual(result, false);
        }
        public void TestSerializeDeserialize()
        {
            IGraphController graphController = new GraphController(null);
            IStorage         storage         = new BinaryStorage();

            IVisualNode node1 = new IdentifierNode(graphController, "a");
            IVisualNode node2 = new IdentifierNode(graphController, "b");

            node1.Serialize(storage);
            storage.Seek(0, SeekOrigin.Begin);
            node2.Deserialize(storage);

            Assert.AreEqual(NodeType.Identifier, node2.VisualType);
            Assert.AreEqual(node1.NodeId, node2.NodeId);
            Assert.AreEqual(true, ((IdentifierNode)node2).Dirty);
            Assert.AreEqual(((IdentifierNode)node1).Text, ((IdentifierNode)node2).Text);
            Assert.AreEqual(((IdentifierNode)node1).Caption, ((IdentifierNode)node2).Caption);
            Assert.AreEqual(node1.X, node2.X);
            Assert.AreEqual(node1.Y, node2.Y);
            Assert.AreEqual(1, node2.GetInputSlots().Length);
            Assert.AreEqual(1, node2.GetOutputSlots().Length);
        }
Beispiel #5
0
        public static IVisualNode Create(IGraphController graphController, IStorage storage)
        {
            if (graphController == null || storage == null)
                throw new ArgumentNullException("graphcontroller, storage");

            storage.Seek(12, SeekOrigin.Current); //Skip NodeSignature
            NodeType type = (NodeType)storage.ReadInteger(FieldCode.NodeType);
            storage.Seek(-24, SeekOrigin.Current); //Shift cursor back to the start point of reading NodeSignature
            VisualNode node = null;
            switch (type)
            {
                case NodeType.CodeBlock:
                    node = new CodeBlockNode(graphController);
                    node.Deserialize(storage);
                    break;
                case NodeType.Condensed:
                    node = new CondensedNode(graphController);
                    node.Deserialize(storage);
                    break;
                case NodeType.Driver:
                    node = new DriverNode(graphController);
                    node.Deserialize(storage);
                    break;
                case NodeType.Function:
                    node = new FunctionNode(graphController);
                    node.Deserialize(storage);
                    break;
                case NodeType.Identifier:
                    node = new IdentifierNode(graphController);
                    node.Deserialize(storage);
                    break;
                case NodeType.Property:
                    node = new PropertyNode(graphController);
                    node.Deserialize(storage);
                    break;
                case NodeType.Render:
                    node = new RenderNode(graphController);
                    node.Deserialize(storage);
                    break;
                default:
                    throw new ArgumentException("Invalid 'nodeType'");
            }

            return node;
        }
        public void TestDeserilaizeOperationException()
        {
            IGraphController graphController = new GraphController(null);
            IStorage storage = new BinaryStorage();
            IVisualNode node = new IdentifierNode(graphController, "a");

            ulong signature = Utilities.MakeEightCC('T', 'E', 'S', 'T', ' ', ' ', ' ', ' ');
            storage.WriteUnsignedInteger(signature, 21);
            storage.Seek(0, SeekOrigin.Begin);

            bool result = node.Deserialize(storage);
            Assert.AreEqual(result, false);
        }
        public void TestSerializeDeserialize()
        {
            IGraphController graphController = new GraphController(null);
            IStorage storage = new BinaryStorage();

            IVisualNode node1 = new IdentifierNode(graphController, "a");
            IVisualNode node2 = new IdentifierNode(graphController, "b");

            node1.Serialize(storage);
            storage.Seek(0, SeekOrigin.Begin);
            node2.Deserialize(storage);

            Assert.AreEqual(NodeType.Identifier, node2.VisualType);
            Assert.AreEqual(node1.NodeId, node2.NodeId);
            Assert.AreEqual(true, ((IdentifierNode)node2).Dirty);
            Assert.AreEqual(((IdentifierNode)node1).Text, ((IdentifierNode)node2).Text);
            Assert.AreEqual(((IdentifierNode)node1).Caption, ((IdentifierNode)node2).Caption);
            Assert.AreEqual(node1.X, node2.X);
            Assert.AreEqual(node1.Y, node2.Y);
            Assert.AreEqual(1, node2.GetInputSlots().Length);
            Assert.AreEqual(1, node2.GetOutputSlots().Length);
        }