Example #1
0
        public void Should_reserve_current_capacity_in_memory_manager_when_growing_twice()
        {
            buffer.Write(Guid.NewGuid());
            buffer.Write(int.MaxValue);

            manager.ReceivedCalls().Should().HaveCount(1);
            manager.Received().TryReserveBytes(InitialSize);

            buffer.Write(Guid.NewGuid());

            manager.ReceivedCalls().Should().HaveCount(2);
            manager.Received().TryReserveBytes(InitialSize);
        }
        public void TryAcquire_should_not_allocate_new_buffers_when_there_are_spare_ones()
        {
            memoryManager.ClearReceivedCalls();

            for (var i = 0; i < 3; i++)
            {
                pool.TryAcquire(out _).Should().BeTrue();
            }

            memoryManager.ReceivedCalls().Should().BeEmpty();
        }