Exemple #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());
        }
Exemple #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);
        }
Exemple #3
0
 public static void BuildString()
 {
     using var builder = new SequenceBuilder <char>();
     builder.Write(new[] { 'H', 'e', 'l', 'l', 'o' });
     Equal("Hello", builder.BuildString());
 }
Exemple #4
0
 public static void UseAutoChunkSize()
 {
     using var builder = new SequenceBuilder <byte>();
     builder.Write(new byte[] { 10, 20, 30 });
     Equal(3L, builder.WrittenCount);
 }
Exemple #5
0
 public static void ReadWriteUsingSequenceBuilder()
 {
     using var builder = new SequenceBuilder <byte>();
     Null(builder.As <IGrowableBuffer <byte> >().Capacity);
     ReadWriteTest(builder);
 }