Exemple #1
0
        public void fix_map()
        {
            var f = new MsgPackFormatter();

            f.BeginMap(2);
            f.Key("0");
            f.Value(1);
            f.Key("2");
            f.Value(3);
            f.EndMap();
            var bytes =
                f.GetStoreBytes();

            ;

            Assert.AreEqual(new Byte[]
            {
                0x82,       // map2

                0xa1, 0x30, // "0"
                0x01,       // 1

                0xa1, 0x32, // "2"
                0x03        // 3
            }, bytes.ToEnumerable());

            var value = MsgPackParser.Parse(bytes);

            Assert.AreEqual(2, value.GetObjectCount());
            Assert.AreEqual(1, value["0"].GetValue());
            Assert.AreEqual(3, value["2"].GetValue());
        }