示例#1
0
    public void testEncodeToSpec()
    {
        byte[] buff = new byte[1024];
        int    i;

        m_MsgIn1.getHeader().getHeaderRec().setMessageID(513);
        m_MsgIn1.getBody3().getRecord3().setField1(4);
        m_MsgIn1.getBody3().getRecord3().setField2(134678021); //1.07112e-31
        m_MsgIn1.getBody3().getRecord3().setField3(.00000000000000000000000000000010711190335780293799599209044936f);
        m_MsgIn1.getBody3().getRecord3().setField4(13);


        // verifying message level encode is AS-5684 compliant"
        m_MsgIn1.encode(buff, 0);

        for (i = 0; i < m_MsgIn1.getSize(); i++)
        {
            Assert.AreEqual(i + 1, buff[i]);
        }

        m_MsgIn3.getHeader().getHeaderRec().setMessageID(513);
        m_MsgIn3.getBody3().getRecord3().setField1(1);
        m_MsgIn3.getBody3().getRecord3().setField3(.000000000000000000000000000000000000094774254455822359527052518093217f);

        // verifying message level encode is AS-5684 compliant regarding optional fields"
        m_MsgIn3.encode(buff, 0);

        for (i = 0; i < m_MsgIn3.getSize(); i++)
        {
            Assert.AreEqual(((i + 1) % 3), buff[i]);
        }
    }
示例#2
0
    public void testEncodeToSpec()
    {
        byte[] buff = new byte[1024];
        int    i;

        Console.WriteLine("[executing test (testEncodeToSpec)(TP_3.3.5.2)]");

        m_MsgIn1.getHeader().getHeaderRec().setMessageID(256);

        m_MsgIn1.getBody().getRecord().getBitField1().setMilliseconds(770);
        m_MsgIn1.getBody().getRecord().getBitField1().setSeconds(0);
        m_MsgIn1.getBody().getRecord().getBitField1().setMinutes(4);
        m_MsgIn1.getBody().getRecord().getBitField1().setHour(20);
        m_MsgIn1.getBody().getRecord().getBitField1().setDay(1);



        // verifying message level encode is AS-5684 compliant"
        m_MsgIn1.encode(buff, 0);

        for (i = 0; i < m_MsgIn1.getSize() - 1; i++)
        {
            Assert.AreEqual(i, buff[i]);
        }
        Assert.AreEqual(13, buff[m_MsgIn1.getSize() - 1]);
    }
示例#3
0
    public void testEncodeToSpec()
    {
        byte[] buff = new byte[1024];
        int    i;

        Console.WriteLine("[executing test (testEncodeToSpec)(TP_3.3.5.2)]");

        m_MsgIn1.getHeader().getHeaderRec().setMessageID(256);
        m_MsgIn1.getBody().getRecord10().getVariableField1().setDegreeAsIntegerAt0(258);


        // verifying message level encode is AS-5684 compliant"
        m_MsgIn1.encode(buff, 0);

        Assert.AreEqual(0, buff[0]);
        Assert.AreEqual(1, buff[1]);

        Assert.AreEqual(0, buff[2]);
        Assert.AreEqual(2, buff[3]);
        Assert.AreEqual(1, buff[4]);
        Assert.AreEqual(0, buff[5]);
        Assert.AreEqual(0, buff[6]);
        Assert.AreEqual(7, m_MsgIn1.getSize());

        m_MsgIn1.getBody().getRecord10().getVariableField1().setKelvinAsUnsignedShortIntegerAt1(770);
        m_MsgIn1.encode(buff, 0);

        Assert.AreEqual(0, buff[0]);
        Assert.AreEqual(1, buff[1]);

        Assert.AreEqual(1, buff[2]);
        Assert.AreEqual(2, buff[3]);
        Assert.AreEqual(3, buff[4]);
        Assert.AreEqual(5, m_MsgIn1.getSize());
    }
示例#4
0
    public void testEncodeToSpec()
    {
        byte[] buff = new byte[1024];
        int    i, j;

        Console.Out.WriteLine("\n[executing test (testEncodeToSpec)(TP_3.3.5.2)]: ");

        populate();
        msgIn1.getHeader().getHeaderRec().setMessageID(256);
        msgIn1.encode(buff, 0);

        Assert.AreEqual(buff[0], 0); Assert.AreEqual(buff[1], 1); // msg_id
        Assert.AreEqual(buff[2], 3);                              // str length
        for (i = 3, j = 0; i < 7; i++, j++)
        {
            Assert.AreEqual(buff[i], j);                                 // record type
        }
        for (i = 7, j = 1; i < 11; i++, j++)
        {
            Assert.AreEqual(buff[i], j);                                  // list type
        }
        for (i = 11, j = 2; i < 15; i++, j++)
        {
            Assert.AreEqual(buff[i], j);                                   // sequence type
        }
    }
示例#5
0
    public void testEncodeToSpec()
    {
        byte[] buff = new byte[1024];
        int    i;

        for (i = 0; i < 770; i++)
        {
            buff[i] = (byte)((i + 6) % 256);
        }

        m_MsgIn1.getHeader().getHeaderRec().setMessageID(256);
        m_MsgIn1.getBody4().getRecord4().getVariableLengthField1().set(770, buff);

        // verifying message level encode is AS-5684 compliant"
        m_MsgIn1.encode(buff, 0);


        for (i = 0; i < m_MsgIn1.getSize(); i++)
        {
            if ((i == 4) || (i == 5))
            {
                Assert.AreEqual(0, buff[i]);
            }
            else
            {
                Assert.AreEqual((i % 256), buff[i]);
            }
        }
    }
示例#6
0
    public void testEncodeToSpec()
    {
        byte[] buff = new byte[40000];
        int    i, j, k;
        sbyte  val = 0;

        Console.WriteLine("[executing test (testEncodeToSpec)(TP_3.3.5.2)]");

        m_MsgIn1.getHeader().getHeaderRec().setMessageID(256);
        val = 2;
        for (k = 0; k < m_MsgIn1.getBody().getRecord().getArray4().getHeightSize(); k++)
        {
            for (j = 0; j < m_MsgIn1.getBody().getRecord().getArray4().getColSize(); j++)
            {
                for (i = 0; i < m_MsgIn1.getBody().getRecord().getArray4().getRowSize(); i++)

                {
                    m_MsgIn1.getBody().getRecord().getArray4().setField1(i, j, k, val);
                    val++;
                }
            }
        }

        // verifying message level encode is AS-5684 compliant"
        m_MsgIn1.encode(buff, 0);
        for (i = 0, val = 0; i < m_MsgIn1.getSize(); i++, val++)
        {
            Assert.AreEqual(val, (sbyte)buff[i]);
        }
    }
示例#7
0
    public void testEncodeToSpec()
    {
        byte[] buff = new byte[1024];
        int    i;

        MsgIn.Body.List3.Sequence1 S1 = new MsgIn.Body.List3.Sequence1();
        MsgIn.Body.List3.Sequence1 S2 = new MsgIn.Body.List3.Sequence1();


        Console.WriteLine("[executing test (testEncodeToSpec)(TP_3.3.5.2)]");

        m_MsgIn1.getHeader().getHeaderRec().setMessageID(256);

        S1.getRecord1().setField1(3);
        S1.getRecord1().setField2(117835012);
        S2.getRecord1().setField1(8);
        S2.getRecord1().setField2(202050057);
        m_MsgIn1.getBody().getList3().addElement(S1);
        m_MsgIn1.getBody().getList3().addElement(S2);


        // verifying message level encode is AS-5684 compliant"
        m_MsgIn1.encode(buff, 0);

        for (i = 0; i < m_MsgIn1.getSize(); i++)
        {
            Assert.AreEqual(i, buff[i]);
        }
    }
示例#8
0
    public void testEncodeToSpec()
    {
        byte[] buff = new byte[1024];
        int    i;

        MsgIn.Header.List1.Record1 R1 = new MsgIn.Header.List1.Record1();
        MsgIn.Header.List1.Record1 R2 = new MsgIn.Header.List1.Record1();


        Console.WriteLine("[executing test (testEncodeToSpec)(TP_3.3.5.2)]");

        R1.setField1(3);
        R1.setField2(117835012);
        R2.setField1(8);
        R2.setField2(202050057);
        m_MsgIn1.getHeader().getList1().addElement(R1);
        m_MsgIn1.getHeader().getList1().addElement(R2);


        // verifying message level encode is AS-5684 compliant"
        m_MsgIn1.encode(buff, 0);

        for (i = 0; i < m_MsgIn1.getSize(); i++)
        {
            Assert.AreEqual((i + 2), buff[i]);
        }
    }
示例#9
0
    public void testEncodeToSpec()
    {
        byte[] buff = new byte[8192];
        byte   b_cc = 0;
        string S    = "";
        int    i;

        for (i = 0; i < 770; i++)
        {
            b_cc = ((byte)((i + 4) % 256));
            if (b_cc != 0)
            {
                S += ((char)b_cc);
            }
            else
            {
                S += ((char)1);
            }
        }
        m_MsgIn1.getHeader().getHeaderRec().setMessageID(256);
        m_MsgIn1.getBody().getRecord11().setVariableLengthString1(S);

        // verifying message level encode is AS-5684 compliant"
        m_MsgIn1.encode(buff, 0);
        Assert.AreEqual(774, m_MsgIn1.getSize());
        for (i = 0; i < m_MsgIn1.getSize(); i++)
        {
            b_cc = (byte)(i % 256);
            if ((i > 10) && (b_cc == 0))
            {
                b_cc = (byte)1;
            }
            Assert.AreEqual(b_cc, buff[i]);
        }
    }
示例#10
0
    public void testEncodeToSpec()
    {
        byte[] buff = new byte[90000];
        int    i, j, r, v;

        Console.WriteLine("[executing test (testEncodeToSpec)(TP_3.3.5.2)]");

        m_MsgIn1.getHeader().getHeaderRec().setMessageID(256);
        r = 0;
        for (j = 0; j < m_MsgIn1.getBody().getRecord16().getArray1().getYSize(); j++)
        {
            for (i = 0; i < m_MsgIn1.getBody().getRecord16().getArray1().getXSize(); i++)
            {
                if (r == 1)
                {
                    m_MsgIn1.getBody().getRecord16().getArray1().getVariableField1(i, j).setDegreeAsIntegerAt0((j * 100) + i + 2);
                    m_MsgIn2.getBody().getRecord16().getArray1().getVariableField1(i, j).setKelvinAsUnsignedShortIntegerAt1((ushort)((j * 100) + i + 2));
                    r = 0;
                }
                else
                {
                    m_MsgIn2.getBody().getRecord16().getArray1().getVariableField1(i, j).setDegreeAsIntegerAt0((j * 100) + i + 2);
                    m_MsgIn1.getBody().getRecord16().getArray1().getVariableField1(i, j).setKelvinAsUnsignedShortIntegerAt1((ushort)((j * 100) + i + 2));
                    r = 1;
                }
            }
        }

        // verifying message level encode is AS-5684 compliant"
        m_MsgIn1.encode(buff, 0);
        Assert.AreEqual(0, buff[0]);
        Assert.AreEqual(1, buff[1]);
        i = 2;
        r = 0;
        v = 2;
        while (i < m_MsgIn1.getSize())
        {
            if (r == 1)
            {
                Assert.AreEqual(0, buff[i]);
                Assert.AreEqual((v % 256), buff[i + 1]);
                Assert.AreEqual(((v / 256) % 256), buff[i + 2]);
                Assert.AreEqual(0, buff[i + 3]);
                Assert.AreEqual(0, buff[i + 4]);
                i += 5;
                r  = 0;
            }
            else
            {
                Assert.AreEqual(1, buff[i]);
                Assert.AreEqual((v % 256), buff[i + 1]);
                Assert.AreEqual(((v / 256) % 256), buff[i + 2]);
                i += 3;
                r  = 1;
            }
            v++;
        }
    }
