Esempio n. 1
0
        public void GetCountriesQueryParameters_Should_Be_Valid()
        {
            var model = new GetCountriesQueryParameters
            {
                Page = 1,
                Take = 1
            };

            var results = ValidateModel(model);

            results.Count.Should().Be(0);
        }
        public async Task Get_Pagination_OnInvoke_ReturnsExpectedMessage()
        {
            var queryParams = new GetCountriesQueryParameters
            {
                Page = 0,
                Take = 10
            };

            var expectedResponse = _fixture.Create <CountryForPaginationResponse>();

            _countriesRestService.GetAllForPagination(queryParams.Page, queryParams.Take).Returns(expectedResponse);

            var response = await _controller.GetAllCountriesForPagination(queryParams);

            var result = response.Result as OkObjectResult;

            result.StatusCode.Should().Be(StatusCodes.Status200OK);
            result.Value.Should().Be(expectedResponse);
        }
        public async Task <ActionResult <CountryForPaginationResponse> > GetAllCountriesForPagination([FromQuery()] GetCountriesQueryParameters queryParams)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = await _countriesService.GetAllForPagination(queryParams.Page, queryParams.Take);

            return(Ok(result));
        }