AppendFill() public method

Takes bytes starting from an offset in an array segment and appends as many as possible to the buffer.
This method will append a maximum of count elements to the end of the buffer, starting at offset in buffer.

If there is not enough space for count elements, it will fill the remaining space with bytes from the start of buffer.

Thrown if is . Thrown if is negative or is non-positive. Thrown if the array segment given by the and parameters falls outside of the given array's bounds.
public AppendFill ( byte buffer, int offset, int count ) : int
buffer byte The array to read from.
offset int The start of the segment.
count int The number of bytes to append.
return int
        public void AppendFill_Should_Return_Written_Bytes_When_FreeSpace_Insufficient()
        {
            var buffer = new BoundedBuffer(9);
            var bytes = Helpers.GetRandomBytes(10);

            var written = buffer.AppendFill(bytes, 0, 10);

            written.Should().Be(9);
        }
        public void AppendFill_Should_Decrease_FreeSpace()
        {
            var buffer = new BoundedBuffer(30);
            var bytes = Helpers.GetRandomBytes(10);

            buffer.AppendFill(bytes, 0, 10);

            buffer.FreeSpace.Should().Be(20);
        }
        public void AppendFill_Should_Return_Written_Bytes()
        {
            var buffer = new BoundedBuffer(30);
            var bytes = Helpers.GetRandomBytes(10);

            var written = buffer.AppendFill(bytes, 0, 10);

            written.Should().Be(10);
        }
        public void AppendFill_Should_Decrease_FreeSpace_Until_Zero()
        {
            var buffer = new BoundedBuffer(16);
            var bytes = Helpers.GetRandomBytes(32);

            buffer.AppendFill(bytes, 0, 32);

            buffer.FreeSpace.Should().Be(0);
        }
Beispiel #5
0
        public void AppendFill_Should_Return_Written_Bytes_When_FreeSpace_Insufficient()
        {
            var buffer = new BoundedBuffer(9);
            var bytes  = Helpers.GetRandomBytes(10);

            var written = buffer.AppendFill(bytes, 0, 10);

            written.Should().Be(9);
        }
Beispiel #6
0
        public void AppendFill_Should_Return_Written_Bytes()
        {
            var buffer = new BoundedBuffer(30);
            var bytes  = Helpers.GetRandomBytes(10);

            var written = buffer.AppendFill(bytes, 0, 10);

            written.Should().Be(10);
        }
Beispiel #7
0
        public void AppendFill_Should_Decrease_FreeSpace_Until_Zero()
        {
            var buffer = new BoundedBuffer(16);
            var bytes  = Helpers.GetRandomBytes(32);

            buffer.AppendFill(bytes, 0, 32);

            buffer.FreeSpace.Should().Be(0);
        }
Beispiel #8
0
        public void AppendFill_Should_Decrease_FreeSpace()
        {
            var buffer = new BoundedBuffer(30);
            var bytes  = Helpers.GetRandomBytes(10);

            buffer.AppendFill(bytes, 0, 10);

            buffer.FreeSpace.Should().Be(20);
        }
        public void AppendFill_Should_Fill_Buffer_When_FreeSpace_Insufficient()
        {
            var buffer = new BoundedBuffer(100);
            var bytes = Helpers.GetRandomBytes(127);
            buffer.AppendFill(bytes, 0, 100);

            var extracted = buffer.ExtractAndReset(0);

            extracted.Should().ContainInOrder(bytes.Take(100));
        }
        public void AppendFill_Should_Append_Whole_Array()
        {
            var buffer = new BoundedBuffer(128);

            var bytes = Helpers.GetRandomBytes(90);
            buffer.AppendFill(bytes, 0, 90);
            var extracted = buffer.ExtractAndReset(0);

            extracted.Take(90).Should().ContainInOrder(bytes);
        }
Beispiel #11
0
        public void AppendFill_Should_Fill_Buffer_When_FreeSpace_Insufficient()
        {
            var buffer = new BoundedBuffer(100);
            var bytes  = Helpers.GetRandomBytes(127);

            buffer.AppendFill(bytes, 0, 100);

            var extracted = buffer.ExtractAndReset(0);

            extracted.Should().ContainInOrder(bytes.Take(100));
        }
Beispiel #12
0
        public void AppendFill_Should_Append_Whole_Array()
        {
            var buffer = new BoundedBuffer(128);

            var bytes = Helpers.GetRandomBytes(90);

            buffer.AppendFill(bytes, 0, 90);
            var extracted = buffer.ExtractAndReset(0);

            extracted.Take(90).Should().ContainInOrder(bytes);
        }