private async Task SetupAsync(TestRequestDto requestDto, Guid testId)
 {
     _httpRequestMock.SetupGet(request => request.Body)
     .Returns(await RequestValueProviderTest.CreateBodyAsync(requestDto));
     _httpRequestMock.SetupGet(request => request.HttpContext)
     .Returns(RequestValueProviderTest.CreateHttpMock(testId).Object);
     _httpRequestMock.SetupGet(request => request.Query)
     .Returns(RequestValueProviderTest.CreateQueryMock().Object);
 }
        private static async Task <Stream> CreateBodyAsync(TestRequestDto requestDto)
        {
            var stream  = new MemoryStream();
            var options = new JsonSerializerOptions
            {
                PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
            };

            await JsonSerializer.SerializeAsync(stream, requestDto, requestDto.GetType(), options, CancellationToken.None);

            stream.Seek(0, SeekOrigin.Begin);

            return(stream);
        }
        public async Task GetValueAsync_Should_Populate_Body_And_Route_Values_To_Result_Object()
        {
            var requestDto = new TestRequestDto
            {
                GuidProperty   = Guid.NewGuid(),
                IntProperty    = 123,
                StringProperty = Guid.NewGuid().ToString(),
            };
            var testId = Guid.NewGuid();

            await SetupAsync(requestDto, testId);

            var value = await _requestValueProvider.GetValueAsync();

            Assert.IsNotNull(value);

            var actual = value as TestRequestDto;

            Assert.IsNotNull(actual);
            Assert.AreEqual(requestDto.GuidProperty, actual.GuidProperty);
            Assert.AreEqual(requestDto.IntProperty, actual.IntProperty);
            Assert.AreEqual(requestDto.StringProperty, actual.StringProperty);
            Assert.AreEqual(testId, actual.TestId);
        }