public async Task GetNextPartitionAsync() { var expected = TestHelper.GetRandomBuffer(10 * Constants.MB); var actual = new byte[expected.Length]; Assert.AreNotSame(expected, actual); using (var expectedStream = new NonSeekableStream(expected)) using (var reader = new StreamPartitioner(expectedStream)) { Assert.IsTrue(expectedStream.CanRead); Assert.IsFalse(expectedStream.CanSeek); do { var position = expectedStream.Position; using (StreamPartition buffer = await reader.GetNextPartitionAsync()) { if (buffer.Length == 0) { Assert.AreEqual(expectedStream.Length, expectedStream.Position); break; } else { Assert.IsTrue(buffer.CanRead); Assert.IsTrue(buffer.CanSeek); await buffer.ReadAsync(actual, (int)position, (int)buffer.Length); } } }while (true); TestHelper.AssertSequenceEqual(expected, actual); } }