public async Task <IActionResult> Get([FromQuery] GetAssetRegisterVersionsRequest request)
        {
            if (!request.IsValid())
            {
                return(StatusCode(400));
            }

            return(this.StandardiseResponse <GetAssetRegisterVersionsResponse, AssetRegisterVersionOutputModel>(
                       await _getAssetRegisterVersionsUseCase.ExecuteAsync(request, CancellationToken.None)
                       .ConfigureAwait(false)));
        }
示例#2
0
        public async Task GivenValidRequest_WhenWeExecute_ThenWeCallGatewayWithParams(int?page, int?pageSize)
        {
            //arrange
            _mockGateway.Setup(s => s.Search(It.IsAny <IPagedQuery>(), It.IsAny <CancellationToken>())).ReturnsAsync(new PagedResults <IAssetRegisterVersion>
            {
                NumberOfPages = 1,
                Results       = new List <IAssetRegisterVersion>(),
                TotalCount    = 1
            });

            var request = new GetAssetRegisterVersionsRequest
            {
                Page     = page,
                PageSize = pageSize
            };
            //act
            var response = await _classUnderTest.ExecuteAsync(request, CancellationToken.None)
                           .ConfigureAwait(false);

            //assert
            response.Should().NotBeNull();
            _mockGateway.Verify(v => v.Search(It.Is <IPagedQuery>(i => i.Page == page && i.PageSize == pageSize), It.IsAny <CancellationToken>()));
        }