示例#11
0
    public void testEncodeToSpec()
    {
        byte[] buff = new byte[1024];

        int i;

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

        Console.Out.WriteLine("  [executing test (testEncodeToSpec)(TP_3.3.5.2)] ");

        msgIn1.getHeader().getHeaderRec().setMessageID(99);

        // at X = 0, Y = 0 in array, RGB = (5, 10, 5)
        msgIn1.getBody().getRecord().getArray8().getColorField(0, 0).setR(5);
        msgIn1.getBody().getRecord().getArray8().getColorField(0, 0).setG(10);
        msgIn1.getBody().getRecord().getArray8().getColorField(0, 0).setB(5);

        // at 1 = 3, Y = 0 in array, RGB = (13, 27, 2)
        msgIn1.getBody().getRecord().getArray8().getColorField(1, 0).setR(13);
        msgIn1.getBody().getRecord().getArray8().getColorField(1, 0).setG(27);
        msgIn1.getBody().getRecord().getArray8().getColorField(1, 0).setB(2);

        // at X = 0, Y = 3 in array, RGB = (31,63,9)
        msgIn1.getBody().getRecord().getArray8().getColorField(0, 3).setR(31);
        msgIn1.getBody().getRecord().getArray8().getColorField(0, 3).setG(63);
        msgIn1.getBody().getRecord().getArray8().getColorField(0, 3).setB(9);

        // at X = 1, Y = 3 in array, RGB = (0,35,15)
        msgIn1.getBody().getRecord().getArray8().getColorField(1, 3).setR(0);
        msgIn1.getBody().getRecord().getArray8().getColorField(1, 3).setG(35);
        msgIn1.getBody().getRecord().getArray8().getColorField(1, 3).setB(15);

        msgIn1.encode(buff, 0);

        // offset 0   : ushort with message ID
        Assert.AreEqual(99, BitConverter.ToUInt16(buff, 0));
        // offset 2   : start of array data, ushort at x = 0, y = 0
        Assert.AreEqual(rgbToUnsignedShortBitfield(5, 10, 5), BitConverter.ToUInt16(buff, 2 + 0));
        // offset 4   : 2nd entry in array data, ushort at x = 1, y = 0
        Assert.AreEqual(rgbToUnsignedShortBitfield(13, 27, 2), BitConverter.ToUInt16(buff, 2 + 2));
        // offset 14   : 7th entry in array data, ushort at x = 0, y = 3
        Assert.AreEqual(rgbToUnsignedShortBitfield(31, 63, 9), BitConverter.ToUInt16(buff, 2 + 12));
        // offset 16   : 8th entry in array data, ushort at x = 1, y = 3
        Assert.AreEqual(rgbToUnsignedShortBitfield(0, 35, 15), BitConverter.ToUInt16(buff, 2 + 14));

        // offset 18   : 0, past end of encoded message!
        Assert.AreEqual(0, buff[18]);

        Console.Out.WriteLine("  [completed test (testEncodeToSpec)] ");
    }
示例#12
0
    public void testEncodeToSpec()
    {
        byte[] buff = new byte[600];
        int    i;

        for (i = 0; i < 512; i++)
        {
            buff[i] = (byte)((i + 16) % 256);
        }

        m_MsgIn1.getHeader().getHeaderRec().setMessageID(256);
        m_MsgIn1.getBody7().getRecord7().setField1(2);
        m_MsgIn1.getBody7().getRecord7().setField2(100992003);  //6.597819835e-33
        m_MsgIn1.getBody7().getRecord7().setField3(.0000000000000000000000000000000065978198350831201722347717993434f);
        m_MsgIn1.getBody7().getRecord7().setField4(11);
        m_MsgIn1.getBody7().getRecord7().getVariableLengthField1().set(288, buff);
        m_MsgIn1.getBody7().getRecord7().setStrFld("0123456789");


        // verifying message level encode is AS-5684 compliant"
        m_MsgIn1.encode(buff, 0);

        for (i = 0; i < m_MsgIn1.getSize() - 70; i++)
        { //20 01 00 00
            if (i == 12)
            {
                Assert.AreEqual(32, buff[i]);
            }
            else if (i == 13)
            {
                Assert.AreEqual(1, buff[i]);
            }
            else if (i == 14)
            {
                Assert.AreEqual(0, buff[i]);
            }
            else if (i == 15)
            {
                Assert.AreEqual(0, buff[i]);
            }
            else
            {
                Assert.AreEqual((i % 256), buff[i]);
            }
        }
        for (i = m_MsgIn1.getSize() - 70; i < m_MsgIn1.getSize(); i++)
        {
            Assert.AreEqual(0, buff[(int)i]);
        }
    }
示例#13
0
    public void testEncodeToSpec()
    {
        byte[] buff = new byte[1024];
        int    i;

        Console.WriteLine("[executing test (testEncodeToSpec)(TP_3.3.5.2)]");

        m_MsgIn1.getHeader().getSequence1().getRecord1().setField1(2);
        m_MsgIn1.getHeader().getSequence1().getRecord1().setField2(100992003);
        MsgIn.Header.Sequence1.List1.Record1 R1 = new MsgIn.Header.Sequence1.List1.Record1();
        R1.setField1(2312);
        m_MsgIn1.getHeader().getSequence1().getList1().addElement(R1);

        R1 = new MsgIn.Header.Sequence1.List1.Record1();
        R1.setField1(2826);
        m_MsgIn1.getHeader().getSequence1().getList1().addElement(R1);

        R1 = new MsgIn.Header.Sequence1.List1.Record1();
        R1.setField1(3340);
        m_MsgIn1.getHeader().getSequence1().getList1().addElement(R1);

        R1 = new MsgIn.Header.Sequence1.List1.Record1();
        R1.setField1(3854);
        m_MsgIn1.getHeader().getSequence1().getList1().addElement(R1);

        R1 = new MsgIn.Header.Sequence1.List1.Record1();
        R1.setField1(4368);
        m_MsgIn1.getHeader().getSequence1().getList1().addElement(R1);

        R1 = new MsgIn.Header.Sequence1.List1.Record1();
        R1.setField1(4882);
        m_MsgIn1.getHeader().getSequence1().getList1().addElement(R1);

        R1 = new MsgIn.Header.Sequence1.List1.Record1();
        R1.setField1(5396);
        m_MsgIn1.getHeader().getSequence1().getList1().addElement(R1);


        // verifying message level encode is AS-5684 compliant"
        m_MsgIn1.encode(buff, 0);

        for (i = 0; i < m_MsgIn1.getSize(); i++)
        {
            Assert.AreEqual((i + 2), buff[i]);
        }
    }
示例#14
0
    public void testEncodeToSpec()
    {
        byte[] buff = new byte[70000];
        uint   i    = 0;

        for (i = 0; i < 65786; i++)
        {
            buff[i] = (byte)((i + 6) % 256);
        }

        m_MsgIn1.getHeader().getHeaderRec().setMessageID(256);
        m_MsgIn1.getBody5().getRecord5().getVariableLengthField1().set(65786, buff);
        m_MsgIn1.getBody5().getRecord5().setField1(0);
        m_MsgIn1.getBody5().getRecord5().setField2(67305985);  //4.06321607e-34
        m_MsgIn1.getBody5().getRecord5().setField3(.0000000000000000000000000000000004063216068939722949825023716001f);
        m_MsgIn1.getBody5().getRecord5().setField4(9);


        // verifying message level encode is AS-5684 compliant"
        m_MsgIn1.encode(buff, 0);

        for (i = 0; i < m_MsgIn1.getSize(); i++)
        { //FA 00 01 00
            if (i == 2)
            {
                Assert.AreEqual(250, buff[i]);
            }
            else if (i == 3)
            {
                Assert.AreEqual(0, buff[i]);
            }
            else if (i == 4)
            {
                Assert.AreEqual(1, buff[i]);
            }
            else if (i == 5)
            {
                Assert.AreEqual(0, buff[i]);
            }
            else
            {
                Assert.AreEqual((i % 256), buff[i]);
            }
        }
    }
示例#15
0
    public void testEncodeToSpec()
    {
        byte[] buff = new byte[1024];
        int    i;

        MsgIn.Body.List2 list = new MsgIn.Body.List2();
        msgIn1.getBody().setList2(list);
        MsgIn.Body.List2.Sublist1         L1 = new MsgIn.Body.List2.Sublist1();
        MsgIn.Body.List2.Sublist1         L2 = new MsgIn.Body.List2.Sublist1();
        MsgIn.Body.List2.Sublist1.Record1 R1 = new MsgIn.Body.List2.Sublist1.Record1();

        Console.Out.WriteLine("\n[executing test (testEncodeToSpec)(TP_3.3.5.2)]: ");

        msgIn1.getHeader().getHeaderRec().setMessageID(256);

        // First sublist should be three elements long
        for (i = 0; i < 3; i++)
        {
            R1 = new MsgIn.Body.List2.Sublist1.Record1();
            R1.setField1((byte)(i + 4));
            L1.addElement(R1);
        }

        // Second sublist should be 7 elements long
        for (i = 0; i < 7; i++)
        {
            R1 = new MsgIn.Body.List2.Sublist1.Record1();
            R1.setField1((byte)(i + 8));
            L2.addElement(R1);
        }

        // Add both sublists to the main list
        msgIn1.getBody().getList2().addElement(L1);
        msgIn1.getBody().getList2().addElement(L2);


        // verifying message level encode is AS-5684 compliant"
        msgIn1.encode(buff, 0);
        Assert.AreEqual(15, msgIn1.getSize());
        for (i = 0; i < msgIn1.getSize(); i++)
        {
            Assert.AreEqual(i, buff[i]);
        }
    }
