public static async Task ReadWriteAsync(int threshold) { using var writer = new FileBufferingWriter(memoryThreshold: threshold, asyncIO: true); var bytes = new byte[500]; for (byte i = 0; i < byte.MaxValue; i++) { bytes[i] = i; } await writer.WriteAsync(bytes, 0, byte.MaxValue); await writer.WriteAsync(bytes.AsMemory(byte.MaxValue)); Equal(bytes.Length, writer.Length); using var manager = await writer.GetWrittenContentAsync(); Equal(bytes, manager.Memory.ToArray()); }
public static async Task CompatWithReadOnlySequenceAsync(int threshold) { await using var writer = new FileBufferingWriter(memoryThreshold: threshold, asyncIO: true); var bytes = new byte[500]; for (byte i = 0; i < byte.MaxValue; i++) { bytes[i] = i; } await writer.WriteAsync(bytes, 0, 450); await writer.WriteAsync(bytes.AsMemory(450)); Equal(bytes.Length, writer.Length); using var source = await writer.GetWrittenContentAsync(10); Equal(bytes, source.Sequence.ToArray()); }