public void RentAndPopulateFromStream_ShouldThrow_WhenContentLengthIsZero()
        {
            var stream = new MemoryStream();

            Action act = () => SqsReceiveResponseMemoryPool.RentAndPopulateFromStream(stream, 0);

            act.Should().Throw <ArgumentException>(because: "we should only both renting memory if there is content to store.");
        }
        public void RentAndPopulateFromStream_ShouldReturnMemoryOwnerWithExpectedLength()
        {
            var stream = new MemoryStream();

            var result = SqsReceiveResponseMemoryPool.RentAndPopulateFromStream(stream, 5);

            result.Memory.Length.Should().Be(5);
        }
        public void RentAndPopulateFromStream_ShouldThrow_WhenStreamIsNotReadable()
        {
            var stream = new NonReadableStream();

            Action act = () => SqsReceiveResponseMemoryPool.RentAndPopulateFromStream(stream, 1);

            act.Should().Throw <ArgumentException>(because: "the stream must be readable");
        }
Exemplo n.º 4
0
        public void AwaitRentAndPopulateFromStream()
        {
            _stream.Position = 0;

            using (var responseMemory = SqsReceiveResponseMemoryPool.RentAndPopulateFromStream(_stream, _contentLength))
            {
                var memory = responseMemory.Memory;
            }
        }