示例#16
0
    public void testEncodeToSpec()
    {
        byte[] buff = new byte[1024];
        int    i;

        Console.WriteLine("[executing test (testEncodeToSpec)(TP_3.3.5.2)]");

        m_MsgIn1.getHeader().getHeaderRec().setMessageID(256);


        // verifying message level encode is AS-5684 compliant"
        m_MsgIn1.encode(buff, 0);


        for (i = 0; i < m_MsgIn1.getSize(); i++)
        {
            Assert.AreEqual(i, buff[i]);
        }
    }
示例#17
0
    public void testEncodeToSpec()
    {
        byte[] buff = new byte[1024];
        int    i;

        Console.WriteLine("[executing test (testEncodeToSpec)(TP_3.3.5.2)]");

        for (i = 0; i < m_MsgIn1.getBody().getRecord().getArray5().getDimension1Size(); i++)
        {
            m_MsgIn1.getBody().getRecord().getArray5().setField1(i, (sbyte)i);
        }

        // verifying message level encode is AS-5684 compliant"
        m_MsgIn1.encode(buff, 0);
        for (i = 0; i < m_MsgIn1.getSize(); i++)
        {
            Assert.AreEqual(i, buff[i]);
        }
    }
示例#18
0
    public void testEncodeToSpec()
    {
        byte[] buff = new byte[8192];
        byte   c = 0;
        string S1 = "", S2 = "";
        int    i = 0;

        for (i = 85; i < 168; i++)
        {
            c   = (byte)i;
            S1 += (((char)c));
        }



        m_MsgIn1.getHeader().getHeaderRec().setMessageID(256);
        m_MsgIn1.getBody().getRecord12().setField1(2);

        for (i = 3; i < 83; i++)
        {
            S2 += (char)i;
        }
        m_MsgIn1.getBody().getRecord12().setStrFld(S2);

        m_MsgIn1.getBody().getRecord12().setVariableLengthString1(S1);

        // verifying message level encode is AS-5684 compliant"
        m_MsgIn1.encode(buff, 0);

        Assert.AreEqual(168, m_MsgIn1.getSize());


        for (i = 0; i < m_MsgIn1.getSize(); i++)
        {
            c = (byte)(i % 256);
            if (i == 84)
            {
                c = (byte)0;
            }
            Assert.AreEqual(c, (char)(buff[i] & 0xff));
        }
    }
示例#19
0
    public void testEncodeToSpec()
    {
        byte[] buff = new byte[1024];
        int    i;

        m_MsgIn1.getHeader().getHeaderRec().setMessageID(256);
        m_MsgIn1.getBody2().getRecord2().setField1(2);
        m_MsgIn1.getBody2().getRecord2().setField2(100992003); //6.59782e-33
        m_MsgIn1.getBody2().getRecord2().setField3(0.00000000000000000000000000000000659782f);
        m_MsgIn1.getBody2().getRecord2().setField4(11);


        // verifying message level encode is AS-5684 compliant"
        m_MsgIn1.encode(buff, 0);

        for (i = 0; i < m_MsgIn1.getSize(); i++)
        {
            Assert.AreEqual(i, buff[i]);
        }
    }
示例#20
0
    public void testEncodeToSpec()
    {
        byte[] buff = new byte[90000];
        int    i, j;
        string stringData = "";

        Console.WriteLine("[executing test (testEncodeToSpec)(TP_3.3.5.2)]");

        m_MsgIn1.getHeader().getHeaderRec().setMessageID(256);
        short val = 2;

        // set the first 200 strings in the array's encoding.
        for (j = 0; j < 2; ++j)
        {
            for (i = 0; i < 100; ++i)
            {
                stringData = buildEncodeTestString(val, 80);
                m_MsgIn1.getBody().getRecord15().getNames().setName(i, j, stringData);
                val++;
            }
        }

        // verifying message level encode is AS-5684 compliant"
        m_MsgIn1.encode(buff, 0);
        Assert.AreEqual(0, buff[0]);
        Assert.AreEqual(1, buff[1]);
        val = 2;
        i   = 2;

        // loop through first 200 80-character strings in the array's encoding.
        while (i < (200 * 80) + 2)
        {
            for (j = i; j < i + 80; j++)
            {
                // treat value in the buffer as an unsigned byte.
                Assert.AreEqual(val, (short)(buff[j] & 0xff));
            }
            val++;
            i += 80;
        }
    }
示例#21
0
    public void testEncodeToSpec()
    {
        byte[] buff = new byte[1024];

        Console.WriteLine("[executing test (testEncodeToSpec)(TP_3.3.5.2)]");

        m_MsgIn1.getHeader().getHeaderRec().setMessageID(256);

        // verifying message level encode is AS-5684 compliant"

        //case 1 - variant containing MessageIDRec
        m_MsgIn1.getBody().getSequence3().getVariant1().getMessageIDRec().setMessageCode(1027);
        m_MsgIn1.getBody().getSequence3().getVariant1().setFieldValue(0);
        m_MsgIn1.encode(buff, 0);
        Assert.AreEqual(5, m_MsgIn1.getSize());
        Assert.AreEqual(0, buff[0]);  //lsb of MessageID
        Assert.AreEqual(1, buff[1]);  //msb of MessageID
        Assert.AreEqual(0, buff[2]);  //vtag_field (run time record type)
        Assert.AreEqual(3, buff[3]);  //lsb of MessageCode
        Assert.AreEqual(4, buff[4]);  //msb of MessageCode

        //case 2 - variant containing EventTypeRec
        m_MsgIn1.getBody().getSequence3().getVariant1().getEventTypeRec().setEventType(1);
        m_MsgIn1.getBody().getSequence3().getVariant1().setFieldValue(1);
        m_MsgIn1.encode(buff, 0);
        Assert.AreEqual(4, m_MsgIn1.getSize());
        Assert.AreEqual(0, buff[0]);  //lsb of MessageID
        Assert.AreEqual(1, buff[1]);  //msb of MessageID
        Assert.AreEqual(1, buff[2]);  //vtag_field (run time record type)
        Assert.AreEqual(1, buff[3]);  //EventType

        //case 3 - variant containing EventIDRec
        m_MsgIn1.getBody().getSequence3().getVariant1().getEventIDRec().setEventID(4);
        m_MsgIn1.getBody().getSequence3().getVariant1().setFieldValue(2);
        m_MsgIn1.encode(buff, 0);
        Assert.AreEqual(4, m_MsgIn1.getSize());
        Assert.AreEqual(0, buff[0]);  //lsb of MessageID
        Assert.AreEqual(1, buff[1]);  //msb of MessageID
        Assert.AreEqual(2, buff[2]);  //vtag_field (run time record type)
        Assert.AreEqual(4, buff[3]);  //EventID

        //case 4 - variant containing AllEventsRec
        m_MsgIn1.getBody().getSequence3().getVariant1().getAllEventsRec().setAllEvents(0);
        m_MsgIn1.getBody().getSequence3().getVariant1().setFieldValue(3);
        m_MsgIn1.encode(buff, 0);
        Assert.AreEqual(4, m_MsgIn1.getSize());
        Assert.AreEqual(0, buff[0]);  //lsb of MessageID
        Assert.AreEqual(1, buff[1]);  //msb of MessageID
        Assert.AreEqual(3, buff[2]);  //vtag_field (run time record type)
        Assert.AreEqual(0, buff[3]);  //allEvents
    }
示例#22
0
    public void testEncodeToSpec()
    {
        byte[] buff = new byte[4096];
        uint   i    = 0;

        m_MsgIn1.getHeader().getHeaderRec().setMessageID(256);
        m_MsgIn1.getBody6().getRecord6().setStrFld("ABCDEFGHIJKLMNOPQRSTUVWXYZ");

        // verifying message level encode is AS-5684 compliant"
        m_MsgIn1.encode(buff, 0);
        Assert.AreEqual(0, buff[0]);
        Assert.AreEqual(1, buff[1]);
        for (i = 2; i < 28; i++)
        {
            Assert.AreEqual(63 + i, buff[i]);
        }
        for (i = 28; i < m_MsgIn1.getSize(); i++)
        {
            Assert.AreEqual(0, buff[i]);
        }
    }
示例#23
0
    public void testEncodeToSpec()
    {
        byte[] buff = new byte[1024];
        int i;

        for (i = 0; i < 770; i++)
            buff[i] = (byte)(i % 256);

        //    m_MsgIn1.getHeader().getHeaderRec().setMessageID(256);
        m_MsgIn1.getHeader().getRecord4().getVariableLengthField1().set(770, buff);

        // verifying message level encode is AS-5684 compliant"
        m_MsgIn1.encode(buff, 0);

        Assert.AreEqual(2, buff[0]);
        Assert.AreEqual(3, buff[1]);
        Assert.AreEqual(0, buff[2]);
        Assert.AreEqual(0, buff[3]);
        for (i = 0; i < m_MsgIn1.getSize() - 4; i++)
        {
            Assert.AreEqual((i % 256), buff[i + 4]);

        }
    }
示例#24
0
    public void testEncodeToSpec()
    {
        byte[] buff = new byte[1024];
        for (int i = 0; i < 1024; i++)
        {
            buff[i] = 0;
        }

        Console.Out.WriteLine("  [executing test (testEncodeToSpec)(TP_3.3.5.2)] ");

        msgIn1.getHeader().getHeaderRec().setMessageID(500);
        msgIn1.getBody().getVariantTop().setFieldValue(1);

        // fill list and encode into buff
        for (ushort i = 0; i < 10; ++i)
        {
            MsgIn.Body.VariantTop.ListB.RecB1 temprec = new MsgIn.Body.VariantTop.ListB.RecB1();
            temprec.setFieldB1((short)(20 + i));
            msgIn1.getBody().getVariantTop().getListB().addElement(temprec);
        }

        msgIn1.encode(buff, 0);

        // verify encoding matches expectations from spec document.

        // offset 0:   ushort w/ message ID
        Assert.AreEqual(500, BitConverter.ToUInt16(buff, 0));

        // offset 2:   byte w/ VariantTop's vtag field
        Assert.AreEqual(1, buff[2]);

        // offset 3:   byte w/ ListB's length
        Assert.AreEqual(10, buff[3]);

        int offset = 4; // list data starts at offset 4, ends at offset 22.

        for (ushort i = 0; i < 10; ++i)
        {
            Assert.AreEqual(20 + i, BitConverter.ToUInt16(buff, offset));
            offset += 2;
        }

        // byte 23 should be 0, past end of message data.
        Assert.AreEqual(0, buff[23]);

        Console.Out.WriteLine("  [completed test (testEncodeToSpec)] ");
    }
示例#25
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)] ");
    }
