コード例 #1
0
        public static void CopyAfterReuse()
        {
            var dest = new MemoryStream();

            using var src = new ChunkSequence <byte>(data, 5).ToReadOnlySequence().AsStream();

            src.CopyTo(dest);
            Equal(data, dest.ToArray());
            Equal(data.Length, src.Length);

            dest.Dispose();
            dest         = new MemoryStream();
            src.Position = 0L;
            src.CopyTo(dest);
            Equal(data, dest.ToArray());
            Equal(data.Length, src.Length);
        }
コード例 #2
0
 public static void SeekFromEnd()
 {
     using var dest = new MemoryStream();
     using var src  = new ChunkSequence <byte>(data, 5).ToReadOnlySequence().AsStream();
     Equal(data.Length - 1, src.Seek(-1L, SeekOrigin.End));
     src.CopyTo(dest);
     Equal(1L, dest.Length);
     Equal(data[^ 1], dest.ToArray()[0]);
コード例 #3
0
        public static void SeekAndCopy()
        {
            using var dest = new MemoryStream();
            using var src  = new ChunkSequence <byte>(data, 5).ToReadOnlySequence().AsStream();
            NotEqual(0L, src.Length);
            src.Position = data.Length;

            src.CopyTo(dest);
            Equal(0L, dest.Length);
        }