public void TestDeserialize1()
        {
            string code = "a=1;";
            Dictionary <int, List <VariableLine> > unboundIdentifiers = null;
            List <ProtoCore.AST.Node> astNodes = null;

            GraphUtilities.ParseCodeBlockNodeStatements(code, unboundIdentifiers, out astNodes);

            Ui.Statement statement = new Ui.Statement(astNodes[0]);

            IStorage storage = new BinaryStorage();

            statement.Serialize(storage);
            Ui.Statement newStatement = new Ui.Statement(storage);
            storage.Seek(0, SeekOrigin.Begin);
            newStatement.Deserialize(storage);

            VariableSlotInfo outputExpression = new VariableSlotInfo("a", 1, uint.MaxValue);

            Assert.AreEqual("a", statement.DefinedVariable);
            Assert.AreEqual(outputExpression, statement.OutputExpression);
            Assert.AreEqual(0, statement.References.Count);
            Assert.AreEqual(0, statement.Children.Count);
            Assert.AreEqual(false, statement.IsSwappable);
            Assert.AreEqual(false, statement.IsComplex);
        }
Exemplo n.º 2
0
        public void TestDeserilaizeOperationException()
        {
            IGraphController graphController = new GraphController(null);
            IStorage         storage         = new BinaryStorage();
            DataHeader       header          = new DataHeader();

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

            Assert.Throws <InvalidOperationException>(() =>
            {
                header.Deserialize(storage);
            });
        }
Exemplo n.º 3
0
        public void TestGetPosition00()
        {
            //Assert MemoryStream cursor position before/after seek operation.
            //
            IStorage storage    = new BinaryStorage();
            long     beforeSeek = storage.GetPosition();

            Assert.AreEqual(0, beforeSeek);

            storage.Seek(4, SeekOrigin.Current);
            long afterSeek = storage.GetPosition();

            Assert.AreEqual(4, afterSeek);
        }
Exemplo n.º 4
0
        public void TestCreate02()
        {
            IGraphController graphController = new GraphController(null);
            IStorage         storage         = new BinaryStorage();

            storage.WriteUnsignedInteger(FieldCode.NodeSignature, 12);
            storage.WriteInteger(FieldCode.NodeType, 21);
            storage.Seek(0, SeekOrigin.Begin);

            Assert.Throws <ArgumentException>(() =>
            {
                IVisualNode node = VisualNode.Create(graphController, storage);
            });
        }
Exemplo n.º 5
0
        public void TestDeserilaizeOperationException()
        {
            IGraphController graphController = new GraphController(null);
            IStorage         storage         = new BinaryStorage();
            IVisualNode      node            = new FunctionNode(graphController, "", "-", "double,double");
            ISlot            slot            = new Slot(graphController, SlotType.Input, node);

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

            Assert.Throws <InvalidOperationException>(() =>
            {
                slot.Deserialize(storage);
            });
        }
Exemplo n.º 6
0
        public void TestSerializeDeserialize()
        {
            IStorage        storage         = new BinaryStorage();
            GraphController graphController = new GraphController(null);
            EdgeController  edgeController  = new EdgeController(graphController);
            IVisualEdge     edge00          = new VisualEdge(edgeController, 0x30000001, 0x30000002, false);

            edge00.Serialize(storage);
            storage.Seek(0, SeekOrigin.Begin);
            IVisualEdge edge01 = VisualEdge.Create(edgeController, storage);

            Assert.AreEqual(edge00.EdgeId, edge01.EdgeId);
            Assert.AreEqual(edge00.StartSlotId, edge01.StartSlotId);
            Assert.AreEqual(edge00.EndSlotId, edge01.EndSlotId);
        }
Exemplo n.º 7
0
        public void TestDeserilaizeOperationException()
        {
            IStorage        storage         = new BinaryStorage();
            GraphController graphController = new GraphController(null);
            EdgeController  edgeController  = new EdgeController(graphController);
            IVisualEdge     edge            = new VisualEdge(edgeController, 0x30000001, 0x30000002, false);

            storage.WriteUnsignedInteger(FieldCode.EdgeSignature, 12);
            storage.Seek(0, SeekOrigin.Begin);

            Assert.Throws <InvalidOperationException>(() =>
            {
                edge.Deserialize(storage);
            });
        }