示例#26
0
    public void testEncodeToSpec()
    {
        byte[] buff = new byte[1024];
        int    i    = 0;

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

        Console.Out.WriteLine("  [executing test (testEncodeToSpec)(TP_3.3.5.2)] ");

        // fill the message in and copy to buffer
        resetMessage(msgIn1);
        msgIn1.encode(buff, 0);

        // verify encoding matches expectations from spec document

        // offset 0:   ushort w/ message ID
        Assert.AreEqual(1000, BitConverter.ToUInt16(buff, 0));

        // offset 2:   byte w/ VariantTop's vtag field
        Assert.AreEqual(1, buff[2]);

        // offset 3:   ushort, FieldB1
        Assert.AreEqual(9000, BitConverter.ToUInt16(buff, 3));

        // offset 5:   byte w/ ListB count field
        Assert.AreEqual(10, buff[5]);

        // offsets 6-24: 10 ushort values in list
        int offset = 6;

        for (i = 0; i < 10; ++i)
        {
            Assert.AreEqual(20 + i, BitConverter.ToUInt16(buff, offset));
            offset += 2;
        }

        Console.Out.WriteLine("  [completed test (testEncodeToSpec)] ");
    }
示例#27
0
    public void testEncodeDecodeOperations()
    {
        byte[] buff = new byte[1024];
        int    i;

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

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

        // fill msg1, select VariantA, RecA1 as active.
        msgIn1.getHeader().getHeaderRec().setMessageID(500);

        msgIn1.getBody().getVariantTop().setFieldValue(0);
        msgIn1.getBody().getVariantTop().getVariantA().setFieldValue(0);
        msgIn1.getBody().getVariantTop().getVariantA().getRecA1().setFieldA1(19);
        msgIn1.getBody().getVariantTop().getVariantB().getRecB2().setFieldB2(0);

        // fill msg2, select VariantB, RecB2 as active.
        msgIn2.getHeader().getHeaderRec().setMessageID(1000);

        msgIn2.getBody().getVariantTop().setFieldValue(1);
        msgIn2.getBody().getVariantTop().getVariantB().setFieldValue(1);
        msgIn2.getBody().getVariantTop().getVariantB().getRecB2().setFieldB2(29);

        // encode/decode msg2 into msg1.  msg1 should now show active VariantB, RecB2; verify field contents are
        // correct.

        msgIn2.encode(buff, 0);
        msgIn1.decode(buff, 0);

        Assert.AreEqual(1000, msgIn1.getHeader().getHeaderRec().getMessageID());
        Assert.AreEqual(1, msgIn1.getBody().getVariantTop().getFieldValue());
        Assert.AreEqual(1, msgIn1.getBody().getVariantTop().getVariantB().getFieldValue());
        Assert.AreEqual(29, msgIn1.getBody().getVariantTop().getVariantB().getRecB2().getFieldB2());

        // change the msg ID on msg1 and fill new values in msg1.
        // fill msg1, select VariantA, RecA1 as active.
        msgIn1.getHeader().getHeaderRec().setMessageID(1999);

        msgIn1.getBody().getVariantTop().setFieldValue(0);
        msgIn1.getBody().getVariantTop().getVariantA().setFieldValue(0);
        msgIn1.getBody().getVariantTop().getVariantA().getRecA1().setFieldA1(0);
        msgIn1.getBody().getVariantTop().getVariantA().getRecA2().setFieldA2(0);
        msgIn1.getBody().getVariantTop().getVariantB().setFieldValue(0);
        msgIn1.getBody().getVariantTop().getVariantB().getRecB1().setFieldB1(0);
        msgIn1.getBody().getVariantTop().getVariantB().getRecB2().setFieldB2(0);

        // encode/decode msg2's VariantTop into msg1.  msg1 should now show changed variant, but keep the msg ID.
        msgIn2.getBody().getVariantTop().encode(buff, 0);
        msgIn1.getBody().getVariantTop().decode(buff, 0);

        Assert.AreEqual(1999, msgIn1.getHeader().getHeaderRec().getMessageID());
        Assert.AreEqual(1, msgIn1.getBody().getVariantTop().getFieldValue());
        Assert.AreEqual(0, msgIn1.getBody().getVariantTop().getVariantA().getFieldValue());
        Assert.AreEqual(1, msgIn1.getBody().getVariantTop().getVariantB().getFieldValue());
        Assert.AreEqual(29, msgIn1.getBody().getVariantTop().getVariantB().getRecB2().getFieldB2());

        // set msg1's VariantTop so VariantA is active, also make RecA2 active inside.
        //  Also make VariantA active in msg2, but make RecA1 active.
        msgIn1.getBody().getVariantTop().setFieldValue(0);
        msgIn1.getBody().getVariantTop().getVariantA().setFieldValue(1);
        msgIn1.getBody().getVariantTop().getVariantA().getRecA2().setFieldA2(9000);
        msgIn1.getBody().getVariantTop().getVariantA().getRecA1().setFieldA1(0);

        msgIn2.getBody().getVariantTop().setFieldValue(0);
        msgIn2.getBody().getVariantTop().getVariantA().setFieldValue(0);
        msgIn2.getBody().getVariantTop().getVariantA().getRecA1().setFieldA1(4500);

        // encode/decode msg2's VariantA into msg1.  verify msg1 shows contents from msgIn2.
        msgIn2.getBody().getVariantTop().getVariantA().encode(buff, 0);
        msgIn1.getBody().getVariantTop().getVariantA().decode(buff, 0);

        Assert.AreEqual(0, msgIn1.getBody().getVariantTop().getFieldValue());
        Assert.AreEqual(0, msgIn1.getBody().getVariantTop().getVariantA().getFieldValue());
        Assert.AreEqual(4500, msgIn1.getBody().getVariantTop().getVariantA().getRecA1().getFieldA1());

        Console.Out.WriteLine("  [completed test (testEncodeDecodeOperations)] ");
    }
示例#28
0
    public void testEncodeDecodeOperations()
    {
        Console.Out.WriteLine("");
        Console.Out.Write("[executing test (testEncodeDecodeOperations)]");

        MsgIn msg1 = new MsgIn();
        MsgIn msg2 = new MsgIn();

        byte[] data1 = new byte[10];
        byte[] data2 = new byte[5];

        for (int i = 0; i < 10; ++i) {
            data1[i] = (byte)(10+i);
        }
        for (int i = 0; i < 5; ++i) {
            data2[i] = (byte)(20+i);
        }

        msg1.getHeader().getHeaderRec().setMessageID(999);

        MsgIn.Body.Sequence.Record3 rec3_i = msg1.getBody().getSequence().getRecord3();

        rec3_i.setField1((sbyte)77);
        rec3_i.getVariableLengthField1().set(10, data1);
        rec3_i.getArray1().setElement1(1, (sbyte)10);
        rec3_i.getArray1().setElement1(3, (sbyte)20);
        rec3_i.getArray1().setElement1(5, (sbyte)30);
        rec3_i.getArray1().setElement1(7, (sbyte)40);
        rec3_i.getArray1().setElement1(9, (sbyte)50);
        rec3_i.getBitField1().setSubfield1((byte)1);
        rec3_i.setFixedLengthString1("ABCDE");
        rec3_i.getVariableField1().setMeterAsUnsignedByteAt1((byte)33);
        rec3_i.setVariableLengthString1("hello world");
        rec3_i.getVariableFormatField1().set((byte)0, 5, data2);

        MsgIn.Body.Sequence.List.Record listrec_i = new MsgIn.Body.Sequence.List.Record();
        msg1.getBody().getSequence().getList().addElement( listrec_i );

        listrec_i.setField1((sbyte)77);
        listrec_i.getVariableLengthField1().set(10, data1);
        listrec_i.getArray1().setElement1(1, (sbyte)60);
        listrec_i.getArray1().setElement1(3, (sbyte)70);
        listrec_i.getArray1().setElement1(5, (sbyte)80);
        listrec_i.getArray1().setElement1(7, (sbyte)90);
        listrec_i.getArray1().setElement1(9, (sbyte)100);
        listrec_i.getBitField1().setSubfield1((byte)1);
        listrec_i.setFixedLengthString1("FGHIJK");
        listrec_i.getVariableField1().setMeterAsUnsignedByteAt1((byte)44);
        listrec_i.setVariableLengthString1("aabbccddeeff");
        listrec_i.getVariableFormatField1().set((byte)0, 5, data2);

        // Variants
        msg1.getBody().getSequence().getVariant().setFieldValue((byte)1); // option 1: Record
        MsgIn.Body.Sequence.Variant.Record varrec_i = msg1.getBody().getSequence().getVariant().getRecord();

        varrec_i.setField1((sbyte)99);
        varrec_i.getVariableLengthField1().set(10, data1);
        varrec_i.getArray1().setElement1(1, (sbyte)65);
        varrec_i.getArray1().setElement1(3, (sbyte)75);
        varrec_i.getArray1().setElement1(5, (sbyte)85);
        varrec_i.getArray1().setElement1(7, (sbyte)95);
        varrec_i.getArray1().setElement1(9, (sbyte)105);
        varrec_i.getBitField1().setSubfield1((byte)1);
        varrec_i.setFixedLengthString1("LMNOPQR");
        varrec_i.getVariableField1().setMeterAsUnsignedByteAt1((byte)55);
        varrec_i.setVariableLengthString1("hello world");
        varrec_i.getVariableFormatField1().set((byte)0, 5, data2);

        byte[] buff = new byte[1000];
        byte[] fieldBuff_i = new byte[100];
        byte[] fieldBuff_o = new byte[100];

        msg1.encode(buff, 0);
        msg2.decode(buff, 0);

        MsgIn.Body.Sequence.Record3 rec3_o = msg2.getBody().getSequence().getRecord3();
        MsgIn.Body.Sequence.List.Record listrec_o = msg2.getBody().getSequence().getList().getElement(0);
        MsgIn.Body.Sequence.Variant.Record varrec_o = msg2.getBody().getSequence().getVariant().getRecord();

        // *** ensure Record3 was decoded correctly

        // compare non bytefield data
        Assert.AreEqual(rec3_i.getField1(), rec3_o.getField1());
        for (int i = 0; i < 10; ++i) {
            Assert.AreEqual(rec3_i.getArray1().getElement1(i), rec3_o.getArray1().getElement1(i));
        }
        Assert.AreEqual(rec3_i.getBitField1().getSubfield1(), rec3_o.getBitField1().getSubfield1());
        Assert.AreEqual(rec3_i.getFixedLengthString1(), rec3_o.getFixedLengthString1());
        Assert.AreEqual(rec3_i.getVariableField1().getMeterAsUnsignedByteAt1(),
                rec3_o.getVariableField1().getMeterAsUnsignedByteAt1());
        Assert.AreEqual(rec3_i.getVariableLengthString1(), rec3_o.getVariableLengthString1());

        // compare bytefield data
        fieldBuff_i = rec3_i.getVariableLengthField1().getData();
        fieldBuff_o = rec3_o.getVariableLengthField1().getData();
        assertBuffersEqual(fieldBuff_i, fieldBuff_o, 10);

        fieldBuff_i = rec3_i.getVariableFormatField1().getData();
        fieldBuff_o = rec3_o.getVariableFormatField1().getData();
        Assert.AreEqual(rec3_i.getVariableFormatField1().getFormat(),
                rec3_o.getVariableFormatField1().getFormat());
        assertBuffersEqual(fieldBuff_i, fieldBuff_o, 5);

        // *** ensure Record under List was decoded correctly

        // compare non-bytefield data
        Assert.AreEqual(listrec_i.getField1(), listrec_o.getField1());
        for (int i = 0; i < 10; ++i) {
            Assert.AreEqual(listrec_i.getArray1().getElement1(i), listrec_o.getArray1().getElement1(i));
        }
        Assert.AreEqual(listrec_i.getBitField1().getSubfield1(), listrec_o.getBitField1().getSubfield1());
        Assert.AreEqual(listrec_i.getFixedLengthString1(), listrec_o.getFixedLengthString1());
        Assert.AreEqual(listrec_i.getVariableField1().getMeterAsUnsignedByteAt1(),
                listrec_o.getVariableField1().getMeterAsUnsignedByteAt1());
        Assert.AreEqual(listrec_i.getVariableLengthString1(), listrec_o.getVariableLengthString1());

        // compare bytefield data
        fieldBuff_i = listrec_i.getVariableLengthField1().getData();
        fieldBuff_o = listrec_o.getVariableLengthField1().getData();
        assertBuffersEqual(fieldBuff_i, fieldBuff_o, 10);

        fieldBuff_i = listrec_i.getVariableFormatField1().getData();
        fieldBuff_o = listrec_o.getVariableFormatField1().getData();
        Assert.AreEqual(listrec_i.getVariableFormatField1().getFormat(),
                listrec_o.getVariableFormatField1().getFormat());
        assertBuffersEqual(fieldBuff_i, fieldBuff_o, 5);

        // *** ensure Record under Variant was decoded correctly.

        // compare non-bytefield data
        Assert.AreEqual(varrec_i.getField1(), varrec_o.getField1());
        for (int i = 0; i < 10; ++i) {
            Assert.AreEqual(varrec_i.getArray1().getElement1(i), varrec_o.getArray1().getElement1(i));
        }
        Assert.AreEqual(varrec_i.getBitField1().getSubfield1(), varrec_o.getBitField1().getSubfield1());
        Assert.AreEqual(varrec_i.getFixedLengthString1(), varrec_o.getFixedLengthString1());
        Assert.AreEqual(varrec_i.getVariableField1().getMeterAsUnsignedByteAt1(),
                varrec_o.getVariableField1().getMeterAsUnsignedByteAt1());
        Assert.AreEqual(varrec_i.getVariableLengthString1(), varrec_o.getVariableLengthString1());

        // compare bytefield data
        fieldBuff_i = varrec_i.getVariableLengthField1().getData();
        fieldBuff_o = varrec_o.getVariableLengthField1().getData();
        assertBuffersEqual(fieldBuff_i, fieldBuff_o, 10);

        fieldBuff_i = varrec_i.getVariableFormatField1().getData();
        fieldBuff_o = varrec_o.getVariableFormatField1().getData();
        Assert.AreEqual(varrec_i.getVariableFormatField1().getFormat(),
                varrec_o.getVariableFormatField1().getFormat());
        assertBuffersEqual(fieldBuff_i, fieldBuff_o, 5);
    }
