public static async Task ExceptionCheck() { using var ms = new MemoryStream(new byte[] { 1, 3, 5, 8, 12 }); using var segment = new StreamSegment(ms); True(segment.CanRead); True(segment.CanSeek); False(segment.CanWrite); Equal(ms.CanTimeout, segment.CanTimeout); Throws <NotSupportedException>(() => segment.WriteByte(2)); Throws <NotSupportedException>(() => segment.Write(new byte[3], 0, 3)); Throws <NotSupportedException>(() => segment.Write(new byte[2])); Throws <NotSupportedException>(() => segment.BeginWrite(new byte[2], 0, 2, null, null)); Throws <InvalidOperationException>(() => segment.EndWrite(Task.CompletedTask)); await ThrowsAsync <NotSupportedException>(() => segment.WriteAsync(new byte[3], 0, 3)); await ThrowsAsync <NotSupportedException>(segment.WriteAsync(new ReadOnlyMemory <byte>()).AsTask); }
public static async Task ExceptionCheck() { using var ms = new MemoryStream(new byte[] { 1, 3, 5, 8, 12 }); using var segment = new StreamSegment(ms); Throws <NotSupportedException>(() => segment.WriteByte(2)); Throws <NotSupportedException>(() => segment.Write(new byte[3], 0, 3)); await ThrowsAsync <NotSupportedException>(() => segment.WriteAsync(new byte[3], 0, 3)); }