Esempio n. 1
0
        public virtual void testEncode()
        {
            // empty frame should yield no bytes
            DataFrame data = new DataFrame();

            byte[] value = datatype.Encode(data);
            Assert.True(value.Length == 0);

            //other tests actually depend on the encoding of each field and their field types.

            // Add a string with the name of test
            data.Add("test", "abc");
            value = datatype.Encode(data);
            Assert.True(value.Length == 13);
            Assert.True(value[0] == 4);   // name of the field is 4 bytes long
            Assert.True(value[1] == 116); // t
            Assert.True(value[2] == 101); // e
            Assert.True(value[3] == 115); // s
            Assert.True(value[4] == 116); // t
            Assert.True(value[5] == 3);   // data type code is 3 - String
            Assert.True(value[6] == 0);   // first byte of unsigned integer for length
            Assert.True(value[7] == 0);   // second byte of unsigned integer for length
            Assert.True(value[8] == 0);   // third byte of unsigned integer for length
            Assert.True(value[9] == 3);   // fourth byte of unsigned integer for length
            Assert.True(value[10] == 97); // a
            Assert.True(value[11] == 98); // b
            Assert.True(value[12] == 99); // c
        }