示例#29
0
    public void testEncodeToSpec()
    {
        Console.Out.WriteLine("");
        Console.Out.Write("[executing test (testEncodeToSpec)]");

        // buffer for encoding
        byte[] buff = new byte[10000];

        // *** first test message: activate only Record1, activate all fields inside of record1.
        byte[] data1 = new byte[10];
        byte[] data2 = new byte[5];

        for (int i = 0; i < 10; ++i)
        {
            data1[i] = (byte)(10 + i);
        }
        for (int i = 0; i < 5; ++i)
        {
            data2[i] = (byte)(20 + i);
        }

        MsgIn msg1 = new MsgIn();

        msg1.getHeader().getHeaderRec().setMessageID(999);

        msg1.getBody().getSequence().getRecord1().setField1((sbyte)77);
        msg1.getBody().getSequence().getRecord1().getVariableLengthField1().set(10, data1);
        msg1.getBody().getSequence().getRecord1().getArray1().setElement1(1, (sbyte)10);
        msg1.getBody().getSequence().getRecord1().getArray1().setElement1(3, (sbyte)20);
        msg1.getBody().getSequence().getRecord1().getArray1().setElement1(5, (sbyte)30);
        msg1.getBody().getSequence().getRecord1().getArray1().setElement1(7, (sbyte)40);
        msg1.getBody().getSequence().getRecord1().getArray1().setElement1(9, (sbyte)50);
        msg1.getBody().getSequence().getRecord1().getBitField1().setSubfield1((byte)1);
        msg1.getBody().getSequence().getRecord1().setFixedLengthString1("ABCDE");
        msg1.getBody().getSequence().getRecord1().getVariableField1().setMeterAsUnsignedByteAt1((byte)33);
        msg1.getBody().getSequence().getRecord1().setVariableLengthString1("hello world");
        msg1.getBody().getSequence().getRecord1().getVariableFormatField1().set((byte)0, 5, data2);

        msg1.encode(buff, 0);

        // offset 0:    ushort w/ message ID
        Assert.AreEqual(999, BitConverter.ToUInt16(buff, 0));

        // offset 2:    ushort w/ Sequence's presence vector - should be 1 indicating only first
        // record is present
        Assert.AreEqual(1, BitConverter.ToUInt16(buff, 2));

        // offset 4: unsigned byte w/ Record1's presence vector, 8 bits all on, 255
        Assert.AreEqual(255, buff[4]);

        // offset 5:    signed byte, Field1 fixed field
        Assert.AreEqual(77, buff[5]);

        // offset 6:    uint, variableLengthField1 count field...
        Assert.AreEqual(10, buff[6]);

        // offset 10-19: 10-byte variableLengthField1.
        assertBufferSliceEqual(buff, data1, 10, 10);

        // offset 20: Array1[0]
        Assert.AreEqual(0, buff[20]);

        // offset 21: Array1[1]
        Assert.AreEqual(10, buff[21]);

        // offset 22: Array1[2]
        Assert.AreEqual(0, buff[22]);

        // offset 23: Array1[3]
        Assert.AreEqual(20, buff[23]);

        // offset 25: Array1[5]
        Assert.AreEqual(30, buff[25]);

        // offset 27: Array1[7]
        Assert.AreEqual(40, buff[27]);

        // offset 29: Array1[9]
        Assert.AreEqual(50, buff[29]);

        // offset 30: BitField1, single unsigned byte
        Assert.AreEqual(1, buff[30]);

        // offset 31: 15-byte fixed length string.  first 5 chars: "ABCDE"
        Assert.AreEqual(65, buff[31]);

        // offset 32: 15-byte fixed length string.  first 5 chars: "ABCDE"
        Assert.AreEqual(66, buff[32]);

        // offset 33: 15-byte fixed length string.  first 5 chars: "ABCDE"
        Assert.AreEqual(67, buff[33]);

        // offset 34: 15-byte fixed length string.  first 5 chars: "ABCDE"
        Assert.AreEqual(68, buff[34]);

        // offset 35: 15-byte fixed length string.  first 5 chars: "ABCDE"
        Assert.AreEqual(69, buff[35]);

        // offset 36: zeroed part of fixed length string
        Assert.AreEqual(0, buff[36]);

        // offset 45: last zeroed byte of fixed length string
        Assert.AreEqual(0, buff[45]);

        // offset 46: type/units enum of VariableField1, single byte
        Assert.AreEqual(1, buff[46]);

        // offset 47: contents of VariableField1
        Assert.AreEqual(33, buff[47]);

        // offset 48: 2-byte unsigned short, count field for VariableLengthString1
        Assert.AreEqual(11, BitConverter.ToUInt16(buff, 48));

        // offset 50-60: 11 characters of VariableLengthString1 "hello world"
        Assert.AreEqual(104, buff[50]);
        Assert.AreEqual(101, buff[51]);
        Assert.AreEqual(108, buff[52]);
        Assert.AreEqual(108, buff[53]);
        Assert.AreEqual(111, buff[54]);
        Assert.AreEqual(32, buff[55]);
        Assert.AreEqual(119, buff[56]);
        Assert.AreEqual(111, buff[57]);
        Assert.AreEqual(114, buff[58]);
        Assert.AreEqual(108, buff[59]);
        Assert.AreEqual(100, buff[60]);

        // offset 61: format field of VariableFormatField1, unsigned byte
        Assert.AreEqual(0, buff[61]);

        // offset 62: count field of VariableFormatField1, unsigned int
        Assert.AreEqual(5, BitConverter.ToUInt16(buff, 62));

        // offset 66-70: 5 byte data of VariableFormatField1
        assertBufferSliceEqual(buff, data2, 66, 5);

        buff = new byte[10000];

        // *** 2nd test message, activate Record 2, Record 4, Record 6, Record 8, activate different
        // fields within each record.
        MsgIn msg2 = new MsgIn();

        msg2.getHeader().getHeaderRec().setMessageID(999);

        msg2.getBody().getSequence().getRecord2().setField1((sbyte)77);
        msg2.getBody().getSequence().getRecord2().getVariableLengthField1().set(10, data1);
        msg2.getBody().getSequence().getRecord4().getArray1().setElement1(1, (sbyte)10);
        msg2.getBody().getSequence().getRecord4().getArray1().setElement1(3, (sbyte)20);
        msg2.getBody().getSequence().getRecord4().getArray1().setElement1(5, (sbyte)30);
        msg2.getBody().getSequence().getRecord4().getArray1().setElement1(7, (sbyte)40);
        msg2.getBody().getSequence().getRecord4().getArray1().setElement1(9, (sbyte)50);
        msg2.getBody().getSequence().getRecord4().getBitField1().setSubfield1((byte)1);
        msg2.getBody().getSequence().getRecord6().setFixedLengthString1("ABCDE");
        msg2.getBody().getSequence().getRecord6().getVariableField1().setMeterAsUnsignedByteAt1((byte)33);
        msg2.getBody().getSequence().getRecord8().setVariableLengthString1("hello world");
        msg2.getBody().getSequence().getRecord8().getVariableFormatField1().set((byte)0, 5, data2);

        msg2.encode(buff, 0);

        // offset 0:   ushort w/ msg ID
        Assert.AreEqual(999, BitConverter.ToUInt16(buff, 0));

        // offset 2:   ushort w/ Sequence pv
        Assert.AreEqual(170, BitConverter.ToUInt16(buff, 2));

        // offset 4:   ubyte w/ Record2 pv
        Assert.AreEqual(3, buff[4]);

        // offset 5:   byte w/ Record2.Field1
        Assert.AreEqual(77, buff[5]);

        // offset 6:   uint w/ Record2.VariableLengthField1 count field
        Assert.AreEqual(10, buff[6]);

        // offset 10-19: ubyte data of Record2.VariableLengthField1
        assertBufferSliceEqual(buff, data1, 10, 10);

        // offset 20:   ubyte w/ Record4 pv
        Assert.AreEqual(12, buff[20]);

        // offset 21:   byte, Record4.Array1[0]
        Assert.AreEqual(0, buff[21]);

        // offset 22:   byte, Record4.Array1[1]
        Assert.AreEqual(10, buff[22]);

        // offset 23:   byte, Record4.Array1[2]
        Assert.AreEqual(0, buff[23]);

        // offset 29:   byte, Record4.Array1[8]
        Assert.AreEqual(0, buff[29]);

        // offset 30:   byte, Record4.Array1[9]
        Assert.AreEqual(50, buff[30]);

        // offset 31:   byte, Record4.BitField1
        Assert.AreEqual(1, buff[31]);

        // offset 32:   ubyte w/ Record6 pv
        Assert.AreEqual(48, buff[32]);

        // offset 33: 15-byte Record6.FixedLengthString1.  first 5 chars: "ABCDE"
        Assert.AreEqual(65, buff[33]);

        // offset 34: 15-byte fixed length string.  first 5 chars: "ABCDE"
        Assert.AreEqual(66, buff[34]);

        // offset 35: 15-byte fixed length string.  first 5 chars: "ABCDE"
        Assert.AreEqual(67, buff[35]);

        // offset 36: 15-byte fixed length string.  first 5 chars: "ABCDE"
        Assert.AreEqual(68, buff[36]);

        // offset 37: 15-byte fixed length string.  first 5 chars: "ABCDE"
        Assert.AreEqual(69, buff[37]);

        // offset 38: zeroed part of fixed length string
        Assert.AreEqual(0, buff[38]);

        // offset 47: last zeroed byte of fixed length string
        Assert.AreEqual(0, buff[47]);

        // offset 48: type/units enum of VariableField1, single byte
        Assert.AreEqual(1, buff[48]);

        // offset 49: byte contents of VariableField1
        Assert.AreEqual(33, buff[49]);

        // offset 50:   ubyte w/ Record8 pv
        Assert.AreEqual(192, buff[50]);

        // offset 51: 2-byte unsigned short, count field for Record8.VariableLengthString1
        Assert.AreEqual(11, BitConverter.ToUInt16(buff, 51));

        // offset 53-63: 11 characters of Record8.VariableLengthString1 "hello world"
        Assert.AreEqual(104, buff[53]);
        Assert.AreEqual(101, buff[54]);
        Assert.AreEqual(108, buff[55]);
        Assert.AreEqual(108, buff[56]);
        Assert.AreEqual(111, buff[57]);
        Assert.AreEqual(32, buff[58]);
        Assert.AreEqual(119, buff[59]);
        Assert.AreEqual(111, buff[60]);
        Assert.AreEqual(114, buff[61]);
        Assert.AreEqual(108, buff[62]);
        Assert.AreEqual(100, buff[63]);

        // offset 64: format field of Record8.VariableFormatField1, unsigned byte
        Assert.AreEqual(0, buff[64]);

        // offset 65: count field of Record8.VariableFormatField1, unsigned int
        Assert.AreEqual(5, BitConverter.ToUInt16(buff, 65));

        // offset 69-73: 5 byte data of Record8.VariableFormatField1
        assertBufferSliceEqual(buff, data2, 69, 5);

        buff = new byte[10000];

        // 3rd msg: activate record 3, List, and Variant, and activate the record
        // inside List and Variant, activate all fields inside each record.
        MsgIn msg3 = new MsgIn();

        msg3.getHeader().getHeaderRec().setMessageID(999);

        MsgIn.Body.Sequence.Record3 rec3 = msg3.getBody().getSequence().getRecord3();

        rec3.setField1((sbyte)77);
        rec3.getVariableLengthField1().set(10, data1);
        rec3.getArray1().setElement1(1, (sbyte)10);
        rec3.getArray1().setElement1(3, (sbyte)20);
        rec3.getArray1().setElement1(5, (sbyte)30);
        rec3.getArray1().setElement1(7, (sbyte)40);
        rec3.getArray1().setElement1(9, (sbyte)50);
        rec3.getBitField1().setSubfield1((byte)1);
        rec3.setFixedLengthString1("ABCDE");
        rec3.getVariableField1().setMeterAsUnsignedByteAt1((byte)33);
        rec3.setVariableLengthString1("hello world");
        rec3.getVariableFormatField1().set((byte)0, 5, data2);

        MsgIn.Body.Sequence.List.Record listrec = new MsgIn.Body.Sequence.List.Record();
        msg3.getBody().getSequence().getList().addElement( listrec );

        listrec.setField1((sbyte)77);
        listrec.getVariableLengthField1().set(10, data1);
        listrec.getArray1().setElement1(1, (sbyte)60);
        listrec.getArray1().setElement1(3, (sbyte)70);
        listrec.getArray1().setElement1(5, (sbyte)80);
        listrec.getArray1().setElement1(7, (sbyte)90);
        listrec.getArray1().setElement1(9, (sbyte)100);
        listrec.getBitField1().setSubfield1((byte)1);
        listrec.setFixedLengthString1("FGHIJK");
        listrec.getVariableField1().setMeterAsUnsignedByteAt1((byte)44);
        listrec.setVariableLengthString1("aabbccddeeff");
        listrec.getVariableFormatField1().set((byte)0, 5, data2);

        // Variants
        msg3.getBody().getSequence().getVariant().setFieldValue((byte)1); // option 1: Record
        MsgIn.Body.Sequence.Variant.Record varrec = msg3.getBody().getSequence().getVariant().getRecord();

        varrec.setField1((sbyte)99);
        varrec.getVariableLengthField1().set(10, data1);
        varrec.getArray1().setElement1(1, (sbyte)65);
        varrec.getArray1().setElement1(3, (sbyte)75);
        varrec.getArray1().setElement1(5, (sbyte)85);
        varrec.getArray1().setElement1(7, (sbyte)95);
        varrec.getArray1().setElement1(9, (sbyte)105);
        varrec.getBitField1().setSubfield1((byte)1);
        varrec.setFixedLengthString1("LMNOPQR");
        varrec.getVariableField1().setMeterAsUnsignedByteAt1((byte)55);
        varrec.setVariableLengthString1("hello world");
        varrec.getVariableFormatField1().set((byte)0, 5, data2);

        msg3.encode(buff, 0);

        // offset 0:    ushort w/ message ID
        Assert.AreEqual(999, BitConverter.ToUInt16(buff, 0));

        // offset 2:    ushort w/ Sequence's presence vector - 1284 indicates record 3, list, variant present
        Assert.AreEqual(1284, BitConverter.ToUInt16(buff, 2));

        // offset 4: unsigned byte w/ Record3's presence vector, 8 bits all on, 255
        Assert.AreEqual(255, buff[4]);

        // offset 5:    signed byte, Record3.Field1 fixed field
        Assert.AreEqual(77, buff[5]);

        // offset 6:    uint, Record3.variableLengthField1 count field...
        Assert.AreEqual(10, buff[6]);

        // offset 10-19: 10-byte Record3.variableLengthField1.
        assertBufferSliceEqual(buff, data1, 10, 10);

        // offset 20: Record3.Array1[0]
        Assert.AreEqual(0, buff[20]);

        // offset 21: Record3.Array1[1]
        Assert.AreEqual(10, buff[21]);

        // offset 22: Record3.Array1[2]
        Assert.AreEqual(0, buff[22]);

        // offset 23: Record3.Array1[3]
        Assert.AreEqual(20, buff[23]);

        // offset 25: Record3.Array1[5]
        Assert.AreEqual(30, buff[25]);

        // offset 27: Record3.Array1[7]
        Assert.AreEqual(40, buff[27]);

        // offset 29: Record3.Array1[9]
        Assert.AreEqual(50, buff[29]);

        // offset 30: Record3.BitField1, single unsigned byte
        Assert.AreEqual(1, buff[30]);

        // offset 31: 15-byte fixed length string.  first 5 chars: "ABCDE"
        Assert.AreEqual(65, buff[31]);

        // offset 32: 15-byte fixed length string.  first 5 chars: "ABCDE"
        Assert.AreEqual(66, buff[32]);

        // offset 33: 15-byte fixed length string.  first 5 chars: "ABCDE"
        Assert.AreEqual(67, buff[33]);

        // offset 34: 15-byte fixed length string.  first 5 chars: "ABCDE"
        Assert.AreEqual(68, buff[34]);

        // offset 35: 15-byte fixed length string.  first 5 chars: "ABCDE"
        Assert.AreEqual(69, buff[35]);

        // offset 36: zeroed part of fixed length string
        Assert.AreEqual(0, buff[36]);

        // offset 45: last zeroed byte of fixed length string
        Assert.AreEqual(0, buff[45]);

        // offset 46: type/units enum of Record3.VariableField1, single byte
        Assert.AreEqual(1, buff[46]);

        // offset 47: contents of Record3.VariableField1
        Assert.AreEqual(33, buff[47]);

        // offset 48: 2-byte unsigned short, count field for Record3.VariableLengthString1
        Assert.AreEqual(11, BitConverter.ToUInt16(buff, 48));

        // offset 50-60: 11 characters of VariableLengthString1 "hello world"
        Assert.AreEqual(104, buff[50]);
        Assert.AreEqual(101, buff[51]);
        Assert.AreEqual(108, buff[52]);
        Assert.AreEqual(108, buff[53]);
        Assert.AreEqual(111, buff[54]);
        Assert.AreEqual(32, buff[55]);
        Assert.AreEqual(119, buff[56]);
        Assert.AreEqual(111, buff[57]);
        Assert.AreEqual(114, buff[58]);
        Assert.AreEqual(108, buff[59]);
        Assert.AreEqual(100, buff[60]);

        // offset 61: format field of VariableFormatField1, unsigned byte
        Assert.AreEqual(0, buff[61]);

        // offset 62: count field of VariableFormatField1, unsigned int
        Assert.AreEqual(5, BitConverter.ToUInt16(buff, 62));

        // offset 66-70: 5 byte data of VariableFormatField1
        assertBufferSliceEqual(buff, data2, 66, 5);

        // *** list and record inside list ***

        // offset 71: ubyte count field for list == 1
        Assert.AreEqual(1, buff[71]);

        // offset 72: ubyte presence vector for List.Record
        Assert.AreEqual(255, buff[72]);

        // offset 73:    signed byte, Record3.Field1 fixed field
        Assert.AreEqual(77, buff[73]);

        // offset 74:    uint, Record3.variableLengthField1 count field...
        Assert.AreEqual(10, buff[74]);

        // offset 78-87: 10-byte Record3.variableLengthField1.
        assertBufferSliceEqual(buff, data1, 78, 10);

        // offset 88: Record3.Array1[0]
        Assert.AreEqual(0, buff[88]);

        // offset 89: Record3.Array1[1]
        Assert.AreEqual(60, buff[89]);

        // offset 90: Record3.Array1[2]
        Assert.AreEqual(0, buff[90]);

        // offset 91: Record3.Array1[3]
        Assert.AreEqual(70, buff[91]);

        // offset 93: Record3.Array1[5]
        Assert.AreEqual(80, buff[93]);

        // offset 95: Record3.Array1[7]
        Assert.AreEqual(90, buff[95]);

        // offset 97: Record3.Array1[9]
        Assert.AreEqual(100, buff[97]);

        // offset 98: Record3.BitField1, single unsigned byte
        Assert.AreEqual(1, buff[98]);

        // offset 99: 15-byte fixed length string.  first 6 chars: "FGHIJK"
        Assert.AreEqual(70, buff[99]);

        // offset 100: 15-byte fixed length string.
        Assert.AreEqual(71, buff[100]);

        // offset 101: 15-byte fixed length string.
        Assert.AreEqual(72, buff[101]);

        // offset 102: 15-byte fixed length string.
        Assert.AreEqual(73, buff[102]);

        // offset 103: 15-byte fixed length string.
        Assert.AreEqual(74, buff[103]);

        // offset 104: 15-byte fixed length string.
        Assert.AreEqual(75, buff[104]);

        // offset 105: zeroed part of fixed length string
        Assert.AreEqual(0, buff[105]);

        // offset 113: last zeroed byte of fixed length string
        Assert.AreEqual(0, buff[113]);

        // offset 114: type/units enum of Record3.VariableField1, single byte
        Assert.AreEqual(1, buff[114]);

        // offset 115: contents of Record3.VariableField1
        Assert.AreEqual(44, buff[115]);

        // offset 116: 2-byte unsigned short, count field for Record3.VariableLengthString1
        Assert.AreEqual(12, BitConverter.ToUInt16(buff, 116));

        // offset 118-129: 12 characters of VariableLengthString1 "aabbccddeeff"
        Assert.AreEqual(97, buff[118]);
        Assert.AreEqual(97, buff[119]);
        Assert.AreEqual(98, buff[120]);
        Assert.AreEqual(98, buff[121]);
        Assert.AreEqual(99, buff[122]);
        Assert.AreEqual(99, buff[123]);
        Assert.AreEqual(100, buff[124]);
        Assert.AreEqual(100, buff[125]);
        Assert.AreEqual(101, buff[126]);
        Assert.AreEqual(101, buff[127]);
        Assert.AreEqual(102, buff[128]);
        Assert.AreEqual(102, buff[129]);

        // offset 130: format field of VariableFormatField1, unsigned byte
        Assert.AreEqual(0, buff[130]);

        // offset 131: count field of VariableFormatField1, unsigned int
        Assert.AreEqual(5, BitConverter.ToUInt16(buff, 131));

        // offset 135-139: 5 byte data of VariableFormatField1
        assertBufferSliceEqual(buff, data2, 135, 5);

        // *** variant and record inside variant ***

        // offset 140: ubyte vtag field for variant
        Assert.AreEqual(1, buff[140]);

        // offset 141: ubyte presence vector for Variant.Record.
        Assert.AreEqual(255, buff[141]);

        // offset 142:    signed byte, Record3.Field1 fixed field
        Assert.AreEqual(99, buff[142]);

        // offset 143:    uint, Record3.variableLengthField1 count field...
        Assert.AreEqual(10, buff[143]);

        // offset 147-156: 10-byte Record3.variableLengthField1.
        assertBufferSliceEqual(buff, data1, 147, 10);

        // offset 157: Record3.Array1[0]
        Assert.AreEqual(0, buff[157]);

        // offset 158: Record3.Array1[1]
        Assert.AreEqual(65, buff[158]);

        // offset 159: Record3.Array1[2]
        Assert.AreEqual(0, buff[159]);

        // offset 160: Record3.Array1[3]
        Assert.AreEqual(75, buff[160]);

        // offset 162: Record3.Array1[5]
        Assert.AreEqual(85, buff[162]);

        // offset 164: Record3.Array1[7]
        Assert.AreEqual(95, buff[164]);

        // offset 166: Record3.Array1[9]
        Assert.AreEqual(105, buff[166]);

        // offset 167: Record3.BitField1, single unsigned byte
        Assert.AreEqual(1, buff[167]);

        // offset 168: 15-byte fixed length string.  first 7 chars: "LMNOPQR"
        Assert.AreEqual(76, buff[168]);

        // offset 169: 15-byte fixed length string.
        Assert.AreEqual(77, buff[169]);

        // offset 170: 15-byte fixed length string.
        Assert.AreEqual(78, buff[170]);

        // offset 171: 15-byte fixed length string.
        Assert.AreEqual(79, buff[171]);

        // offset 172: 15-byte fixed length string.
        Assert.AreEqual(80, buff[172]);

        // offset 173: 15-byte fixed length string.
        Assert.AreEqual(81, buff[173]);

        // offset 174: 15-byte fixed length string.
        Assert.AreEqual(82, buff[174]);

        // offset 175: zeroed part of fixed length string
        Assert.AreEqual(0, buff[175]);

        // offset 182: last zeroed byte of fixed length string
        Assert.AreEqual(0, buff[182]);

        // offset 183: type/units enum of Record3.VariableField1, single byte
        Assert.AreEqual(1, buff[183]);

        // offset 184: contents of Record3.VariableField1
        Assert.AreEqual(55, buff[184]);

        // offset 185: 2-byte unsigned short, count field for Record3.VariableLengthString1
        Assert.AreEqual(11, BitConverter.ToUInt16(buff, 185));

        // offset 50-60: 11 characters of VariableLengthString1 "hello world"
        Assert.AreEqual(104, buff[187]);
        Assert.AreEqual(101, buff[188]);
        Assert.AreEqual(108, buff[189]);
        Assert.AreEqual(108, buff[190]);
        Assert.AreEqual(111, buff[191]);
        Assert.AreEqual(32, buff[192]);
        Assert.AreEqual(119, buff[193]);
        Assert.AreEqual(111, buff[194]);
        Assert.AreEqual(114, buff[195]);
        Assert.AreEqual(108, buff[196]);
        Assert.AreEqual(100, buff[197]);

        // offset 61: format field of VariableFormatField1, unsigned byte
        Assert.AreEqual(0, buff[198]);

        // offset 62: count field of VariableFormatField1, unsigned int
        Assert.AreEqual(5, BitConverter.ToUInt16(buff, 199));

        // offset 66-70: 5 byte data of VariableFormatField1
        assertBufferSliceEqual(buff, data2, 203, 5);

        buff = new byte[10000];

        // 4th msg: activate the subsequence, activate only some fields inside subsequence's record...
        MsgIn msg4 = new MsgIn();

        msg4.getHeader().getHeaderRec().setMessageID(999);

        MsgIn.Body.Sequence.Subsequence.Record sseqRec =
            msg4.getBody().getSequence().getSubsequence().getRecord();

        sseqRec.setField1((sbyte)77);
        sseqRec.getVariableLengthField1().set(10, data1);
        sseqRec.getArray1().setElement1(1, (sbyte)10);
        sseqRec.getArray1().setElement1(3, (sbyte)20);
        sseqRec.getArray1().setElement1(5, (sbyte)30);
        sseqRec.getArray1().setElement1(7, (sbyte)40);
        sseqRec.getArray1().setElement1(9, (sbyte)50);
        sseqRec.getBitField1().setSubfield1((byte)1);
        sseqRec.setFixedLengthString1("ABCDE");
        sseqRec.getVariableField1().setMeterAsUnsignedByteAt1((byte)33);
        sseqRec.setVariableLengthString1("JTS=PWNT");
        sseqRec.getVariableFormatField1().set((byte)0, 5, data2);

        msg4.encode(buff, 0);

        // offset 0:    ushort w/ message ID
        Assert.AreEqual(999, BitConverter.ToUInt16(buff, 0));

        // offset 2:    ushort w/ Sequence's presence vector - 512 indicates only Subsequence present
        Assert.AreEqual(512, BitConverter.ToUInt16(buff, 2));

        // offset 4:    ubyte w/ Subsequence's presence vector - should be 1 indicating only first
        // record is present
        Assert.AreEqual(1, buff[4]);

        // offset 5: ubyte w/ Record's presence vector - 255 indicates all elements present
        Assert.AreEqual(255, buff[5]);

        // offset 6:    signed byte, Field1 fixed field
        Assert.AreEqual(77, buff[6]);

        // offset 7:    uint, variableLengthField1 count field...
        Assert.AreEqual(10, buff[7]);

        // offset 11-20: 10-byte variableLengthField1.
        assertBufferSliceEqual(buff, data1, 11, 10);

        // offset 21: Array1[0]
        Assert.AreEqual(0, buff[21]);

        // offset 22: Array1[1]
        Assert.AreEqual(10, buff[22]);

        // offset 23: Array1[2]
        Assert.AreEqual(0, buff[23]);

        // offset 24: Array1[3]
        Assert.AreEqual(20, buff[24]);

        // offset 26: Array1[5]
        Assert.AreEqual(30, buff[26]);

        // offset 28: Array1[7]
        Assert.AreEqual(40, buff[28]);

        // offset 30: Array1[9]
        Assert.AreEqual(50, buff[30]);

        // offset 31: BitField1, single unsigned byte
        Assert.AreEqual(1, buff[31]);

        // offset 32: 15-byte fixed length string.  first 5 chars: "ABCDE"
        Assert.AreEqual(65, buff[32]);

        // offset 33: 15-byte fixed length string.  first 5 chars: "ABCDE"
        Assert.AreEqual(66, buff[33]);

        // offset 34: 15-byte fixed length string.  first 5 chars: "ABCDE"
        Assert.AreEqual(67, buff[34]);

        // offset 35: 15-byte fixed length string.  first 5 chars: "ABCDE"
        Assert.AreEqual(68, buff[35]);

        // offset 36: 15-byte fixed length string.  first 5 chars: "ABCDE"
        Assert.AreEqual(69, buff[36]);

        // offset 37: zeroed part of fixed length string
        Assert.AreEqual(0, buff[37]);

        // offset 46: last zeroed byte of fixed length string
        Assert.AreEqual(0, buff[46]);

        // offset 47: type/units enum of VariableField1, single byte
        Assert.AreEqual(1, buff[47]);

        // offset 48: contents of VariableField1
        Assert.AreEqual(33, buff[48]);

        // offset 49: 2-byte unsigned short, count field for VariableLengthString1
        Assert.AreEqual(8, BitConverter.ToUInt16(buff, 49));

        // offset 51-61: 11 characters of VariableLengthString1 "hello world"
        Assert.AreEqual(74, buff[51]);
        Assert.AreEqual(84, buff[52]);
        Assert.AreEqual(83, buff[53]);
        Assert.AreEqual(61, buff[54]);
        Assert.AreEqual(80, buff[55]);
        Assert.AreEqual(87, buff[56]);
        Assert.AreEqual(78, buff[57]);
        Assert.AreEqual(84, buff[58]);

        // offset 59: format field of VariableFormatField1, unsigned byte
        Assert.AreEqual(0, buff[59]);

        // offset 60: count field of VariableFormatField1, unsigned int
        Assert.AreEqual(5, BitConverter.ToUInt16(buff, 60));

        // offset 64-69: 5 byte data of VariableFormatField1
        assertBufferSliceEqual(buff, data2, 64, 5);
    }
