Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TagsResourceTest Test #321

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Xunit;
Expand All @@ -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<Ticket> CreateTicketWithTagsAsync(IZendeskClient client)
{
var ticketResponse = await client.Tickets.CreateAsync(new Requests.TicketCreateRequest {
Tags = new List<string> { "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);
}
}
}