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]); } }
public void testSetGetOperations() { Console.Out.WriteLine("\nexecuting test (testSetGetOperations)(TP_3.3.5.1)]: "); // verifying setMessageID/getMessageID reciprocity" msgIn1.getHeader().getHeaderRec().setMessageID(5); Assert.AreEqual(5, msgIn1.getHeader().getHeaderRec().getMessageID()); msgIn1.getHeader().getHeaderRec().setMessageID(1); Assert.AreEqual(1, msgIn1.getHeader().getHeaderRec().getMessageID()); // verifying setField/getField reciprocity" 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(); MsgIn.Body.List2.Sublist1.Record1 R2 = new MsgIn.Body.List2.Sublist1.Record1(); MsgIn.Body.List2.Sublist1.Record1 R3 = new MsgIn.Body.List2.Sublist1.Record1(); MsgIn.Body.List2.Sublist1.Record1 R4 = new MsgIn.Body.List2.Sublist1.Record1(); R1.setField1((byte)5); R2.setField1((byte)6); R3.setField1((byte)7); R4.setField1((byte)8); L1.addElement(R1); L1.addElement(R2); L2.addElement(R3); L2.addElement(R4); msgIn1.getBody().getList2().addElement(L1); msgIn1.getBody().getList2().addElement(L2); Assert.AreEqual(5, msgIn1.getBody().getList2().getElement(0).getElement(0).getField1()); Assert.AreEqual(6, msgIn1.getBody().getList2().getElement(0).getElement(1).getField1()); Assert.AreEqual(7, msgIn1.getBody().getList2().getElement(1).getElement(0).getField1()); Assert.AreEqual(8, msgIn1.getBody().getList2().getElement(1).getElement(1).getField1()); // Test copy constructor // verifying copy constructor" msgIn2 = msgIn1; Assert.AreEqual(msgIn2, msgIn1); Assert.AreEqual(msgIn2.getBody().getList2().getNumberOfElements(), msgIn1.getBody().getList2().getNumberOfElements()); Assert.AreEqual(msgIn2.getBody().getList2().getElement(0).getNumberOfElements(), msgIn1.getBody().getList2().getElement(0).getNumberOfElements()); }