Exemplo n.º 8
0
        public void TestDeserilaizeOperationException()
        {
            IGraphController graphController = new GraphController(null);
            IStorage         storage         = new BinaryStorage();
            CondensedNode    node            = new CondensedNode(graphController, "Hello World");

            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);
        }
Exemplo n.º 9
0
        public void TestDeserilaizeOperationException()
        {
            IGraphController graphController = new GraphController(null);
            IStorage         storage         = new BinaryStorage();
            IVisualNode      node            = new DriverNode(graphController, Configurations.DriverInitialTextValue);

            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);
        }
Exemplo n.º 10
0
        public void TestCreate02()
        {
            IGraphController graphController = new GraphController(null);
            IStorage         storage         = new BinaryStorage();
            IVisualNode      node            = new FunctionNode(graphController, "", "-", "double,double");
            ISlot            slot1           = new Slot(graphController, SlotType.Input, node);

            slot1.Serialize(storage);
            storage.Seek(0, SeekOrigin.Begin);
            ISlot slot2 = Slot.Create(graphController, storage);

            Assert.AreEqual(SlotType.Input, slot2.SlotType);
            Assert.AreEqual(slot1.SlotId, slot2.SlotId);
            Assert.AreEqual(slot1.Owners[0], slot2.Owners[0]);
            Assert.AreEqual(slot1.ConnectingSlots, slot2.ConnectingSlots);
        }
Exemplo n.º 11
0
        public void TestSerializeDeserialize()
        {
            IGraphController graphController = new GraphController(null);
            IStorage         storage         = new BinaryStorage();
            DataHeader       header1         = new DataHeader();

            header1.DataSize = 21;
            DataHeader header2 = new DataHeader();

            header2.DataSize = 12;

            header1.Serialize(storage);
            storage.Seek(0, SeekOrigin.Begin);
            header2.Deserialize(storage);

            Assert.AreEqual(21, header2.DataSize);
        }
Exemplo n.º 12
0
        public void TestReadWriteLong01()
        {
            //Functionality test on ReadLong(ulong expectedSignature) and WriteLong(ulong signature, long value)
            //Initial value expected since matched signature.
            //
            IStorage storage   = new BinaryStorage();
            ulong    signature = Utilities.MakeEightCC('T', 'E', 'S', 'T', ' ', 'L', 'N', 'G');

            storage.WriteLong(signature, 3000000000);
            long position = storage.GetPosition();

            Assert.AreEqual(16, position);

            storage.Seek(0, SeekOrigin.Begin);
            long returned = storage.ReadLong(signature);

            Assert.AreEqual(3000000000, returned);
        }
Exemplo n.º 13
0
        public void TestReadWriteDouble03()
        {
            //Functionality test on ReadDouble(ulong expectedSignature, double defaultValue) and WriteDouble(ulong signature, double value)
            //Initial value expected since matched signature.
            //
            IStorage storage   = new BinaryStorage();
            ulong    signature = Utilities.MakeEightCC('T', 'E', 'S', 'T', ' ', 'D', 'B', 'L');

            storage.WriteDouble(signature, 1.2);
            long position = storage.GetPosition();

            Assert.AreEqual(16, position);

            storage.Seek(0, SeekOrigin.Begin);
            double returned = storage.ReadDouble(signature, 2.1);

            Assert.AreEqual(1.2, returned);
        }
Exemplo n.º 14
0
        public void TestReadWriteString03()
        {
            //Functionality test on ReadString(ulong expectedSignature, string defaultValue) and WriteString(ulong signature, string value)
            //Initial value expected since matched signature.
            //
            IStorage storage   = new BinaryStorage();
            ulong    signature = Utilities.MakeEightCC('T', 'E', 'S', 'T', ' ', 'S', 'T', 'R');

            storage.WriteString(signature, "Hello World");
            long position = storage.GetPosition();

            Assert.AreEqual(20, position);

            storage.Seek(0, SeekOrigin.Begin);
            string returned = storage.ReadString(signature, "World Hello");

            Assert.AreEqual("Hello World", returned);
        }