示例#30
0
    public void testEncodeToSpec()
    {
        byte[] buff = new byte[1024];

        int i;

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

        Console.Out.WriteLine("  [executing test (testEncodeToSpec)(TP_3.3.5.2)] ");

        msgIn1.getHeader().getHeaderRec().setMessageID(999);

        byte[] data1 = new byte[1] {
            10
        };
        byte[] data2 = new byte[2] {
            10, 11
        };
        byte[] data3 = new byte[3] {
            10, 11, 12
        };
        byte[] data4 = new byte[4] {
            10, 11, 12, 13
        };
        byte[] data5 = new byte[5] {
            10, 11, 12, 13, 14
        };
        byte[] data6 = new byte[6] {
            10, 11, 12, 13, 14, 15
        };
        byte[] data7 = new byte[7] {
            10, 11, 12, 13, 14, 15, 16
        };
        byte[] data8 = new byte[8] {
            10, 11, 12, 13, 14, 15, 16, 17
        };
        byte[] data9 = new byte[9] {
            10, 11, 12, 13, 14, 15, 16, 17, 18
        };
        byte[] data10 = new byte[10] {
            10, 11, 12, 13, 14, 15, 16, 17, 18, 19
        };

        msgIn1.getBody().getRecord().getArray10().getVFF1(0).set(1, 1, data1);
        msgIn1.getBody().getRecord().getArray10().getVFF1(1).set(1, 2, data2);
        msgIn1.getBody().getRecord().getArray10().getVFF1(2).set(1, 3, data3);
        msgIn1.getBody().getRecord().getArray10().getVFF1(3).set(1, 4, data4);
        msgIn1.getBody().getRecord().getArray10().getVFF1(4).set(1, 5, data5);
        msgIn1.getBody().getRecord().getArray10().getVFF1(5).set(1, 6, data6);
        msgIn1.getBody().getRecord().getArray10().getVFF1(6).set(1, 7, data7);
        msgIn1.getBody().getRecord().getArray10().getVFF1(7).set(1, 8, data8);
        msgIn1.getBody().getRecord().getArray10().getVFF1(8).set(1, 9, data9);
        msgIn1.getBody().getRecord().getArray10().getVFF1(9).set(1, 10, data10);

        msgIn1.encode(buff, 0);

        // offset 0:   ushort w/ message ID
        Assert.AreEqual(999, BitConverter.ToUInt16(buff, 0));

        // offset 2: byte w/ format field
        Assert.AreEqual(1, buff[2]);

        // offset 3:  ushort w/ count field = 1
        Assert.AreEqual(1, BitConverter.ToUInt16(buff, 3));

        // offset 5: single byte from 1st VFF
        Assert.AreEqual(10, buff[5]);

        // offset 6: byte w/ format field
        Assert.AreEqual(1, buff[6]);

        // offset 7:  ushort w/ count field = 2
        Assert.AreEqual(2, BitConverter.ToUInt16(buff, 7));

        // offset 9: byte from 2nd VFF
        Assert.AreEqual(10, buff[9]);

        // offset 10: byte from 2nd VFF
        Assert.AreEqual(11, buff[10]);

        // offset 11: byte w/ format field
        Assert.AreEqual(1, buff[11]);

        // offset 12:  ushort w/ count field = 3
        Assert.AreEqual(3, BitConverter.ToUInt16(buff, 12));

        // array of uchar starting at offset 14: 3rd VFF data
        assertArraySlicesEqual(buff, data3, 14, 3);

        // skip to the last VFF
        // offset 74: byte w/ format field
        Assert.AreEqual(1, buff[74]);

        // offset 75: ushort w/ count field = 10
        Assert.AreEqual(10, BitConverter.ToUInt16(buff, 75));

        // array of uchar starting at offset 77: 10th VFF data
        assertArraySlicesEqual(buff, data10, 77, 10);

        Console.Out.WriteLine("  [completed test (testEncodeToSpec)] ");
    }
