Ejemplo n.º 1
0
        void Same <T>() where T : IMessage, new()
        {
            var src = FixtureFactory.Create <T>(10);
            var buf = StaticPacker.Pack(src);
            var dst = StaticPacker.Unpack <T>(buf);

            Assert.AreEqual(Json.To(dst), Json.To(src));
        }
Ejemplo n.º 2
0
        async Task RequestSame <T>(HttpClient client, string url, bool fixSort, bool fixNumber, bool skipCheck) where T : IMessage, new()
        {
            var src     = FixtureFactory.Create <T>(10);
            var content = new ByteArrayContent(StaticPacker.Pack(src));
            var ret     = await client.PostAsync(url + src.GetType().Name, content);

            var buf = await ret.Content.ReadAsByteArrayAsync();

            var dst = StaticPacker.Unpack <T>(buf);

            if (src is AllParameter)
            {
                FixParam(src as AllParameter, fixSort, fixNumber);
                FixParam(dst as AllParameter, fixSort, fixNumber);
            }
            if (!skipCheck)
            {
                Assert.AreEqual(Json.To(dst), Json.To(src));
            }
        }