Exemplo n.º 15
0
        public void TestReadWriteBoolean03()
        {
            //Functionality test on ReadBoolean(ulong expectedSignature, bool defaultValue) and WriteBoolean(ulong signature, bool value)
            //Initial value expected since matched signature.
            //
            IStorage storage   = new BinaryStorage();
            ulong    signature = Utilities.MakeEightCC('T', 'E', 'S', 'T', 'B', 'O', 'O', 'L');

            storage.WriteBoolean(signature, true);
            long position = storage.GetPosition();

            Assert.AreEqual(9, position);

            storage.Seek(0, SeekOrigin.Begin);
            bool returned = storage.ReadBoolean(signature, false);

            Assert.AreEqual(true, returned);
        }
Exemplo n.º 16
0
        public void TestReadWriteUnsignedLong03()
        {
            //Functionality test on ReadUnsignedLong(ulong expectedSignature, long defaultValue) and WriteUnsignedLong(ulong signature, long value)
            //Initial value expected since matched signature.
            //
            IStorage storage   = new BinaryStorage();
            ulong    signature = Utilities.MakeEightCC('T', 'E', 'S', 'T', 'U', 'L', 'N', 'G');

            storage.WriteUnsignedLong(signature, 9223372036854775808);
            long position = storage.GetPosition();

            Assert.AreEqual(16, position);

            storage.Seek(0, SeekOrigin.Begin);
            ulong returned = storage.ReadUnsignedLong(signature, 9223372036854775809);

            Assert.AreEqual(9223372036854775808, returned);
        }
Exemplo n.º 17
0
        public void TestReadWriteUnsignedInteger03()
        {
            //Functionality test on ReadUnsignedInteger(ulong expectedSignature, uint defaultValue) and WriteUnsignedInteger(ulong signature, uint value)
            //Initial value expected since matched signature.
            //
            IStorage storage   = new BinaryStorage();
            ulong    signature = Utilities.MakeEightCC('T', 'E', 'S', 'T', ' ', 'I', 'N', 'T');

            storage.WriteUnsignedInteger(signature, 2147483648);
            long position = storage.GetPosition();

            Assert.AreEqual(12, position);

            storage.Seek(0, SeekOrigin.Begin);
            uint returned = storage.ReadUnsignedInteger(signature, 2147483649);

            Assert.AreEqual(2147483648, returned);
        }
Exemplo n.º 18
0
        public void TestReadWriteInteger02()
        {
            //Functionality test on ReadInteger(ulong expectedSignature, int defaultValue) and WriteInteger(ulong signature, int value)
            //Default value expected due to unmatched signature.
            //
            IStorage storage     = new BinaryStorage();
            ulong    signature00 = Utilities.MakeEightCC('T', 'E', 'S', 'T', ' ', 'I', 'N', 'T');
            ulong    signature01 = Utilities.MakeEightCC('T', 'E', 'S', 'T', '_', 'I', 'N', 'T');

            storage.WriteInteger(signature00, 12);
            long position = storage.GetPosition();

            Assert.AreEqual(12, position);

            storage.Seek(0, SeekOrigin.Begin);
            int returned = storage.ReadInteger(signature01, 21);

            Assert.AreEqual(21, returned);
        }
Exemplo n.º 19
0
        public void TestGetPosition01()
        {
            //Assert MemoryStream cursor position before/after read operation.
            //MemoryStream needs to be written before reading, hence the involvement of write operation in this test.
            //
            IStorage storage    = new BinaryStorage();
            long     beforeRead = storage.GetPosition();

            Assert.AreEqual(0, beforeRead);

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

            storage.WriteInteger(signature, 12);
            storage.Seek(-12, SeekOrigin.End);
            storage.ReadInteger(signature);
            long afterRead = storage.GetPosition();

            Assert.AreEqual(12, afterRead);
        }