示例#31
0
    public void testEncodeToSpec()
    {
        Console.Out.WriteLine("");
        Console.Out.WriteLine("executing test testEncodeToSpec(TP_3.3.5.2): ");

        byte[] buff = new byte[1024];
        int    i    = 0;

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

        m_MsgIn1.getHeader().getHeaderRec().setMessageID(256);

        // array's length should be 9.
        // populate the array with 9 strings; first is 'A', second is 'BB', up to 'IIIIIIIII' (nine 'I's)
        for (i = 0; i < m_MsgIn1.getBody().getRecord().getArray7().getDimension1Size(); i++)
        {
            m_MsgIn1.getBody().getRecord().getArray7().setVariableLengthString1(i, buildEncodeTestString(65 + i, i + 1));
        }

        // verifying message level encode is AS-5684 compliant
        m_MsgIn1.encode(buff, 0);

        // offset 0 in buff is message ID, should be 256 (in an unsigned short)
        Assert.AreEqual(256, BitConverter.ToUInt16(buff, 0));

        // offset 2 in buff is length of first string, should be 1 (in an unsigned short)
        Assert.AreEqual(1, BitConverter.ToUInt16(buff, 2));

        // offset 4 in buff is single 'A' of first string, single byte UTF-8 character
        Assert.AreEqual(65, buff[4]);

        // offset 5 = length of 2nd string, 2 in unsigned short.
        Assert.AreEqual(2, BitConverter.ToUInt16(buff, 5));

        // offset 7 = 1st 'B' in 2nd string, single byte UTF-8 character
        Assert.AreEqual(66, buff[7]);

        // offset 8 = 2nd 'B' in 2nd string
        Assert.AreEqual(66, buff[8]);

        // offset 9 = length of 3rd string, 3 in unsigned short.
        Assert.AreEqual(3, BitConverter.ToUInt16(buff, 9));

        // offset 11 = 1st 'C' in 3rd string
        Assert.AreEqual(67, buff[11]);

        //        12 = 2nd 'C' in 3rd string
        Assert.AreEqual(67, buff[12]);

        //        13 = 3rd 'C' in 3rd string
        Assert.AreEqual(67, buff[13]);

        // skipping to 9th string, should be 9 'I's, length value at offset 54
        Assert.AreEqual(9, BitConverter.ToUInt16(buff, 54));

        //        56 = 1st 'I' in 9th string
        Assert.AreEqual(73, buff[56]);

        //        60 = 5th 'I' in 9th string
        Assert.AreEqual(73, buff[60]);

        //        64 = 9th 'I' in 9th string
        Assert.AreEqual(73, buff[64]);

        //        65 = past end of message encoding, should be 0.
        Assert.AreEqual(0, buff[65]);
    }
