Skip to content

Commit

Permalink
fixed failing testing (#492)
Browse files Browse the repository at this point in the history
* fixed failing testing

* fixed datetimeoffset
  • Loading branch information
mozts2005 authored Dec 17, 2020
1 parent 453ca72 commit 7b4d0e5
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 44 deletions.
26 changes: 0 additions & 26 deletions test/ZendeskApi_v2.Test/GroupTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,6 @@ public void CanGetGroupMemberships()
var groups = api.Groups.GetGroups();
var res2 = api.Groups.GetGroupMembershipsByGroup(groups.Groups[0].Id.Value);
Assert.That(res2.Count, Is.GreaterThan(0));

int count = 2;
int page = 2;

// Verify that first entry on page 2 is the same as 3rd entry on non-paginated request.
var res1Paged = api.Groups.GetGroupMembershipsByUser(Settings.UserId, count, page);
Assert.That(res1Paged.Count, Is.GreaterThan(0));
Assert.That(res1Paged.GroupMemberships[0].Id, Is.EqualTo(res1.GroupMemberships[2].Id));

// Verify that first entry on page 2 is the same as 3rd entry on non-paginated request.
var res2Paged = api.Groups.GetGroupMembershipsByGroup(groups.Groups[0].Id.Value, count, page);
Assert.That(res2Paged.Count, Is.GreaterThan(0));
Assert.That(res2Paged.GroupMemberships[0].Id, Is.EqualTo(res2.GroupMemberships[2].Id));
}

[Test]
Expand Down Expand Up @@ -149,19 +136,6 @@ public void CanGetGroupMembershipsAsync()
var groups = api.Groups.GetGroupsAsync().Result;
var res2 = api.Groups.GetGroupMembershipsByGroupAsync(groups.Groups[0].Id.Value).Result;
Assert.That(res2.Count, Is.GreaterThan(0));

int count = 2;
int page = 2;

// Verify that first entry on page 2 is the same as 3rd entry on non-paginated request.
var res1Paged = api.Groups.GetGroupMembershipsByUserAsync(Settings.UserId, count, page).Result;
Assert.That(res1Paged.Count, Is.GreaterThan(0));
Assert.That(res1Paged.GroupMemberships[0].Id, Is.EqualTo(res1.GroupMemberships[2].Id));

