public async Task ShouldReturnNullWhenNonSeekableStreamIsEmpty() { using (var stream = new TestStream()) { stream.DisableSeeking(); byte[] bytes = await stream.ToArrayAsync(); Assert.IsNull(bytes); } }
public async Task ShouldReturnEmptyArrayWhenNonSeekableStreamOnlyContainsPreamable() { using (var stream = new TestStream()) { stream.Write(Utf8Preamable, 0, Utf8Preamable.Length); stream.Position = 0; stream.DisableSeeking(); byte[] bytes = await stream.ToArrayAsync(); Assert.IsNotNull(bytes); Assert.AreEqual(0, bytes.Length); } }
public async Task ShouldReturnArrayWhenNonSeekableStreamContains9000Bytes() { using (var stream = new TestStream()) { byte[] data = Enumerable.Repeat((byte)68, 9000).ToArray(); stream.Write(data, 0, data.Length); stream.Position = 0; stream.DisableSeeking(); byte[] bytes = await stream.ToArrayAsync(); Assert.IsNotNull(bytes); Assert.AreEqual(9000, bytes.Length); } }
public async Task ShouldReturnArrayWhenNonSeekableStreamStartsWithPreamable() { using (var stream = new TestStream()) { stream.Write(Utf8Preamable, 0, 2); stream.Position = 0; stream.DisableSeeking(); byte[] bytes = await stream.ToArrayAsync(); Assert.IsNotNull(bytes); Assert.AreEqual(2, bytes.Length); Assert.AreEqual(Utf8Preamable[0], bytes[0]); Assert.AreEqual(Utf8Preamable[1], bytes[1]); } }
public async Task ShouldReturnArrayWhenNonSeekableStreamContainsData() { using (var stream = new TestStream()) { byte[] data = new byte[4] { 68, 73, 82, 75 }; stream.Write(data, 0, data.Length); stream.Position = 0; stream.DisableSeeking(); byte[] bytes = await stream.ToArrayAsync(); Assert.IsNotNull(bytes); Assert.AreEqual(4, bytes.Length); } }