Exemplo n.º 20
0
        [Ignore] // to create regression to nunit in jenkins - will remove this - Monika
        public void TestSerializeDeserialize()
        {
            IGraphController graphController = new GraphController(null);
            IStorage         storage         = new BinaryStorage();

            IVisualNode node1 = new CondensedNode(graphController, "Hello World");
            IVisualNode node2 = new CondensedNode(graphController, "ABC");

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

            Assert.AreEqual(NodeType.Condensed, node2.VisualType);
            Assert.AreEqual(node1.NodeId, node2.NodeId);
            Assert.AreEqual(true, ((CondensedNode)node2).Dirty);
            Assert.AreEqual(((CondensedNode)node1).Text, ((CondensedNode)node2).Text);
            Assert.AreEqual(((CondensedNode)node1).Caption, ((CondensedNode)node2).Caption);
            Assert.AreEqual(node1.X, node2.X);
            Assert.AreEqual(node1.Y, node2.Y);
        }
Exemplo n.º 21
0
        public void TestReadWriteBytes01()
        {
            //Functionality test on ReadBytes(ulong expectedSignature) and WriteBytes(ulong signature, int value)
            //Initial value expected since matched signature.
            //
            IStorage storage = new BinaryStorage();
            string   str     = "Hello World";

            byte[] actual    = Encoding.ASCII.GetBytes(str);
            ulong  signature = Utilities.MakeEightCC('T', 'E', 'S', 'T', 'B', 'Y', 'T', 'E');

            storage.WriteBytes(signature, actual);
            long position = storage.GetPosition();

            Assert.AreEqual(23, position);

            storage.Seek(0, SeekOrigin.Begin);
            byte[] returned = storage.ReadBytes(signature);
            Assert.AreEqual(actual, returned);
        }
Exemplo n.º 22
0
        public void TestReadWriteString00()
        {
            //Functionality test on ReadString(ulong expectedSignature) and WriteDouble(ulong signature, string value)
            //Exception expected due to unmatched signature.
            //
            IStorage storage     = new BinaryStorage();
            ulong    signature00 = Utilities.MakeEightCC('T', 'E', 'S', 'T', ' ', 'S', 'T', 'R');
            ulong    signature01 = Utilities.MakeEightCC('T', 'E', 'S', 'T', '_', 'S', 'T', 'R');

            storage.WriteString(signature00, "Hello World");
            long position = storage.GetPosition();

            Assert.AreEqual(20, position);

            storage.Seek(0, SeekOrigin.Begin);
            Assert.Throws <InvalidDataException>(() =>
            {
                string returned = storage.ReadString(signature01);
            });
        }
Exemplo n.º 23
0
        public void TestReadWriteDouble00()
        {
            //Functionality test on ReadDouble(ulong expectedSignature) and WriteDouble(ulong signature, double value)
            //Exception expected due to unmatched signature.
            //
            IStorage storage     = new BinaryStorage();
            ulong    signature00 = Utilities.MakeEightCC('T', 'E', 'S', 'T', ' ', 'D', 'B', 'L');
            ulong    signature01 = Utilities.MakeEightCC('T', 'E', 'S', 'T', '_', 'D', 'B', 'L');

            storage.WriteDouble(signature00, 1.2);
            long position = storage.GetPosition();

            Assert.AreEqual(16, position);

            storage.Seek(0, SeekOrigin.Begin);
            Assert.Throws <InvalidDataException>(() =>
            {
                double returned = storage.ReadDouble(signature01);
            });
        }
Exemplo n.º 24
0
        public void TestReadWriteUnsignedLong00()
        {
            //Functionality test on ReadUnsignedLong(ulong expectedSignature) and WriteUnsignedLong(ulong signature, long value)
            //Exception expected due to unmatched signature.
            //
            IStorage storage     = new BinaryStorage();
            ulong    signature00 = Utilities.MakeEightCC('T', 'E', 'S', 'T', 'U', 'L', 'N', 'G');
            ulong    signature01 = Utilities.MakeEightCC('T', 'E', 'S', 'T', '_', '_', '_', '_');

            storage.WriteUnsignedLong(signature00, 9223372036854775808);
            long position = storage.GetPosition();

            Assert.AreEqual(16, position);

            storage.Seek(0, SeekOrigin.Begin);
            Assert.Throws <InvalidDataException>(() =>
            {
                ulong returned = storage.ReadUnsignedLong(signature01);
            });
        }
