コード例 #1
0
        public void ShouldSerializeToMsgPack()
        {
            IMessageSerializer serializer = new MsgPackMessageSerializer();

            var message = new TestMessageProto {
                Id = 123, Name = "SomeName"
            };
            var serialize = serializer.Serialize(message);


            Assert.NotNull(serialize);
            Assert.Equal(21, serialize.Length);
        }
コード例 #2
0
        public void ShouldSerializeToMsgPack()
        {
            IMessageSerializer serializer = new MsgPackMessageSerializer();

            var message = new TestMessage {
                Id = 123, Name = "SomeName"
            };
            var serialize = serializer.Serialize(message);

            Assert.That(serialize, Is.Not.Null);
            Assert.That(serialize, Is.Not.Empty);
            Assert.That(serialize, Has.Length.EqualTo(20));
        }
コード例 #3
0
        public void ShouldDeserializeFromMsgPack()
        {
            IMessageSerializer serializer = new MsgPackMessageSerializer();
            IMessageDeserializer <TestMessageProto> deserializer = new MsgPackMessageDeserializer <TestMessageProto>();

            // see MsgPack spec limitation regarding UTC dates
            // https://github.com/msgpack/msgpack-cli/wiki#datetime
            var message = new TestMessageProto {
                Id = 123, Name = "SomeName", Date = new DateTime(2010, 2, 10, 13, 22, 59, DateTimeKind.Utc)
            };
            var serialize   = serializer.Serialize(message);
            var deserialize = deserializer.Deserialize(serialize);

            Assert.Equal(message.Id, deserialize.Id);
            Assert.Equal(message.Name, deserialize.Name);
            Assert.Equal(message.Date, deserialize.Date);
        }