diff --git a/test/ZendeskApi.Client.IntegrationTests/Resources/TagsResourceTests.cs b/test/ZendeskApi.Client.IntegrationTests/Resources/TagsResourceTests.cs index 4d653aa8..9bf49c70 100644 --- a/test/ZendeskApi.Client.IntegrationTests/Resources/TagsResourceTests.cs +++ b/test/ZendeskApi.Client.IntegrationTests/Resources/TagsResourceTests.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Xunit; @@ -21,24 +22,49 @@ public TagsResourceTest( public async Task GetAllAsync_WhenCalledWithCursorPagination_ShouldBePaginatable() { var client = _clientFactory.GetClient(); + Ticket ticket = await CreateTicketWithTagsAsync(client); - var cursorPager = new CursorPager { Size = 5 }; - var tagsPageOne = await client - .Tags.GetAllAsync(cursorPager); + try + { + var cursorPager = new CursorPager { Size = 2 }; + var tagsPageOne = await client + .Tags.GetAllAsync(cursorPager); - Assert.NotNull(tagsPageOne); - Assert.Equal(5, tagsPageOne.Count()); - Assert.True(tagsPageOne.Meta.HasMore); + Assert.NotNull(tagsPageOne); + Assert.Equal(2, tagsPageOne.Count()); + Assert.True(tagsPageOne.Meta.HasMore); - cursorPager.AfterCursor = tagsPageOne.Meta.AfterCursor; + cursorPager.AfterCursor = tagsPageOne.Meta.AfterCursor; - var tagsPageTwo = await client.Tags.GetAllAsync(cursorPager); - Assert.NotNull(tagsPageTwo); - Assert.Equal(5, tagsPageTwo.Count()); + var tagsPageTwo = await client.Tags.GetAllAsync(cursorPager); + Assert.NotNull(tagsPageTwo); + Assert.Equal(2, tagsPageTwo.Count()); - var tagIdsPageOne = tagsPageOne.Select(tag => tag.Name).ToList(); - var tagIdsPageTwo = tagsPageTwo.Select(tag => tag.Name).ToList(); - Assert.NotEqual(tagIdsPageOne, tagIdsPageTwo); + var tagIdsPageOne = tagsPageOne.Select(tag => tag.Name).ToList(); + var tagIdsPageTwo = tagsPageTwo.Select(tag => tag.Name).ToList(); + Assert.NotEqual(tagIdsPageOne, tagIdsPageTwo); + } + finally + { + await CleanupTicketAsync(client, ticket); + } + + } + + private async Task CreateTicketWithTagsAsync(IZendeskClient client) + { + var ticketResponse = await client.Tickets.CreateAsync(new Requests.TicketCreateRequest { + Tags = new List { "apac", "shipping", "sales", "important", "sla" }, + Comment = new TicketComment { Body = "This is a ticket with 5 of tags" }, + Subject = "Test ticket" + } + ); + return ticketResponse.Ticket; + } + + private async Task CleanupTicketAsync(IZendeskClient client, Ticket ticket) + { + await client.Tickets.DeleteAsync(ticket.Id); } } } \ No newline at end of file