|
| 1 | +using System.Net; |
| 2 | +using System.Threading.Tasks; |
| 3 | +using Microsoft.VisualStudio.TestTools.UnitTesting; |
| 4 | + |
| 5 | +namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests |
| 6 | +{ |
| 7 | + [TestClass] |
| 8 | + public class PaginationTests : AcceptanceTestsBase |
| 9 | + { |
| 10 | + [TestMethod] |
| 11 | + [DeploymentItem(@"Data\Comment.csv", @"Data")] |
| 12 | + [DeploymentItem(@"Data\Post.csv", @"Data")] |
| 13 | + [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] |
| 14 | + [DeploymentItem(@"Data\Tag.csv", @"Data")] |
| 15 | + [DeploymentItem(@"Data\User.csv", @"Data")] |
| 16 | + public async Task GetPage2Post2() |
| 17 | + { |
| 18 | + using (var effortConnection = GetEffortConnection()) |
| 19 | + { |
| 20 | + var response = await SubmitGet(effortConnection, "posts?page[number]=1&page[size]=2"); |
| 21 | + |
| 22 | + await AssertResponseContent(response, @"Fixtures\Pagination\GetAllResponsePaged-2-2.json", HttpStatusCode.OK); |
| 23 | + } |
| 24 | + } |
| 25 | + |
| 26 | + [TestMethod] |
| 27 | + [DeploymentItem(@"Data\Comment.csv", @"Data")] |
| 28 | + [DeploymentItem(@"Data\Post.csv", @"Data")] |
| 29 | + [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] |
| 30 | + [DeploymentItem(@"Data\Tag.csv", @"Data")] |
| 31 | + [DeploymentItem(@"Data\User.csv", @"Data")] |
| 32 | + public async Task GetWithFilter() |
| 33 | + { |
| 34 | + using (var effortConnection = GetEffortConnection()) |
| 35 | + { |
| 36 | + var response = await SubmitGet(effortConnection, "users?filter[last-name]=Burns&page[number]=1&page[size]=1"); |
| 37 | + |
| 38 | + await AssertResponseContent(response, @"Fixtures\Pagination\GetFilterPaged-2-1.json", HttpStatusCode.OK); |
| 39 | + } |
| 40 | + } |
| 41 | + |
| 42 | + |
| 43 | + [TestMethod] |
| 44 | + [DeploymentItem(@"Data\Comment.csv", @"Data")] |
| 45 | + [DeploymentItem(@"Data\Post.csv", @"Data")] |
| 46 | + [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] |
| 47 | + [DeploymentItem(@"Data\Tag.csv", @"Data")] |
| 48 | + [DeploymentItem(@"Data\User.csv", @"Data")] |
| 49 | + public async Task GetWithFilterSortedAscTest() |
| 50 | + { |
| 51 | + using (var effortConnection = GetEffortConnection()) |
| 52 | + { |
| 53 | + var response = await SubmitGet(effortConnection, "users?filter[last-name]=Burns&page[number]=0&page[size]=2&sort=first-name"); |
| 54 | + |
| 55 | + await AssertResponseContent(response, @"Fixtures\Pagination\GetFilterPaged-1-2-sorted.json", HttpStatusCode.OK); |
| 56 | + } |
| 57 | + } |
| 58 | + |
| 59 | + |
| 60 | + [TestMethod] |
| 61 | + [DeploymentItem(@"Data\Comment.csv", @"Data")] |
| 62 | + [DeploymentItem(@"Data\Post.csv", @"Data")] |
| 63 | + [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] |
| 64 | + [DeploymentItem(@"Data\Tag.csv", @"Data")] |
| 65 | + [DeploymentItem(@"Data\User.csv", @"Data")] |
| 66 | + public async Task GetWithFilterSortedDescTest() |
| 67 | + { |
| 68 | + using (var effortConnection = GetEffortConnection()) |
| 69 | + { |
| 70 | + var response = await SubmitGet(effortConnection, "users?filter[last-name]=Burns&page[number]=0&page[size]=2&sort=-first-name"); |
| 71 | + |
| 72 | + await AssertResponseContent(response, @"Fixtures\Pagination\GetFilterPaged-1-2-sorted-desc.json", HttpStatusCode.OK); |
| 73 | + } |
| 74 | + } |
| 75 | + |
| 76 | + } |
| 77 | +} |
0 commit comments