ExtractAndReset() public method

Extracts the data from the BoundedBuffer and prepares it for the new data.
Thrown if is negative.
public ExtractAndReset ( int newCapacity ) : byte[]
newCapacity int The new capacity for the .
return byte[]
Beispiel #1
0
        public void ExtractAndReset_Should_Set_New_Capacity()
        {
            var buffer = new BoundedBuffer(100);

            buffer.ExtractAndReset(64);

            buffer.FreeSpace.Should().Be(64);
        }
        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 #4
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 #5
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);
        }
        public void ExtractAndReset_Should_Set_New_Capacity()
        {
            var buffer = new BoundedBuffer(100);

            buffer.ExtractAndReset(64);

            buffer.FreeSpace.Should().Be(64);
        }