Exemple #1
0
        public void Take_MultipleAdds_ProperlyReturnsData()
        {
            var buffer = new ChunksBuffer();

            var expected = new byte[] { 1, 2 };

            buffer.Add(expected);
            buffer.Add(new byte[3]);
            var received = buffer.Take(5);

            Assert.That(received, Is.EqualTo(expected));
        }
Exemple #2
0
        public void CompleteAdding_AddAsyncCalled_ThrowsInvalidOperationException()
        {
            var buffer = new ChunksBuffer();

            buffer.CompleteAdding();

            Assert.Throws <InvalidOperationException>(() => buffer.Add(new byte[] {}));
        }
Exemple #3
0
        public void Take_SizeGreaterThanBufferSize_ReturnsSizeEqualToBufferSize()
        {
            var buffer = new ChunksBuffer();

            buffer.Add(new byte[1]);
            var received = buffer.Take(2);

            Assert.That(received.Count, Is.EqualTo(1));
        }
Exemple #4
0
        public async Task TakeAsync_SizeLessThanBufferSize_ReturnsRequestedSize()
        {
            var buffer = new ChunksBuffer();

            var takeTask = buffer.TakeAsync(1);

            buffer.Add(new byte[2]);
            var received = await takeTask;

            Assert.That(received.Count, Is.EqualTo(1));
        }