Exemplo n.º 1
0
        public static void BuildSequence()
        {
            using var builder = new SequenceBuilder <byte>(1024);

            // must be greater than 4096 because it's a default size of arrays obtained from ArrayPool<T>.Shared
            var expected = RandomBytes(5000);

            builder.Write(expected);
            Equal(expected, builder.As <IReadOnlySequenceSource <byte> >().Sequence.ToArray());
        }
Exemplo n.º 2
0
        public static void CheckFragmentation()
        {
            using var builder = new SequenceBuilder <byte>(1024);

            // must be greater than 4096 because it's a default size of arrays obtained from ArrayPool<T>.Shared
            var expected = RandomBytes(5000);

            builder.Write(expected);
            Equal(expected.Length, builder.WrittenCount);
            var actual = new byte[expected.Length];

            Equal(actual.Length, builder.CopyTo(actual));
            Equal(expected, actual);
        }
Exemplo n.º 3
0
 public static void BuildString()
 {
     using var builder = new SequenceBuilder <char>();
     builder.Write(new[] { 'H', 'e', 'l', 'l', 'o' });
     Equal("Hello", builder.BuildString());
 }
Exemplo n.º 4
0
 public static void UseAutoChunkSize()
 {
     using var builder = new SequenceBuilder <byte>();
     builder.Write(new byte[] { 10, 20, 30 });
     Equal(3L, builder.WrittenCount);
 }
Exemplo n.º 5
0
 public static void ReadWriteUsingSequenceBuilder()
 {
     using var builder = new SequenceBuilder <byte>();
     Null(builder.As <IGrowableBuffer <byte> >().Capacity);
     ReadWriteTest(builder);
 }