Ejemplo n.º 1
0
        public static async Task ToBlittableType()
        {
            var bytes = new byte[sizeof(decimal)];

            Span.AsReadOnlyBytes(42M).CopyTo(bytes);
            var dto = new BinaryTransferObject(bytes);

            Equal(42M, await dto.ToTypeAsync <decimal, BinaryTransferObject>());
        }
Ejemplo n.º 2
0
        public static async Task MemoryDTO3()
        {
            IDataTransferObject dto = new BinaryTransferObject <long> {
                Content = 42L
            };

            Equal(sizeof(long), dto.Length);
            True(dto.IsReusable);
            var writer = new ArrayBufferWriter <byte>();
            await dto.WriteToAsync(writer);

            Equal(sizeof(long), writer.WrittenCount);
            Equal(42L, BitConverter.ToInt64(writer.WrittenSpan));
            Equal(42L, await dto.ToTypeAsync <long, IDataTransferObject>());
        }