コード例 #1
0
    public void testEncodeDecodeOperations()
    {
        byte[] buff = new byte[1024];

        for (int i = 0; i < 1024; i++)
        {
            buff[i] = 0;
        }

        Console.Out.WriteLine("  [executing test (testEncodeDecodeOperations)(TP_3.3.5.3)] ");

        // fill msg1, select ListA as active.
        msgIn1.getHeader().getHeaderRec().setMessageID(500);
        msgIn1.getBody().getVariantTop().setFieldValue(0);
        for (ushort i = 0; i < 5; ++i)
        {
            MsgIn.Body.VariantTop.ListA.RecA1 temprec = new MsgIn.Body.VariantTop.ListA.RecA1();
            temprec.setFieldA1((short)(10 + i));
            msgIn1.getBody().getVariantTop().getListA().addElement(temprec);
        }

        // fill msg2, select ListB as active.
        msgIn2.getHeader().getHeaderRec().setMessageID(1000);
        msgIn2.getBody().getVariantTop().setFieldValue(1);
        for (ushort i = 0; i < 10; ++i)
        {
            MsgIn.Body.VariantTop.ListB.RecB1 temprec = new MsgIn.Body.VariantTop.ListB.RecB1();
            temprec.setFieldB1((short)(20 + i));
            msgIn2.getBody().getVariantTop().getListB().addElement(temprec);
        }

        // encode/decode msg2 into msg1.  verify ListB now active in msg1 and verify list contents copied over
        msgIn2.encode(buff, 0);
        msgIn1.decode(buff, 0);

        Assert.AreEqual(1000, msgIn1.getHeader().getHeaderRec().getMessageID());
        Assert.AreEqual(1, msgIn1.getBody().getVariantTop().getFieldValue());
        for (ushort i = 0; i < 10; ++i)
        {
            Assert.AreEqual(20 + i, msgIn1.getBody().getVariantTop().getListB().getElement(i).getFieldB1());
        }

        Console.Out.WriteLine("  [completed test (testEncodeDecodeOperations)] ");
    }
コード例 #2
0
ファイル: Variant3_utst.cs プロジェクト: nikola-v/jaustoolset
    public void testEncodeDecodeOperations()
    {
        byte[] buff = new byte[1024];

        for (int i = 0; i < 1024; i++)
        {
            buff[i] = 0;
        }

        Console.Out.WriteLine("  [executing test (testEncodeDecodeOperations)(TP_3.3.5.3)] ");

        // fill msg1, select ListA as active.
        msgIn1.getHeader().getHeaderRec().setMessageID(500);
        msgIn1.getBody().getVariantTop().setFieldValue(0);
        for (ushort i = 0; i < 5; ++i)
        {
            MsgIn.Body.VariantTop.ListA.RecA1 temprec = new MsgIn.Body.VariantTop.ListA.RecA1();
            temprec.setFieldA1((short)(10 + i));
            msgIn1.getBody().getVariantTop().getListA().addElement(temprec);
        }

        // fill msg2, select ListB as active.
        msgIn2.getHeader().getHeaderRec().setMessageID(1000);
        msgIn2.getBody().getVariantTop().setFieldValue(1);
        for (ushort i = 0; i < 10; ++i)
        {
            MsgIn.Body.VariantTop.ListB.RecB1 temprec = new MsgIn.Body.VariantTop.ListB.RecB1();
            temprec.setFieldB1((short)(20 + i));
            msgIn2.getBody().getVariantTop().getListB().addElement(temprec);
        }

        // encode/decode msg2 into msg1.  verify ListB now active in msg1 and verify list contents copied over
        msgIn2.encode(buff, 0);
        msgIn1.decode(buff, 0);

        Assert.AreEqual(1000, msgIn1.getHeader().getHeaderRec().getMessageID());
        Assert.AreEqual(1, msgIn1.getBody().getVariantTop().getFieldValue());
        for (ushort i = 0; i < 10; ++i)
        {
            Assert.AreEqual(20 + i, msgIn1.getBody().getVariantTop().getListB().getElement(i).getFieldB1());
        }

        Console.Out.WriteLine("  [completed test (testEncodeDecodeOperations)] ");
    }
