Exemplo n.º 1
0
        public void should_be_able_to_take_a_buffer_from_the_current_position()
        {
            BufferListStream            sut      = new BufferListStream();
            List <ArraySegment <byte> > segments = new List <ArraySegment <byte> >();

            for (int i = 0; i < 10; i++)
            {
                segments.Add(GetSegment(new byte[16], 512, 1024));
            }
            sut.Initialize(segments);

            // pre-condition
            Assert.AreEqual(0, sut.Position);

            sut.Position += 24;

            // act
            var actual = sut.Take(36);

            var totalLength = actual.Sum(segment => segment.Count);

            // assert
            Assert.IsNotNull(actual);
            Assert.AreEqual(36, totalLength);
            // TODO: check if the data is correct
        }