public void TestLongCodec()
        {
            var longCodec = new LongBcdCodec();

            sbyte[] data1 =
            {
                1,
                0x23,
                0x45,
                0x67,
                unchecked ((sbyte)0x89),
                00,
                00,
                00,
                00,
                00
            };
            Assert.Equal(123456789L,
                         (long)longCodec.DecodeBinaryField(data1,
                                                           0,
                                                           5));
            Assert.Equal(1234567890L,
                         (long)longCodec.DecodeBinaryField(longData2,
                                                           0,
                                                           5));
            var cod1 = longCodec.EncodeBinaryField(123456789L);
            var cod2 = longCodec.EncodeBinaryField(1234567890L);

            for (var i = 0; i < 5; i++)
            {
                Assert.Equal(data1[i],
                             cod1[i]);
                Assert.Equal(longData2[i],
                             cod2[i]);
            }
        }
        private void TestFieldType(IsoType type,
                                   FieldParseInfo fieldParser,
                                   int offset1,
                                   int offset2)
        {
            var bigintCodec = new BigIntBcdCodec();
            var longCodec   = new LongBcdCodec();
            var mfact       = new MessageFactory <IsoMessage>();
            var tmpl        = new IsoMessage
            {
                Binary = true,
                Type   = 0x200
            };

            tmpl.SetValue(2,
                          1234567890L,
                          longCodec,
                          type,
                          0);
            tmpl.SetValue(3,
                          b29,
                          bigintCodec,
                          type,
                          0);
            mfact.AddMessageTemplate(tmpl);
            mfact.SetCustomField(2,
                                 longCodec);
            mfact.SetCustomField(3,
                                 bigintCodec);
            var parser = new Dictionary <int, FieldParseInfo>
            {
                { 2, fieldParser },
                { 3, fieldParser }
            };

            mfact.SetParseMap(0x200,
                              parser);
            mfact.UseBinaryMessages = true;

            //Test encoding
            tmpl = mfact.NewMessage(0x200);
            var buf     = tmpl.WriteData();
            var message = HexCodec.HexEncode(buf,
                                             0,
                                             buf.Length);

            Console.WriteLine("MESSAGE: " + message);
            for (var i = 0; i < 5; i++)
            {
                var b = longData2[i];
                Assert.Equal(b,
                             buf[i + offset1]);
            }

            for (var i = 0; i < 15; i++)
            {
                Assert.Equal(bigintData1[i],
                             buf[i + offset2]);
            }

            //Test parsing
            tmpl = mfact.ParseMessage(buf,
                                      0);
            Assert.Equal(1234567890L,
                         tmpl.GetObjectValue(2));
            Assert.Equal(b29,
                         tmpl.GetObjectValue(3));
        }