Esempio n. 1
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());

        // set/add elements to active sequence, SeqA, verify changes are recorded.
        msgIn1.getBody().getVariantTop().getSeqA().getRecA().setFieldA1(45);
        for (int i = 0; i < 10; ++i)
        {
            MsgIn.Body.VariantTop.SeqA.ListA.RecAInner temprec = new MsgIn.Body.VariantTop.SeqA.ListA.RecAInner();
            temprec.setFieldA2((short)(10 + i));
            msgIn1.getBody().getVariantTop().getSeqA().getListA().addElement(temprec);
        }

        Assert.AreEqual(45, msgIn1.getBody().getVariantTop().getSeqA().getRecA().getFieldA1());
        for (int i = 0; i < 10; ++i)
        {
            Assert.AreEqual(10 + i, msgIn1.getBody().getVariantTop().getSeqA().getListA().getElement(i).getFieldA2());
        }


        // set/add elements to active sequence, SeqB, verify changes are recorded.
        msgIn1.getBody().getVariantTop().setFieldValue(1);
        msgIn1.getBody().getVariantTop().getSeqB().getRecB().setFieldB1(90);
        for (int i = 0; i < 5; ++i)
        {
            MsgIn.Body.VariantTop.SeqB.ListB.RecBInner temprec = new MsgIn.Body.VariantTop.SeqB.ListB.RecBInner();
            temprec.setFieldB2((short)(20 + i));
            msgIn1.getBody().getVariantTop().getSeqB().getListB().addElement(temprec);
        }

        Assert.AreEqual(90, msgIn1.getBody().getVariantTop().getSeqB().getRecB().getFieldB1());
        for (int i = 0; i < 5; ++i)
        {
            Assert.AreEqual(20 + i, msgIn1.getBody().getVariantTop().getSeqB().getListB().getElement(i).getFieldB2());
        }

        // check message size is correct
        // 2-byte ushort msg ID header, 1-byte vtag field, 2-byte ushort in RecB, 1-byte count field for ListB,
        // 5 2-byte ushorts in ListB
        Assert.AreEqual(2 + 1 + 2 + 1 + 5 * 2, msgIn1.getSize());

        Console.Out.WriteLine("   [completed test (testSetGetOperations)] ");
    }
Esempio n. 2
0
    // need to repeatedly reset the contents of msgIn1 in during testEncodeDecodeOperations.
    void resetMessage(MsgIn for_reset)
    {
        for_reset.getHeader().getHeaderRec().setMessageID(1000);
        for_reset.getBody().getVariantTop().setFieldValue(1);
        for_reset.getBody().getVariantTop().getSeqB().getRecB().setFieldB1(9000);

        for (int i = 0; i < 10; ++i)
        {
            MsgIn.Body.VariantTop.SeqB.ListB.RecBInner temprec = new MsgIn.Body.VariantTop.SeqB.ListB.RecBInner();
            temprec.setFieldB2((short)(20 + i));
            for_reset.getBody().getVariantTop().getSeqB().getListB().addElement(temprec);
        }
    }
Esempio n. 3
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)] ");
    }
Esempio n. 4
0
    // need to repeatedly reset the contents of msgIn1 in during testEncodeDecodeOperations.
    void resetMessage(MsgIn for_reset)
    {
        for_reset.getHeader().getHeaderRec().setMessageID(1000);
        for_reset.getBody().getVariantTop().setFieldValue(1);
        for_reset.getBody().getVariantTop().getSeqB().getRecB().setFieldB1(9000);

        for (int i = 0; i < 10; ++i)
        {
            MsgIn.Body.VariantTop.SeqB.ListB.RecBInner temprec = new MsgIn.Body.VariantTop.SeqB.ListB.RecBInner();
            temprec.setFieldB2((short)(20 + i));
            for_reset.getBody().getVariantTop().getSeqB().getListB().addElement(temprec);
        }
    }
Esempio n. 5
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());

        // set/add elements to active sequence, SeqA, verify changes are recorded.
        msgIn1.getBody().getVariantTop().getSeqA().getRecA().setFieldA1(45);
        for (int i = 0; i < 10; ++i)
        {
            MsgIn.Body.VariantTop.SeqA.ListA.RecAInner temprec = new MsgIn.Body.VariantTop.SeqA.ListA.RecAInner();
            temprec.setFieldA2((short)(10 + i));
            msgIn1.getBody().getVariantTop().getSeqA().getListA().addElement(temprec);
        }

        Assert.AreEqual(45, msgIn1.getBody().getVariantTop().getSeqA().getRecA().getFieldA1());
        for (int i = 0; i < 10; ++i)
        {
            Assert.AreEqual(10 + i, msgIn1.getBody().getVariantTop().getSeqA().getListA().getElement(i).getFieldA2());
        }

        // set/add elements to active sequence, SeqB, verify changes are recorded.
        msgIn1.getBody().getVariantTop().setFieldValue(1);
        msgIn1.getBody().getVariantTop().getSeqB().getRecB().setFieldB1(90);
        for (int i = 0; i < 5; ++i)
        {
            MsgIn.Body.VariantTop.SeqB.ListB.RecBInner temprec = new MsgIn.Body.VariantTop.SeqB.ListB.RecBInner();
            temprec.setFieldB2((short)(20 + i));
            msgIn1.getBody().getVariantTop().getSeqB().getListB().addElement(temprec);
        }

        Assert.AreEqual(90, msgIn1.getBody().getVariantTop().getSeqB().getRecB().getFieldB1());
        for (int i = 0; i < 5; ++i)
        {
            Assert.AreEqual(20 + i, msgIn1.getBody().getVariantTop().getSeqB().getListB().getElement(i).getFieldB2());
        }

        // check message size is correct
        // 2-byte ushort msg ID header, 1-byte vtag field, 2-byte ushort in RecB, 1-byte count field for ListB,
        // 5 2-byte ushorts in ListB
        Assert.AreEqual(2 + 1 + 2 + 1 + 5 * 2, msgIn1.getSize());

        Console.Out.WriteLine("   [completed test (testSetGetOperations)] ");
    }
Esempio n. 6
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)] ");
    }