private void Setup(Guid testId) { var items = new Dictionary <object, object>(); var requestDto = new GetTestDocumentRequestDto { TestDocumentId = testId, }; items.Add(RequestBinding.ParameterDescriptorName, requestDto); _httpContextMock.SetupGet(context => context.Items) .Returns(items); _valueProvider = new DocumentValueProvider(typeof(TestDocument), _httpRequestMock.Object, CancellationToken.None); _documentProviderMock.Setup(provider => provider.GetDocumentAsync(It.IsAny <HttpRequest>(), It.IsAny <Type>(), It.IsAny <CancellationToken>())) .ReturnsAsync((HttpRequest httpRequest, Type type, CancellationToken CancellationToken) => { object instance = null; if (httpRequest.HttpContext.Items.TryGetValue( RequestBinding.ParameterDescriptorName, out var requestObject) && requestObject is GetTestDocumentRequestDto requestDto) { instance = new TestDocument { Id = requestDto.TestDocumentId, }; } return(instance); }); }
private void Setup(string stringProperty, DateTime dateTimeProperty) { var items = new Dictionary <object, object>(); var requestDto = new SearchTestDocumentsRequestDto { StringProperty = stringProperty, DateTimeProperty = dateTimeProperty, }; items.Add(RequestBinding.ParameterDescriptorName, requestDto); _httpContextMock.SetupGet(context => context.Items) .Returns(items); _valueProvider = new DocumentValueProvider(typeof(IEnumerable <TestDocument>), _httpRequestMock.Object, CancellationToken.None); _documentProviderMock.Setup(provider => provider.GetDocumentsAsync(It.IsAny <HttpRequest>(), It.IsAny <Type>(), It.IsAny <CancellationToken>())) .ReturnsAsync((HttpRequest httpRequest, Type type, CancellationToken CancellationToken) => { object instance = null; if (httpRequest.HttpContext.Items.TryGetValue( RequestBinding.ParameterDescriptorName, out var requestObject) && requestObject is SearchTestDocumentsRequestDto requestDto) { instance = Enumerable.Range(1, 5) .Select(number => new TestDocument { StringProperty = requestDto.StringProperty, DateTimeProperty = requestDto.DateTimeProperty, }); } return(instance); }); }