public async Task GetItemsPage_GetsProperPages(int amount, int expectedPages) { this.CreateItems(amount); var dto = new GetItemsPageDTO { Query = "", Page = 1, PageSize = 10, Descending = true }; var result = await this.itemController.GetItemsPage(dto); var response = Assert.IsType <OkNegotiatedContentResult <ItemsPageViewModel> >(result); Assert.True(response.Content.Items.Count() <= 10); Assert.Equal(1, response.Content.Page); Assert.Equal(expectedPages, response.Content.PageCount); }
public async Task GetItemsPage_GetsProperPages() { var items = new List <ItemViewModel>(); for (int i = 0; i < 100; i++) { var item = new ItemViewModel() { Id = i, Name = $"Name {i}", Description = $"Description {1}" }; items.Add(item); } var itemsPageViewModel = new ItemsPageViewModel() { Items = items, Page = 1, PageCount = 10, ResultCount = 100 }; this.itemService.Setup(i => i.GetItemsPageAsync(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <bool>())) .Returns(Task.FromResult(itemsPageViewModel)); var dto = new GetItemsPageDTO { Query = "Name", Page = 1, PageSize = 10, Descending = true, }; var result = await this.itemController.GetItemsPage(dto); var response = Assert.IsType <OkNegotiatedContentResult <ItemsPageViewModel> >(result); Assert.Equal(100, response.Content.Items.Count); Assert.Equal(1, response.Content.Page); Assert.Equal(10, response.Content.PageCount); Assert.Equal(100, response.Content.ResultCount); }