Exemple #1
0
        public async Task WriteToStreamAsync()
        {
            var bnumber = new BNumber(1234);

            var ms = new MemoryStream();
            await bnumber.EncodeToAsync(ms);

            var result = Encoding.UTF8.GetString(ms.ToArray());

            result.Should().Be("i1234e");
        }
Exemple #2
0
        public async Task WriteToPipeWriterAsync()
        {
            var bnumber = new BNumber(1234);

            var(reader, writer) = new Pipe();

            await bnumber.EncodeToAsync(writer);

            reader.TryRead(out var readResult);

            var result = Encoding.UTF8.GetString(readResult.Buffer.First.Span.ToArray());

            result.Should().Be("i1234e");
        }