public void DataFlowsThroughQueue() { //Arrange var queue = new FeedingQueue(0); var output = new byte[65536]; var task = Task.Factory.StartNew(() => { queue.Fill(output, 0, 32768); queue.Fill(output, 32768, output.Length - 32768); }); var bigData = new byte[100000]; //Act var buffer = new byte[5000]; for (int i = 0; i < 20; i++) { var data = Buffer(buffer.Length); Array.Copy(data, buffer, data.Length); queue.Add(buffer); Array.Copy(data, 0, bigData, data.Length * i, data.Length); } task.Wait(); //Assert var expected = bigData.Take(output.Length); Assert.That(output.SequenceEqual(expected), Is.True); }
public void QueueIgnoresBlocksOutsideRange() { //Arrange var data = Buffer(1000); //Act _queue.Add(data); //Assert Assert.That(_queue.BufferedBytes, Is.EqualTo(0)); }