Skip to content

Commit

Permalink
Add unit/integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hnrkndrssn committed Aug 7, 2017
1 parent 96ea359 commit fb85a3c
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Octokit.Tests.Integration/Clients/TeamsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,27 @@ public async Task CanAddRepository()
}
}
}

public class TheGetAllPendingInvitesMethod
{
private readonly IGitHubClient _gitHub;

public TheGetAllPendingInvitesMethod()
{
_gitHub = Helper.GetAuthenticatedClient();
}

[OrganizationTest]
public async Task ReturnsNoPendingInvites()
{
using (var teamContext = await _gitHub.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team"))))
{
var team = teamContext.Team;

var pendingInvites = await _gitHub.Organization.Team.GetAllPendingInvitations(team.Id);
Assert.NotNull(pendingInvites);
Assert.Empty(pendingInvites);
}
}
}
}
23 changes: 23 additions & 0 deletions Octokit.Tests.Integration/Reactive/ObservableTeamsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,27 @@ public async Task GetsAllRepositories()
}
}
}

public class TheGetAllPendingInvitationsMethod
{
private readonly IGitHubClient _gitHub;
private readonly Team _team;

public TheGetAllPendingInvitationsMethod()
{
_gitHub = Helper.GetAuthenticatedClient();
_team = _gitHub.Organization.Team.GetAll(Helper.Organization).Result.First();
}

[OrganizationTest]
public async Task ReturnsNoPendingInvites()
{
var client = new ObservableTeamsClient(_gitHub);
var observable = client.GetAllPendingInvitations(_team.Id);
var pendingInvitations = await observable.ToList();

Assert.NotNull(pendingInvitations);
Assert.Empty(pendingInvitations);
}
}
}
17 changes: 17 additions & 0 deletions Octokit.Tests/Clients/TeamsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -344,5 +344,22 @@ public async Task EnsuresNonNullOrEmptyArguments()
await Assert.ThrowsAsync<ArgumentException>(() => client.IsRepositoryManagedByTeam(1, "ownerName", ""));
}
}

public class TheGetAllPendingInvitesMethod
{
[Fact]
public async Task RequestsTheCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new TeamsClient(connection);

await client.GetAllPendingInvitations(1);

connection.Received().GetAll<OrganizationMembershipInvite>(
Arg.Is<Uri>(u => u.ToString() == "teams/1/invitations"),
null,
"application/vnd.github.korra-preview+json");
}
}
}
}
18 changes: 18 additions & 0 deletions Octokit.Tests/Reactive/ObservableTeamsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Threading.Tasks;
using NSubstitute;
using Octokit.Reactive;
using Octokit.Reactive.Internal;
using Xunit;

namespace Octokit.Tests.Reactive
Expand Down Expand Up @@ -43,5 +44,22 @@ public void EnsuresNonNullArguments()
Assert.Throws<ArgumentNullException>(() => new ObservableTeamsClient(null));
}
}

public class TheGetAllPendingInvitationsMethod
{
[Fact]
public void RequestsTheCorrectUrl()
{
var gitHub = Substitute.For<IGitHubClient>();
var client = new ObservableTeamsClient(gitHub);

client.GetAllPendingInvitations(1);

gitHub.Connection.Received().GetAndFlattenAllPages<OrganizationMembershipInvite>(
Arg.Is<Uri>(u => u.ToString() == "teams/1/invitations"),
null,
"application/vnd.github.korra-preview+json");
}
}
}
}

0 comments on commit fb85a3c

Please sign in to comment.