コード例 #3
0
ファイル: Variant3_utst.cs プロジェクト: nikola-v/jaustoolset
    public void testSetGetOperations()
    {
        Console.Out.WriteLine("  [executing test (testSetGetOperations)(TP_3.3.5.1)] ");

        // check header field changes are recorded properly
        msgIn1.getHeader().getHeaderRec().setMessageID(5);
        Assert.AreEqual(5, msgIn1.getHeader().getHeaderRec().getMessageID());
        msgIn1.getHeader().getHeaderRec().setMessageID(1);
        Assert.AreEqual(1, msgIn1.getHeader().getHeaderRec().getMessageID());

        // check vtag field changes are recorded properly
        msgIn1.getBody().getVariantTop().setFieldValue(1);
        Assert.AreEqual(1, msgIn1.getBody().getVariantTop().getFieldValue());
        msgIn1.getBody().getVariantTop().setFieldValue(0);
        Assert.AreEqual(0, msgIn1.getBody().getVariantTop().getFieldValue());

        // add elements (records with ushorts) to ListA.
        for (ushort i = 0; i < 10; ++i)
        {
            MsgIn.Body.VariantTop.ListA.RecA1 temprec = new MsgIn.Body.VariantTop.ListA.RecA1();
            temprec.setFieldA1((byte)(10 + i));
            msgIn1.getBody().getVariantTop().getListA().addElement(temprec);
        }

        // verify new contents were stored
        Assert.AreEqual(10, msgIn1.getBody().getVariantTop().getListA().getNumberOfElements());

        for (ushort i = 0; i < 10; ++i)
        {
            Assert.AreEqual(10 + i, msgIn1.getBody().getVariantTop().getListA().getElement(i).getFieldA1());
        }

        // try changing and deleting some elements and ensure expected results occur.
        MsgIn.Body.VariantTop.ListA list_alias = msgIn1.getBody().getVariantTop().getListA(); // less typing

        list_alias.deleteElement(1);
        list_alias.deleteElement(1);
        list_alias.deleteLastElement();
        list_alias.deleteLastElement();

        Assert.AreEqual(6, list_alias.getNumberOfElements());

        Assert.AreEqual(10, list_alias.getElement(0).getFieldA1());
        Assert.AreEqual(13, list_alias.getElement(1).getFieldA1());
        Assert.AreEqual(14, list_alias.getElement(2).getFieldA1());
        Assert.AreEqual(15, list_alias.getElement(3).getFieldA1());
        Assert.AreEqual(16, list_alias.getElement(4).getFieldA1());
        Assert.AreEqual(17, list_alias.getElement(5).getFieldA1());

        MsgIn.Body.VariantTop.ListA.RecA1 rec1 = new MsgIn.Body.VariantTop.ListA.RecA1();
        MsgIn.Body.VariantTop.ListA.RecA1 rec2 = new MsgIn.Body.VariantTop.ListA.RecA1();
        MsgIn.Body.VariantTop.ListA.RecA1 rec3 = new MsgIn.Body.VariantTop.ListA.RecA1();
        rec1.setFieldA1(99);
        rec2.setFieldA1(199);
        rec3.setFieldA1(299);

        list_alias.setElement(5, rec1);
        list_alias.addElement(rec2);
        list_alias.addElement(rec3);

        Assert.AreEqual(10, list_alias.getElement(0).getFieldA1());
        Assert.AreEqual(13, list_alias.getElement(1).getFieldA1());
        Assert.AreEqual(14, list_alias.getElement(2).getFieldA1());
        Assert.AreEqual(15, list_alias.getElement(3).getFieldA1());
        Assert.AreEqual(16, list_alias.getElement(4).getFieldA1());
        Assert.AreEqual(99, list_alias.getElement(5).getFieldA1());
        Assert.AreEqual(199, list_alias.getElement(6).getFieldA1());
        Assert.AreEqual(299, list_alias.getElement(7).getFieldA1());

        // check size is correct
        // 2-byte header, 1 1-byte vtag field, 1 1-byte count field, 8 2-byte store shorts
        Assert.AreEqual(2 + 1 + 1 + 2 * 8, msgIn1.getSize());

        Console.Out.WriteLine("  [completed test (testSetGetOperations)] ");
    }
