Beispiel #1
0
        public async Task WritesObjectCorretly()
        {
            var  formatter = new DeepSleepJsonMediaSerializer(null);
            long length    = 0;

            var obj = new MyType
            {
                MyBool = true
            };

            using var ms = new MemoryStream();
            await formatter.WriteType(ms, obj, (l) => length = l).ConfigureAwait(false);

            ms.Length.Should().BeGreaterThan(0);
            length.Should().Be(ms.Length);
        }
Beispiel #2
0
        public async Task ReadsJsonCorrectly4()
        {
            var json = @"{
    ""EmailAddress"": ""*****@*****.**"",
    ""Password"": ""my-ut-password""
}";

            using var ms     = new MemoryStream();
            using var writer = new StreamWriter(ms);

            await writer.WriteAsync(json).ConfigureAwait(false);

            writer.Flush();
            ms.Seek(0, SeekOrigin.Begin);

            var formatter = new DeepSleepJsonMediaSerializer(null);
            await formatter.ReadType(ms, typeof(UserAccountLoginBodyRq)).ConfigureAwait(false);
        }