示例#32
0
    public void testEncodeDecodeOperations()
    {
        byte[] buff = new byte[1024];
        int    i;

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

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

        // setup msg1
        resetMessage(msgIn1);

        // setup msg2
        msgIn2.getHeader().getHeaderRec().setMessageID(500);
        msgIn2.getBody().getVariantTop().setFieldValue(1);
        msgIn2.getBody().getVariantTop().getSeqB().getRecB().setFieldB1(4500);

        for (i = 0; i < 15; ++i)
        {
            MsgIn.Body.VariantTop.SeqB.ListB.RecBInner temprec = new MsgIn.Body.VariantTop.SeqB.ListB.RecBInner();
            temprec.setFieldB2((short)(5 + i));
            msgIn2.getBody().getVariantTop().getSeqB().getListB().addElement(temprec);
        }

        // copy entire msg2 into msg1, verify new contents are correct
        msgIn2.encode(buff, 0);
        msgIn1.decode(buff, 0);

        Assert.AreEqual(500, msgIn1.getHeader().getHeaderRec().getMessageID());
        Assert.AreEqual(1, msgIn1.getBody().getVariantTop().getFieldValue());
        Assert.AreEqual(4500, msgIn1.getBody().getVariantTop().getSeqB().getRecB().getFieldB1());

        for (i = 0; i < 15; ++i)
        {
            Assert.AreEqual(5 + i, msgIn1.getBody().getVariantTop().getSeqB().getListB().getElement(i).getFieldB2());
        }

        // reset msg1.
        resetMessage(msgIn1);

        // copy only variant from msg2 into msg1, verify contents
        msgIn2.getBody().getVariantTop().encode(buff, 0);
        msgIn1.getBody().getVariantTop().decode(buff, 0);

        Assert.AreEqual(1000, msgIn1.getHeader().getHeaderRec().getMessageID()); // unchanged from reset values
        Assert.AreEqual(1, msgIn1.getBody().getVariantTop().getFieldValue());
        Assert.AreEqual(4500, msgIn1.getBody().getVariantTop().getSeqB().getRecB().getFieldB1());

        for (i = 0; i < 15; ++i)
        {
            Assert.AreEqual(5 + i, msgIn1.getBody().getVariantTop().getSeqB().getListB().getElement(i).getFieldB2());
        }

        // reset msg1.
        resetMessage(msgIn1);

        // copy only seqB's listB from msg2 into msg1, verify contents.
        msgIn2.getBody().getVariantTop().getSeqB().getListB().encode(buff, 0);
        msgIn1.getBody().getVariantTop().getSeqB().getListB().decode(buff, 0);

        Assert.AreEqual(1000, msgIn1.getHeader().getHeaderRec().getMessageID());                  // unchanged from reset values
        Assert.AreEqual(1, msgIn1.getBody().getVariantTop().getFieldValue());
        Assert.AreEqual(9000, msgIn1.getBody().getVariantTop().getSeqB().getRecB().getFieldB1()); // should also be unchanged.

        for (i = 0; i < 15; ++i)
        {
            Assert.AreEqual(5 + i, msgIn1.getBody().getVariantTop().getSeqB().getListB().getElement(i).getFieldB2());
        }

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