Example #1
0
        internal static void UseNewtonsoftJson(JSend jsend)
        {
            var json         = JsonConvert.SerializeObject(jsend);
            var deserialized = JsonConvert.DeserializeObject <JSend>(json);

            Assert.Equal(jsend.status, deserialized.status);

            if (jsend.IsSuccess())
            {
                Assert.Equal(Any(jsend.data), Any(deserialized.data));
            }
            else if (jsend.IsFail())
            {
                Assert.Equal(Any(jsend.data), Any(deserialized.data));
            }
            else if (jsend.IsError())
            {
                Assert.Equal(jsend.code, deserialized.code);
                Assert.Equal(jsend.message, deserialized.message);
            }
        }
Example #2
0
        internal static void UseSystemJson(JSend jsend)
        {
            var json         = System.Text.Json.JsonSerializer.Serialize(jsend);
            var deserialized = System.Text.Json.JsonSerializer.Deserialize <JSend>(json);

            Assert.Equal(jsend.status, deserialized.status);

            if (jsend.IsSuccess())
            {
                Assert.Equal(Any(jsend.data), Any(deserialized.data));
            }
            else if (jsend.IsFail())
            {
                Assert.Equal(Any(jsend.data), Any(deserialized.data));
            }
            else if (jsend.IsError())
            {
                Assert.Equal(jsend.code, deserialized.code);
                Assert.Equal(jsend.message, deserialized.message);
            }
        }