Exemplo n.º 25
0
        public void TestReadWriteUnsignedInteger00()
        {
            //Functionality test on ReadUnsignedInteger(ulong expectedSignature) and WriteUnsignedInteger(ulong signature, uint value)
            //Exception expected due to unmatched signature.
            //
            IStorage storage     = new BinaryStorage();
            ulong    signature00 = Utilities.MakeEightCC('T', 'E', 'S', 'T', 'U', 'I', 'N', 'T');
            ulong    signature01 = Utilities.MakeEightCC('T', 'E', 'S', 'T', '_', 'I', 'N', 'T');

            storage.WriteUnsignedInteger(signature00, 2147483648);
            long position = storage.GetPosition();

            Assert.AreEqual(12, position);

            storage.Seek(0, SeekOrigin.Begin);
            Assert.Throws <InvalidDataException>(() =>
            {
                uint returned = storage.ReadUnsignedInteger(signature01);
            });
        }
Exemplo n.º 26
0
        public void TestSerializeDeserialize()
        {
            IGraphController graphController = new GraphController(null);
            IStorage         storage         = new BinaryStorage();

            IVisualNode node1 = new RenderNode(graphController, 1);
            IVisualNode node2 = new RenderNode(graphController, 1);

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

            Assert.AreEqual(NodeType.Render, node2.VisualType);
            Assert.AreEqual(node1.NodeId, node2.NodeId);
            Assert.AreEqual(true, ((RenderNode)node2).Dirty);
            Assert.AreEqual(((RenderNode)node1).Text, ((RenderNode)node2).Text);
            Assert.AreEqual(((RenderNode)node1).Caption, ((RenderNode)node2).Caption);
            Assert.AreEqual(node1.X, node2.X);
            Assert.AreEqual(node1.Y, node2.Y);
            //Assert.AreEqual(1, node2.GetInputSlots().Length);
            //Assert.AreEqual(0, node2.GetOutputSlots().Length);
        }
Exemplo n.º 27
0
        public void TestReadWriteBytes00()
        {
            //Functionality test on ReadBytes(ulong expectedSignature) and WriteBytes(ulong signature, int value)
            //Exception expected due to unmatched signature.
            //
            IStorage storage = new BinaryStorage();
            string   str     = "Hello World";

            byte[] actual      = Encoding.ASCII.GetBytes(str);
            ulong  signature00 = Utilities.MakeEightCC('T', 'E', 'S', 'T', 'B', 'Y', 'T', 'E');
            ulong  signature01 = Utilities.MakeEightCC('T', 'E', 'S', 'T', '_', '_', '_', '_');

            storage.WriteBytes(signature00, actual);
            long position = storage.GetPosition();

            Assert.AreEqual(23, position);

            storage.Seek(0, SeekOrigin.Begin);
            Assert.Throws <InvalidDataException>(() =>
            {
                byte[] returned = storage.ReadBytes(signature01);
            });
        }
Exemplo n.º 28
0
        public void TestReadWriteBytes02()
        {
            //Functionality test on ReadBytes(ulong expectedSignature, int defaultValue) and WriteBytes(ulong signature, int value)
            //Default value expected due to unmatched signature.
            //
            IStorage storage = new BinaryStorage();
            string   str00   = "Hello World";

            byte[] actual = Encoding.ASCII.GetBytes(str00);
            string str01  = "World Hello";

            byte[] defaultValue = Encoding.ASCII.GetBytes(str01);
            ulong  signature00  = Utilities.MakeEightCC('T', 'E', 'S', 'T', 'B', 'Y', 'T', 'E');
            ulong  signature01  = Utilities.MakeEightCC('T', 'E', 'S', 'T', '_', '_', '_', '_');

            storage.WriteBytes(signature00, actual);
            long position = storage.GetPosition();

            Assert.AreEqual(23, position);

            storage.Seek(0, SeekOrigin.Begin);
            byte[] returned = storage.ReadBytes(signature01, defaultValue);
            Assert.AreEqual(defaultValue, returned);
        }