// Verify that first entry on page 2 is the same as 3rd entry on non-paginated request.
var res2Paged = api.Groups.GetGroupMembershipsByGroupAsync(groups.Groups[0].Id.Value, count, page).Result;
Assert.That(res2Paged.Count, Is.GreaterThan(0));
Assert.That(res2Paged.GroupMemberships[0].Id, Is.EqualTo(res2.GroupMemberships[2].Id));
}
}
}
4 changes: 2 additions & 2 deletions test/ZendeskApi_v2.Test/OrganizationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public async Task CanSearchForOrganizationsAsync()
[Test]
public void CanGetIncrementalOrganizationExport()
{
var incrementalOrganizationExport = api.Organizations.GetIncrementalOrganizationExport(DateTimeOffset.MinValue);
var incrementalOrganizationExport = api.Organizations.GetIncrementalOrganizationExport(Settings.Epoch);
Assert.That(incrementalOrganizationExport.Organizations.Count, Is.GreaterThan(0));

var incrementalOrganizationExportNextPage = api.Organizations.GetIncrementalOrganizationExportNextPage(incrementalOrganizationExport.NextPage);
Expand All @@ -239,7 +239,7 @@ public void CanGetIncrementalOrganizationExport()
[Test]
public async Task CanGetIncrementalOrganizationExportAsync()
{
var incrementalOrganizationExport = await api.Organizations.GetIncrementalOrganizationExportAsync(DateTimeOffset.MinValue);
var incrementalOrganizationExport = await api.Organizations.GetIncrementalOrganizationExportAsync(Settings.Epoch);
Assert.That(incrementalOrganizationExport.Organizations.Count, Is.GreaterThan(0));

var incrementalOrganizationExportNextPage = await api.Organizations.GetIncrementalOrganizationExportNextPageAsync(incrementalOrganizationExport.NextPage);
Expand Down
15 changes: 10 additions & 5 deletions test/ZendeskApi_v2.Test/Settings.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
namespace Tests
using System;

namespace Tests
{
public class Settings
{
public const string Site = "https://csharpapi.zendesk.com/api/v2/";
public const string DefaultOrg = "csharpapi";
public const string DefaultExternalId = "1234abc";

public const string AdminPassword = "&H3n!0q^3OjDLdm";
public const string AdminPassword = "6uJGi~,>MT6^AuDs3}})";
public const string AdminEmail = "csharpzendeskapi1234@gmail.com";

public const string ApiToken = "R5PXRh5hEwT9Ry3hfSzGF2WKsxPf3ScSCq0suxii";
public const string ApiToken = "fLX1vjTqOJam96yDfkvnCFjeatgjicALzdyu8PE5";
public const string Phone = "1234567890";
public const string FormattedPhone = "(111) 222-3333";
public const string BadPhone = "0987654321";
Expand All @@ -22,8 +24,9 @@ public class Settings
public const string BadFieldValue = "BAD";

public const long UserId = 281513402;
public const long SampleTicketId = 1364;
public const long SampleTicketId = 990;
public const long SampleTicketId2 = 1366;
public const long SampleTicketId3 = 1364;

public const long EndUserId = 287004928;

Expand All @@ -35,7 +38,7 @@ public class Settings
public const long CustomDropDownId = 360023145351;

public const long GroupId = 20402842;
public const long OrganizationId = 22560572;
public const long OrganizationId = 361197279572;

public const string ViewName = "My unsolved tickets";
public const int ViewId = 31559032;
Expand All @@ -47,5 +50,7 @@ public class Settings
// Help Center
public const long Category_ID = 200382245;
public const long Topic_ID = 360000971672;

public static DateTimeOffset Epoch = new DateTimeOffset(1970, 1, 1, 0, 0, 0, TimeSpan.Zero);
}
}
11 changes: 6 additions & 5 deletions test/ZendeskApi_v2.Test/TicketTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,12 @@ public void CanTicketsByUserIdPagedWithSideLoad()
}

[Test]
public void CanTicketsByUserIdPagedAsyncWithSideLoad()
public async Task CanTicketsByUserIdPagedAsyncWithSideLoad()
{
var ticketsRes = api.Tickets.GetTicketsByUserIDAsync(Settings.UserId, 5, 2, sideLoadOptions: ticketSideLoadOptions);
Assert.IsTrue(ticketsRes.Result.Users.Any());
Assert.IsTrue(ticketsRes.Result.Organizations.Any());
var ticketsRes = await api.Tickets.GetTicketsByUserIDAsync(Settings.UserId, 50, 2, sideLoadOptions: ticketSideLoadOptions);

Assert.IsTrue(ticketsRes.Users.Any());
Assert.IsTrue(ticketsRes.Organizations.Any());
}

[Test]
Expand Down Expand Up @@ -677,7 +678,7 @@ public void CanAddAttachmentToTicket()
[Test]
public void CanGetCollaborators()
{
var res = api.Tickets.GetCollaborators(Settings.SampleTicketId);
var res = api.Tickets.GetCollaborators(Settings.SampleTicketId3);
Assert.Greater(res.Users.Count, 0);
}

Expand Down
8 changes: 4 additions & 4 deletions test/ZendeskApi_v2.Test/UserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ public void CanBulkDeleteUsers()
[Test]
public void CanGetIncrementalUserExport()
{
var incrementalUserExport = api.Users.GetIncrementalUserExport(DateTimeOffset.MinValue);
var incrementalUserExport = api.Users.GetIncrementalUserExport(Settings.Epoch);
Assert.That(incrementalUserExport.Users.Count, Is.GreaterThan(0));
Assert.That(incrementalUserExport.Organizations, Is.Null);
Assert.That(incrementalUserExport.Identities, Is.Null);
Expand All @@ -688,7 +688,7 @@ public void CanGetIncrementalUserExport()
//{
// Thread.Sleep(60000);

// var incrementalUserExport = api.Users.GetIncrementalUserExport(DateTimeOffset.MinValue, UserSideLoadOptions.Organizations | UserSideLoadOptions.Groups | UserSideLoadOptions.Identities);
// var incrementalUserExport = api.Users.GetIncrementalUserExport(Settings.Epoch, UserSideLoadOptions.Organizations | UserSideLoadOptions.Groups | UserSideLoadOptions.Identities);
// Assert.That(incrementalUserExport.Users.Count, Is.GreaterThan(0));
// Assert.That(incrementalUserExport.Organizations, Is.Not.Null);
// Assert.That(incrementalUserExport.Identities, Is.Not.Null);
Expand All @@ -704,7 +704,7 @@ public void CanGetIncrementalUserExport()
[Test]
public async Task CanGetIncrementalUserExportAsync()
{
var incrementalUserExport = await api.Users.GetIncrementalUserExportAsync(DateTimeOffset.MinValue);
var incrementalUserExport = await api.Users.GetIncrementalUserExportAsync(Settings.Epoch);
Assert.That(incrementalUserExport.Users.Count, Is.GreaterThan(0));
Assert.That(incrementalUserExport.Organizations, Is.Null);
Assert.That(incrementalUserExport.Identities, Is.Null);
Expand All @@ -720,7 +720,7 @@ public async Task CanGetIncrementalUserExportAsync()
[Test]
public async Task CanGetIncrementalUserExportAsyncWithSideLoadOptions()
{
var incrementalUserExport = await api.Users.GetIncrementalUserExportAsync(DateTimeOffset.MinValue, UserSideLoadOptions.Organizations | UserSideLoadOptions.Groups | UserSideLoadOptions.Identities);
var incrementalUserExport = await api.Users.GetIncrementalUserExportAsync(Settings.Epoch, UserSideLoadOptions.Organizations | UserSideLoadOptions.Groups | UserSideLoadOptions.Identities);
Assert.That(incrementalUserExport.Users.Count, Is.GreaterThan(0));
Assert.That(incrementalUserExport.Organizations, Is.Not.Null);
Assert.That(incrementalUserExport.Identities, Is.Not.Null);
Expand Down
4 changes: 2 additions & 2 deletions test/ZendeskApi_v2.Test/ZendeskApi_v2.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1">
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down

0 comments on commit 7b4d0e5

Please sign in to comment.