System.IO.Tests.StreamMethods.FlushAsyncTest C# (CSharp) Method

FlushAsyncTest() private method

private FlushAsyncTest ( ) : System.Threading.Task
return System.Threading.Task
        public async Task FlushAsyncTest()
        {
            byte[] data = Enumerable.Range(0, 8000).Select(i => (byte)i).ToArray();
            Stream stream = CreateStream();

            for (int i = 0; i < 4; i++)
            {
                await stream.WriteAsync(data, 2000 * i, 2000);
                await stream.FlushAsync();
            }

            stream.Position = 0;
            byte[] output = new byte[data.Length];
            int bytesRead, totalRead = 0;
            while ((bytesRead = await stream.ReadAsync(output, totalRead, data.Length - totalRead)) > 0)
                totalRead += bytesRead;
            Assert.Equal(data, output);
        }