public async Task ListTermsOfServicesAsync_WithNoInputs_ReturnsList()
        {
            // Arrange
            var inList = new List <TermsOfServiceModel>
            {
                new TermsOfServiceModel {
                    AgreementName = "Test TermsOfServices 1", Id = Guid.NewGuid()
                },
                new TermsOfServiceModel {
                    AgreementName = "Test TermsOfServices 2", Id = Guid.NewGuid()
                },
                new TermsOfServiceModel {
                    AgreementName = "Test TermsOfServices 3", Id = Guid.NewGuid()
                }
            };

            PaginatedResult <TermsOfServiceModel> paginatedResult = new PaginatedResult <TermsOfServiceModel>
            {
                CurrentPage = 1,
                PageCount   = 1,
                PageSize    = 3,
                Results     = inList
            };

            termsOfServiceService.GetPaginatedListAsync(Arg.Any <int>(), Arg.Any <int>(), Arg.Any <bool>(), Arg.Any <string>(), Arg.Any <List <KeyValuePair <string, string> > >()).Returns(paginatedResult);
            var controller = new TermsOfServiceController(termsOfServiceService, orderByHelper, paginationHelper, mapper);

            // Act
            IActionResult actionResult = await controller.ListTermsOfServicesAsync(0, 0, true, string.Empty, string.Empty);

            // Assert
            var okResult = actionResult as OkObjectResult;

            Assert.NotNull(okResult);

            var outList = okResult.Value as List <TermsOfServiceListItem>;

            Assert.NotNull(outList);

            for (var i = 0; i < outList.Count; i++)
            {
                Assert.Equal(outList[i].Uuid, inList[i].Id);
                Assert.Equal(outList[i].AgreementName, inList[i].AgreementName);
            }
        }
        public async override Task <IActionResult> ListTermsOfServicesAsync([FromQuery] int page, [FromQuery][Range(1, 20)] int size, [FromQuery] bool includeRelations, [FromQuery][StringLength(255, MinimumLength = 0)] string filterAgreementName, [FromQuery] string orderBy)
        {
            List <KeyValuePair <string, string> > orderByKeyValueList = orderByHelper.ConvertCommaSeparateOrderByStringToKeyValuePairList(orderBy);

            // Validate only correct order by components were supplied.
            orderByHelper.ValidateOrderByListOnlyContainsCertainElements(orderByKeyValueList, new List <string> {
                "agreementName"
            });
            PaginatedResult <TermsOfServiceModel> paginatedResult = await termsOfServiceService.GetPaginatedListAsync(page, size, includeRelations, filterAgreementName, orderByKeyValueList);

            // Generate a K-V pair of all the current applied filters sent to the controller so that pagination header URLs can include them.
            List <KeyValuePair <string, string> > currrentFilters = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("filterAgreementName", filterAgreementName)
            };

            paginationHelper.AddPaginationHeaderMetaDataToResponse(paginatedResult, currrentFilters, orderBy, "ListTermsOfServices", Url, Response);

            return(Ok(mapper.Map <List <TermsOfServiceListItem> >(paginatedResult.Results)));
        }