コード例 #4
0
    public void testSetGetOperations()
    {
        Console.Out.WriteLine("  [executing test (testSetGetOperations)(TP_3.3.5.1)] ");

        // check header field changes are recorded properly
        msgIn1.getHeader().getHeaderRec().setMessageID(5);
        Assert.AreEqual(5, msgIn1.getHeader().getHeaderRec().getMessageID());
        msgIn1.getHeader().getHeaderRec().setMessageID(1);
        Assert.AreEqual(1, msgIn1.getHeader().getHeaderRec().getMessageID());

        // check vtag field changes are recorded properly
        msgIn1.getBody().getVariantTop().setFieldValue(1);
        Assert.AreEqual(1, msgIn1.getBody().getVariantTop().getFieldValue());
        msgIn1.getBody().getVariantTop().setFieldValue(0);
        Assert.AreEqual(0, msgIn1.getBody().getVariantTop().getFieldValue());

        // add elements (records with ushorts) to ListA.
        for (ushort i = 0; i < 10; ++i)
        {
            MsgIn.Body.VariantTop.ListA.RecA1 temprec = new MsgIn.Body.VariantTop.ListA.RecA1();
            temprec.setFieldA1((byte)(10 + i));
            msgIn1.getBody().getVariantTop().getListA().addElement(temprec);
        }

        // verify new contents were stored
        Assert.AreEqual(10, msgIn1.getBody().getVariantTop().getListA().getNumberOfElements());

        for (ushort i = 0; i < 10; ++i)
        {
            Assert.AreEqual(10 + i, msgIn1.getBody().getVariantTop().getListA().getElement(i).getFieldA1());
        }

        // try changing and deleting some elements and ensure expected results occur.
        MsgIn.Body.VariantTop.ListA list_alias = msgIn1.getBody().getVariantTop().getListA(); // less typing

        list_alias.deleteElement(1);
        list_alias.deleteElement(1);
        list_alias.deleteLastElement();
        list_alias.deleteLastElement();

        Assert.AreEqual(6, list_alias.getNumberOfElements());

        Assert.AreEqual(10, list_alias.getElement(0).getFieldA1());
        Assert.AreEqual(13, list_alias.getElement(1).getFieldA1());
        Assert.AreEqual(14, list_alias.getElement(2).getFieldA1());
        Assert.AreEqual(15, list_alias.getElement(3).getFieldA1());
        Assert.AreEqual(16, list_alias.getElement(4).getFieldA1());
        Assert.AreEqual(17, list_alias.getElement(5).getFieldA1());

        MsgIn.Body.VariantTop.ListA.RecA1 rec1 = new MsgIn.Body.VariantTop.ListA.RecA1();
        MsgIn.Body.VariantTop.ListA.RecA1 rec2 = new MsgIn.Body.VariantTop.ListA.RecA1();
        MsgIn.Body.VariantTop.ListA.RecA1 rec3 = new MsgIn.Body.VariantTop.ListA.RecA1();
        rec1.setFieldA1(99);
        rec2.setFieldA1(199);
        rec3.setFieldA1(299);

        list_alias.setElement(5, rec1);
        list_alias.addElement(rec2);
        list_alias.addElement(rec3);

        Assert.AreEqual(10, list_alias.getElement(0).getFieldA1());
        Assert.AreEqual(13, list_alias.getElement(1).getFieldA1());
        Assert.AreEqual(14, list_alias.getElement(2).getFieldA1());
        Assert.AreEqual(15, list_alias.getElement(3).getFieldA1());
        Assert.AreEqual(16, list_alias.getElement(4).getFieldA1());
        Assert.AreEqual(99, list_alias.getElement(5).getFieldA1());
        Assert.AreEqual(199, list_alias.getElement(6).getFieldA1());
        Assert.AreEqual(299, list_alias.getElement(7).getFieldA1());

        // check size is correct
        // 2-byte header, 1 1-byte vtag field, 1 1-byte count field, 8 2-byte store shorts
        Assert.AreEqual(2 + 1 + 1 + 2 * 8, msgIn1.getSize());

        Console.Out.WriteLine("  [completed test (testSetGetOperations)] ");
    }