mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-05 11:40:42 +00:00
Tests added.
This commit is contained in:
@@ -48,7 +48,7 @@ public class TeamsClientTests
|
||||
public class TheGetAllForCurrentMethod
|
||||
{
|
||||
[IntegrationTest]
|
||||
public async Task GetsIsMemberWhenAuthenticated()
|
||||
public async Task GetsAllForCurrentWhenAuthenticated()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var teams = await github.Organization.Team.GetAllForCurrent();
|
||||
|
||||
@@ -10,13 +10,13 @@ public class ObservableTeamsClientTests
|
||||
{
|
||||
public class TheGetMembersMethod
|
||||
{
|
||||
readonly Team team;
|
||||
readonly Team _team;
|
||||
|
||||
public TheGetMembersMethod()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
|
||||
team = github.Organization.Team.GetAll(Helper.Organization).Result.First();
|
||||
_team = github.Organization.Team.GetAll(Helper.Organization).Result.First();
|
||||
}
|
||||
|
||||
[OrganizationTest]
|
||||
@@ -26,7 +26,7 @@ public class ObservableTeamsClientTests
|
||||
|
||||
var client = new ObservableTeamsClient(github);
|
||||
|
||||
var member = await client.GetAllMembers(team.Id, ApiOptions.None);
|
||||
var member = await client.GetAllMembers(_team.Id, ApiOptions.None);
|
||||
|
||||
Assert.Equal(Helper.UserName, member.Login);
|
||||
}
|
||||
|
||||
@@ -218,6 +218,7 @@
|
||||
<Compile Include="Reactive\ObservableGistsTests.cs" />
|
||||
<Compile Include="Reactive\ObservableStarredClientTests.cs" />
|
||||
<Compile Include="Reactive\ObservableStatisticsClientTests.cs" />
|
||||
<Compile Include="Reactive\ObservableTeamsClientTests.cs" />
|
||||
<Compile Include="Reactive\ObservableTreesClientTests.cs" />
|
||||
<Compile Include="Reactive\ObservableFollowersTest.cs" />
|
||||
<Compile Include="Reactive\ObservableUserKeysClientTests.cs" />
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using NSubstitute;
|
||||
using Octokit.Reactive;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Reactive
|
||||
{
|
||||
public class ObservableTeamsClientTests
|
||||
{
|
||||
public class TheCreateMethod
|
||||
{
|
||||
[Fact]
|
||||
public void PostsToCorrectUrl()
|
||||
{
|
||||
var team = new NewTeam("avengers");
|
||||
var github = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableTeamsClient(github);
|
||||
|
||||
client.Create("shield", team);
|
||||
|
||||
github.Organization.Team.Received().Create("shield", team);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnsuresNotNullAndNonEmptyArguments()
|
||||
{
|
||||
var github = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableTeamsClient(github);
|
||||
|
||||
Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("shield", null).ToTask());
|
||||
Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(null, new NewTeam("avengers")).ToTask());
|
||||
Assert.ThrowsAsync<ArgumentException>(() => client.Create("", new NewTeam("avengers")).ToTask());
|
||||
}
|
||||
}
|
||||
|
||||
public class TheCtor
|
||||
{
|
||||
[Fact]
|
||||
public void EnsuresNotNullGitHubClient()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => new ObservableTeamsClient(null));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user