Ejemplo n.º 1
0
        public void CanEnodeToStream()
        {
            var bnumber = new BNumber(42);

            using (var stream = new MemoryStream())
            {
                bnumber.EncodeTo(stream);

                stream.Length.Should().Be(4);
                stream.AsString().Should().Be("i42e");
            }
        }
Ejemplo n.º 2
0
        public async Task WriteToPipeWriter()
        {
            var bnumber = new BNumber(1234);

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

            bnumber.EncodeTo(writer);
            await writer.FlushAsync();

            reader.TryRead(out var readResult);

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

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