Files
octokit.net/Octokit.Tests/Reactive/ObservableOrganizationsClientTests.cs
Ryan Gribble 600c8657e4 Remove method/members previously deprecated (#1780)
* removes obsolete OranizationsClient.GetAll (replaced with GetAllForUser)

* removes obsolete PullRequestsClient.Comment (replaced with ReviewComment)

* removes obsolete TeamsClient.GetMembership (replaced with GetMembershipDetails)
removes obsolete TeamsClient.AddMembership (replaced with AddOrEditMembership)
removes obsolete TeamsClient.AddMembership (replaced with AddOrEditMembership)
removes obsolete TeamMembership response class (replaced with TeamMembershipDetails)

* removes obsolete RepositoryBranchesClient.GetRequiredStatusChecksContexts (replaced with GetAllRequiredStatusChecksContexts)
removes obsolete RepositoryBranchesClient.GetProtectedBranchTeamRestrictions (replaced with GetAllProtectedBranchTeamRestrictions)
removes obsolete RepositoryBranchesClient.GetProtectedBranchUserRestrictions (replaced with GetAllProtectedBranchUserRestrictions)

* removes obsolete RepositoryTrafficClient.GetReferrers (replaced with GetAllReferrers)
removes obsolete RepositoryTrafficClient.GetPaths (replaced with GetAllPaths)

* removes obsolete constructors from BranchProtectionUpdateSettings and UpdateTeam request models

* removes obsolete Assignee property from NewIssue and IssueUpdate request models (replaced with Assignees)
2018-04-22 09:58:06 +10:00

157 lines
5.2 KiB
C#

using System;
using NSubstitute;
using Octokit.Reactive;
using Xunit;
namespace Octokit.Tests.Reactive
{
public class ObservableOrganizationsClientTests
{
public class TheCtor
{
[Fact]
public void EnsuresNonNullArguments()
{
Assert.Throws<ArgumentNullException>(() => new ObservableOrganizationsClient(null));
}
}
public class TheGetMethod
{
[Fact]
public void RequestsCorrectUrl()
{
var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservableOrganizationsClient(gitHubClient);
client.Get("orgName");
gitHubClient.Received().Organization.Get("orgName");
}
[Fact]
public void EnsuresNonNullArguments()
{
var client = new ObservableOrganizationsClient(Substitute.For<IGitHubClient>());
Assert.Throws<ArgumentNullException>(() => client.Get(null));
Assert.Throws<ArgumentException>(() => client.Get(""));
}
}
public class TheGetAllForUserMethod
{
[Fact]
public void RequestsTheCorrectUrl()
{
var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservableOrganizationsClient(gitHubClient);
client.GetAllForUser("username");
gitHubClient.Received().Organization.GetAllForUser("username");
}
[Fact]
public void RequestsTheCorrectUrlWithApiOptions()
{
var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservableOrganizationsClient(gitHubClient);
var options = new ApiOptions
{
StartPage = 1,
PageCount = 1,
PageSize = 1
};
client.GetAllForUser("username", options);
gitHubClient.Received().Organization.GetAllForUser("username", options);
}
[Fact]
public void EnsuresNonNullArguments()
{
var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservableOrganizationsClient(gitHubClient);
Assert.Throws<ArgumentNullException>(() => client.GetAllForUser((string)null));
Assert.Throws<ArgumentNullException>(() => client.GetAllForUser(null, ApiOptions.None));
Assert.Throws<ArgumentNullException>(() => client.GetAllForUser("username", null));
Assert.Throws<ArgumentException>(() => client.GetAllForUser(""));
Assert.Throws<ArgumentException>(() => client.GetAllForUser("", ApiOptions.None));
}
}
public class TheGetAllForCurrentMethod
{
[Fact]
public void RequestsTheCorrectUrl()
{
var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservableOrganizationsClient(gitHubClient);
client.GetAllForCurrent();
gitHubClient.Received().Organization.GetAllForCurrent();
}
[Fact]
public void RequestsTheCorrectUrlWithApiOptions()
{
var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservableOrganizationsClient(gitHubClient);
var options = new ApiOptions
{
StartPage = 1,
PageCount = 1,
PageSize = 1
};
client.GetAllForCurrent(options);
gitHubClient.Received().Organization.GetAllForCurrent(options);
}
[Fact]
public void EnsuresNonNullArguments()
{
var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservableOrganizationsClient(gitHubClient);
Assert.Throws<ArgumentNullException>(() => client.GetAllForCurrent(null));
}
}
public class TheUpdateMethod
{
[Fact]
public void RequestsTheCorrectUrl()
{
var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservableOrganizationsClient(gitHubClient);
var organizationUpdate = new OrganizationUpdate();
client.Update("initrode", organizationUpdate);
gitHubClient.Received().Organization.Update("initrode", organizationUpdate);
}
[Fact]
public void EnsuresNonNullArguments()
{
var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservableOrganizationsClient(gitHubClient);
Assert.Throws<ArgumentNullException>(() => client.Update(null, new OrganizationUpdate()));
Assert.Throws<ArgumentNullException>(() => client.Update("org", null));
Assert.Throws<ArgumentException>(() => client.Update("", new OrganizationUpdate()));
}
}
}
}