using System; using System.Collections.Generic; using System.Reactive.Linq; using System.Threading.Tasks; using NSubstitute; using Octokit.Internal; using Octokit.Reactive; using Xunit; namespace Octokit.Tests.Reactive { public class ObservableRepositoryBranchesClientTests { public class TheCtor { [Fact] public void EnsuresNonNullArguments() { Assert.Throws( () => new ObservableRepositoryBranchesClient(null)); } } public class TheGetAllMethod { [Fact] public void RequestsTheCorrectUrl() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); var expected = new Uri("repos/owner/repo/branches", UriKind.Relative); client.GetAll("owner", "repo"); gitHubClient.Connection.Received(1).Get>(expected, Args.EmptyDictionary); } [Fact] public void RequestsTheCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); var expected = new Uri("repositories/1/branches", UriKind.Relative); client.GetAll(1); gitHubClient.Connection.Received(1).Get>(expected, Args.EmptyDictionary); } [Fact] public void RequestsTheCorrectUrlWithApiOptions() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); var expected = new Uri("repos/owner/name/branches", UriKind.Relative); var options = new ApiOptions { PageCount = 1, StartPage = 1, PageSize = 1 }; client.GetAll("owner", "name", options); gitHubClient.Connection.Received(1).Get>(expected, Arg.Is>(d => d.Count == 2 && d["page"] == "1" && d["per_page"] == "1")); } [Fact] public void RequestsTheCorrectUrlWithRepositoryIdWithApiOptions() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); var expected = new Uri("repositories/1/branches", UriKind.Relative); var options = new ApiOptions { PageCount = 1, StartPage = 1, PageSize = 1 }; client.GetAll(1, options); gitHubClient.Connection.Received(1).Get>(expected, Arg.Is>(d => d.Count == 2 && d["page"] == "1" && d["per_page"] == "1")); } [Fact] public void EnsuresNonNullArguments() { var client = new ObservableRepositoryBranchesClient(Substitute.For()); Assert.Throws(() => client.GetAll(null, "name")); Assert.Throws(() => client.GetAll("owner", null)); Assert.Throws(() => client.GetAll(null, "name", ApiOptions.None)); Assert.Throws(() => client.GetAll("owner", null, ApiOptions.None)); Assert.Throws(() => client.GetAll("owner", "name", null)); Assert.Throws(() => client.GetAll(1, null)); Assert.Throws(() => client.GetAll("", "name")); Assert.Throws(() => client.GetAll("owner", "")); Assert.Throws(() => client.GetAll("", "name", ApiOptions.None)); Assert.Throws(() => client.GetAll("owner", "", ApiOptions.None)); } } public class TheGetMethod { [Fact] public void RequestsTheCorrectUrl() { var github = Substitute.For(); var client = new ObservableRepositoryBranchesClient(github); client.Get("owner", "repo", "branch"); github.Repository.Branch.Received(1).Get("owner", "repo", "branch"); } [Fact] public void RequestsTheCorrectUrlWithRepositoryId() { var github = Substitute.For(); var client = new ObservableRepositoryBranchesClient(github); client.Get(1, "branch"); github.Repository.Branch.Received(1).Get(1, "branch"); } [Fact] public async Task EnsuresNonNullArguments() { var client = new ObservableRepositoryBranchesClient(Substitute.For()); Assert.Throws(() => client.Get(null, "repo", "branch")); Assert.Throws(() => client.Get("owner", null, "branch")); Assert.Throws(() => client.Get("owner", "repo", null)); Assert.Throws(() => client.Get(1, null)); Assert.Throws(() => client.Get("", "repo", "branch")); Assert.Throws(() => client.Get("owner", "", "branch")); Assert.Throws(() => client.Get("owner", "repo", "")); Assert.Throws(() => client.Get(1, "")); } } public class TheGetBranchProtectectionMethod { [Fact] public void RequestsTheCorrectUrl() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); client.GetBranchProtection("owner", "repo", "branch"); gitHubClient.Repository.Branch.Received() .GetBranchProtection("owner", "repo", "branch"); } [Fact] public void RequestsTheCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); client.GetBranchProtection(1, "branch"); gitHubClient.Repository.Branch.Received() .GetBranchProtection(1, "branch"); } [Fact] public async Task EnsuresNonNullArguments() { var client = new ObservableRepositoryBranchesClient(Substitute.For()); Assert.Throws(() => client.GetBranchProtection(null, "repo", "branch")); Assert.Throws(() => client.GetBranchProtection("owner", null, "branch")); Assert.Throws(() => client.GetBranchProtection("owner", "repo", null)); Assert.Throws(() => client.GetBranchProtection(1, null)); Assert.Throws(() => client.GetBranchProtection("", "repo", "branch")); Assert.Throws(() => client.GetBranchProtection("owner", "", "branch")); Assert.Throws(() => client.GetBranchProtection("owner", "repo", "")); Assert.Throws(() => client.GetBranchProtection(1, "")); } } public class TheUpdateBranchProtectionMethod { [Fact] public void RequestsTheCorrectUrl() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); var update = new BranchProtectionSettingsUpdate(new BranchProtectionRequiredStatusChecksUpdate(true, new[] { "test" })); client.UpdateBranchProtection("owner", "repo", "branch", update); gitHubClient.Repository.Branch.Received() .UpdateBranchProtection("owner", "repo", "branch", update); } [Fact] public void RequestsTheCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); var update = new BranchProtectionSettingsUpdate(new BranchProtectionRequiredStatusChecksUpdate(true, new[] { "test" })); client.UpdateBranchProtection(1, "branch", update); gitHubClient.Repository.Branch.Received() .UpdateBranchProtection(1, "branch", update); } [Fact] public async Task EnsuresNonNullArguments() { var client = new ObservableRepositoryBranchesClient(Substitute.For()); var update = new BranchProtectionSettingsUpdate(new BranchProtectionRequiredStatusChecksUpdate(true, new[] { "test" })); Assert.Throws(() => client.UpdateBranchProtection(null, "repo", "branch", update)); Assert.Throws(() => client.UpdateBranchProtection("owner", null, "branch", update)); Assert.Throws(() => client.UpdateBranchProtection("owner", "repo", null, update)); Assert.Throws(() => client.UpdateBranchProtection("owner", "repo", "branch", null)); Assert.Throws(() => client.UpdateBranchProtection(1, null, update)); Assert.Throws(() => client.UpdateBranchProtection(1, "branch", null)); Assert.Throws(() => client.UpdateBranchProtection("", "repo", "branch", update)); Assert.Throws(() => client.UpdateBranchProtection("owner", "", "branch", update)); Assert.Throws(() => client.UpdateBranchProtection("owner", "repo", "", update)); Assert.Throws(() => client.UpdateBranchProtection(1, "", update)); } } public class TheDeleteBranchProtectectionMethod { [Fact] public void RequestsTheCorrectUrl() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); client.DeleteBranchProtection("owner", "repo", "branch"); gitHubClient.Repository.Branch.Received() .DeleteBranchProtection("owner", "repo", "branch"); } [Fact] public void RequestsTheCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); client.DeleteBranchProtection(1, "branch"); gitHubClient.Repository.Branch.Received() .DeleteBranchProtection(1, "branch"); } [Fact] public async Task EnsuresNonNullArguments() { var client = new ObservableRepositoryBranchesClient(Substitute.For()); Assert.Throws(() => client.DeleteBranchProtection(null, "repo", "branch")); Assert.Throws(() => client.DeleteBranchProtection("owner", null, "branch")); Assert.Throws(() => client.DeleteBranchProtection("owner", "repo", null)); Assert.Throws(() => client.DeleteBranchProtection(1, null)); Assert.Throws(() => client.DeleteBranchProtection("", "repo", "branch")); Assert.Throws(() => client.DeleteBranchProtection("owner", "", "branch")); Assert.Throws(() => client.DeleteBranchProtection("owner", "repo", "")); Assert.Throws(() => client.DeleteBranchProtection(1, "")); } } public class TheGetRequiredStatusChecksMethod { [Fact] public void RequestsTheCorrectUrl() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); client.GetRequiredStatusChecks("owner", "repo", "branch"); gitHubClient.Repository.Branch.Received() .GetRequiredStatusChecks("owner", "repo", "branch"); } [Fact] public void RequestsTheCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); client.GetRequiredStatusChecks(1, "branch"); gitHubClient.Repository.Branch.Received() .GetRequiredStatusChecks(1, "branch"); } [Fact] public async Task EnsuresNonNullArguments() { var client = new ObservableRepositoryBranchesClient(Substitute.For()); Assert.Throws(() => client.GetRequiredStatusChecks(null, "repo", "branch")); Assert.Throws(() => client.GetRequiredStatusChecks("owner", null, "branch")); Assert.Throws(() => client.GetRequiredStatusChecks("owner", "repo", null)); Assert.Throws(() => client.GetRequiredStatusChecks(1, null)); Assert.Throws(() => client.GetRequiredStatusChecks("", "repo", "branch")); Assert.Throws(() => client.GetRequiredStatusChecks("owner", "", "branch")); Assert.Throws(() => client.GetRequiredStatusChecks("owner", "repo", "")); Assert.Throws(() => client.GetRequiredStatusChecks(1, "")); } } public class TheUpdateRequiredStatusChecksMethod { [Fact] public void RequestsTheCorrectUrl() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); var update = new BranchProtectionRequiredStatusChecksUpdate(true, new[] { "test" }); client.UpdateRequiredStatusChecks("owner", "repo", "branch", update); gitHubClient.Repository.Branch.Received() .UpdateRequiredStatusChecks("owner", "repo", "branch", update); } [Fact] public void RequestsTheCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); var update = new BranchProtectionRequiredStatusChecksUpdate(true, new[] { "test" }); client.UpdateRequiredStatusChecks(1, "branch", update); gitHubClient.Repository.Branch.Received() .UpdateRequiredStatusChecks(1, "branch", update); } [Fact] public async Task EnsuresNonNullArguments() { var client = new ObservableRepositoryBranchesClient(Substitute.For()); var update = new BranchProtectionRequiredStatusChecksUpdate(true, new[] { "test" }); Assert.Throws(() => client.UpdateRequiredStatusChecks(null, "repo", "branch", update)); Assert.Throws(() => client.UpdateRequiredStatusChecks("owner", null, "branch", update)); Assert.Throws(() => client.UpdateRequiredStatusChecks("owner", "repo", null, update)); Assert.Throws(() => client.UpdateRequiredStatusChecks("owner", "repo", "branch", null)); Assert.Throws(() => client.UpdateRequiredStatusChecks(1, null, update)); Assert.Throws(() => client.UpdateRequiredStatusChecks(1, "branch", null)); Assert.Throws(() => client.UpdateRequiredStatusChecks("", "repo", "branch", update)); Assert.Throws(() => client.UpdateRequiredStatusChecks("owner", "", "branch", update)); Assert.Throws(() => client.UpdateRequiredStatusChecks("owner", "repo", "", update)); Assert.Throws(() => client.UpdateRequiredStatusChecks(1, "", update)); } } public class TheDeleteRequiredStatusChecksMethod { [Fact] public void RequestsTheCorrectUrl() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); client.DeleteRequiredStatusChecks("owner", "repo", "branch"); gitHubClient.Repository.Branch.Received() .DeleteRequiredStatusChecks("owner", "repo", "branch"); } [Fact] public void RequestsTheCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); client.DeleteRequiredStatusChecks(1, "branch"); gitHubClient.Repository.Branch.Received() .DeleteRequiredStatusChecks(1, "branch"); } [Fact] public async Task EnsuresNonNullArguments() { var client = new ObservableRepositoryBranchesClient(Substitute.For()); Assert.Throws(() => client.DeleteRequiredStatusChecks(null, "repo", "branch")); Assert.Throws(() => client.DeleteRequiredStatusChecks("owner", null, "branch")); Assert.Throws(() => client.DeleteRequiredStatusChecks("owner", "repo", null)); Assert.Throws(() => client.DeleteRequiredStatusChecks(1, null)); Assert.Throws(() => client.DeleteRequiredStatusChecks("", "repo", "branch")); Assert.Throws(() => client.DeleteRequiredStatusChecks("owner", "", "branch")); Assert.Throws(() => client.DeleteRequiredStatusChecks("owner", "repo", "")); Assert.Throws(() => client.DeleteRequiredStatusChecks(1, "")); } } public class TheGetAllRequiredStatusChecksContextsMethod { [Fact] public void RequestsTheCorrectUrl() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); client.GetAllRequiredStatusChecksContexts("owner", "repo", "branch"); gitHubClient.Repository.Branch.Received() .GetAllRequiredStatusChecksContexts("owner", "repo", "branch"); } [Fact] public void RequestsTheCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); client.GetAllRequiredStatusChecksContexts(1, "branch"); gitHubClient.Repository.Branch.Received() .GetAllRequiredStatusChecksContexts(1, "branch"); } [Fact] public async Task EnsuresNonNullArguments() { var client = new ObservableRepositoryBranchesClient(Substitute.For()); Assert.Throws(() => client.GetAllRequiredStatusChecksContexts(null, "repo", "branch")); Assert.Throws(() => client.GetAllRequiredStatusChecksContexts("owner", null, "branch")); Assert.Throws(() => client.GetAllRequiredStatusChecksContexts("owner", "repo", null)); Assert.Throws(() => client.GetAllRequiredStatusChecksContexts(1, null)); Assert.Throws(() => client.GetAllRequiredStatusChecksContexts("", "repo", "branch")); Assert.Throws(() => client.GetAllRequiredStatusChecksContexts("owner", "", "branch")); Assert.Throws(() => client.GetAllRequiredStatusChecksContexts("owner", "repo", "")); Assert.Throws(() => client.GetAllRequiredStatusChecksContexts(1, "")); } } public class TheUpdateRequiredStatusChecksContextsMethod { [Fact] public void RequestsTheCorrectUrl() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); var update = new List() { "test" }; client.UpdateRequiredStatusChecksContexts("owner", "repo", "branch", update); gitHubClient.Repository.Branch.Received() .UpdateRequiredStatusChecksContexts("owner", "repo", "branch", update); } [Fact] public void RequestsTheCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); var update = new List() { "test" }; client.UpdateRequiredStatusChecksContexts(1, "branch", update); gitHubClient.Repository.Branch.Received() .UpdateRequiredStatusChecksContexts(1, "branch", update); } [Fact] public async Task EnsuresNonNullArguments() { var client = new ObservableRepositoryBranchesClient(Substitute.For()); var update = new List() { "test" }; Assert.Throws(() => client.UpdateRequiredStatusChecksContexts(null, "repo", "branch", update)); Assert.Throws(() => client.UpdateRequiredStatusChecksContexts("owner", null, "branch", update)); Assert.Throws(() => client.UpdateRequiredStatusChecksContexts("owner", "repo", null, update)); Assert.Throws(() => client.UpdateRequiredStatusChecksContexts("owner", "repo", "branch", null)); Assert.Throws(() => client.UpdateRequiredStatusChecksContexts(1, null, update)); Assert.Throws(() => client.UpdateRequiredStatusChecksContexts(1, "branch", null)); Assert.Throws(() => client.UpdateRequiredStatusChecksContexts("", "repo", "branch", update)); Assert.Throws(() => client.UpdateRequiredStatusChecksContexts("owner", "", "branch", update)); Assert.Throws(() => client.UpdateRequiredStatusChecksContexts("owner", "repo", "", update)); Assert.Throws(() => client.UpdateRequiredStatusChecksContexts(1, "", update)); } } public class TheAddRequiredStatusChecksContextsMethod { [Fact] public void RequestsTheCorrectUrl() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); var newContexts = new List() { "test" }; client.AddRequiredStatusChecksContexts("owner", "repo", "branch", newContexts); gitHubClient.Repository.Branch.Received() .AddRequiredStatusChecksContexts("owner", "repo", "branch", newContexts); } [Fact] public void RequestsTheCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); var newContexts = new List() { "test" }; client.AddRequiredStatusChecksContexts(1, "branch", newContexts); gitHubClient.Repository.Branch.Received() .AddRequiredStatusChecksContexts(1, "branch", newContexts); } [Fact] public async Task EnsuresNonNullArguments() { var client = new ObservableRepositoryBranchesClient(Substitute.For()); var newContexts = new List() { "test" }; Assert.Throws(() => client.AddRequiredStatusChecksContexts(null, "repo", "branch", newContexts)); Assert.Throws(() => client.AddRequiredStatusChecksContexts("owner", null, "branch", newContexts)); Assert.Throws(() => client.AddRequiredStatusChecksContexts("owner", "repo", null, newContexts)); Assert.Throws(() => client.AddRequiredStatusChecksContexts("owner", "repo", "branch", null)); Assert.Throws(() => client.AddRequiredStatusChecksContexts(1, null, newContexts)); Assert.Throws(() => client.AddRequiredStatusChecksContexts(1, "branch", null)); Assert.Throws(() => client.AddRequiredStatusChecksContexts("", "repo", "branch", newContexts)); Assert.Throws(() => client.AddRequiredStatusChecksContexts("owner", "", "branch", newContexts)); Assert.Throws(() => client.AddRequiredStatusChecksContexts("owner", "repo", "", newContexts)); Assert.Throws(() => client.AddRequiredStatusChecksContexts(1, "", newContexts)); } } public class TheDeleteRequiredStatusChecksContextsMethod { [Fact] public void RequestsTheCorrectUrl() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); var contextsToRemove = new List() { "test" }; client.DeleteRequiredStatusChecksContexts("owner", "repo", "branch", contextsToRemove); gitHubClient.Repository.Branch.Received() .DeleteRequiredStatusChecksContexts("owner", "repo", "branch", contextsToRemove); } [Fact] public void RequestsTheCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); var contextsToRemove = new List() { "test" }; client.DeleteRequiredStatusChecksContexts(1, "branch", contextsToRemove); gitHubClient.Repository.Branch.Received() .DeleteRequiredStatusChecksContexts(1, "branch", contextsToRemove); } [Fact] public async Task EnsuresNonNullArguments() { var client = new ObservableRepositoryBranchesClient(Substitute.For()); var contextsToRemove = new List() { "test" }; Assert.Throws(() => client.DeleteRequiredStatusChecksContexts(null, "repo", "branch", contextsToRemove)); Assert.Throws(() => client.DeleteRequiredStatusChecksContexts("owner", null, "branch", contextsToRemove)); Assert.Throws(() => client.DeleteRequiredStatusChecksContexts("owner", "repo", null, contextsToRemove)); Assert.Throws(() => client.DeleteRequiredStatusChecksContexts("owner", "repo", "branch", null)); Assert.Throws(() => client.DeleteRequiredStatusChecksContexts(1, null, contextsToRemove)); Assert.Throws(() => client.DeleteRequiredStatusChecksContexts(1, "branch", null)); Assert.Throws(() => client.DeleteRequiredStatusChecksContexts("", "repo", "branch", contextsToRemove)); Assert.Throws(() => client.DeleteRequiredStatusChecksContexts("owner", "", "branch", contextsToRemove)); Assert.Throws(() => client.DeleteRequiredStatusChecksContexts("owner", "repo", "", contextsToRemove)); Assert.Throws(() => client.DeleteRequiredStatusChecksContexts(1, "", contextsToRemove)); } } public class TheGetReviewEnforcementMethod { [Fact] public void RequestsTheCorrectUrl() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); client.GetReviewEnforcement("owner", "repo", "branch"); gitHubClient.Repository.Branch.Received().GetReviewEnforcement("owner", "repo", "branch"); } [Fact] public void RequestsTheCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); client.GetReviewEnforcement(1, "branch"); gitHubClient.Repository.Branch.Received().GetReviewEnforcement(1, "branch"); } [Fact] public async Task EnsuresNonNullArguments() { var client = new ObservableRepositoryBranchesClient(Substitute.For()); Assert.Throws(() => client.GetReviewEnforcement(null, "repo", "branch")); Assert.Throws(() => client.GetReviewEnforcement("owner", null, "branch")); Assert.Throws(() => client.GetReviewEnforcement("owner", "repo", null)); Assert.Throws(() => client.GetReviewEnforcement(1, null)); Assert.Throws(() => client.GetReviewEnforcement("", "repo", "branch")); Assert.Throws(() => client.GetReviewEnforcement("owner", "", "branch")); Assert.Throws(() => client.GetReviewEnforcement("owner", "repo", "")); Assert.Throws(() => client.GetReviewEnforcement(1, "")); } } public class TheUpdateReviewEnforcement { [Fact] public void RequestsTheCorrectUrl() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); var update = new BranchProtectionRequiredReviewsUpdate(false, false, 2); client.UpdateReviewEnforcement("owner", "repo", "branch", update); gitHubClient.Repository.Branch.Received().UpdateReviewEnforcement("owner", "repo", "branch", update); } [Fact] public void RequestsTheCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); var update = new BranchProtectionRequiredReviewsUpdate(false, false, 2); client.UpdateReviewEnforcement(1, "branch", update); gitHubClient.Repository.Branch.Received().UpdateReviewEnforcement(1, "branch", update); } [Fact] public async Task EnsuresNonNullArguments() { var client = new ObservableRepositoryBranchesClient(Substitute.For()); var update = new BranchProtectionRequiredReviewsUpdate(false, false, 2); Assert.Throws(() => client.UpdateReviewEnforcement(null, "repo", "branch", update)); Assert.Throws(() => client.UpdateReviewEnforcement("owner", null, "branch", update)); Assert.Throws(() => client.UpdateReviewEnforcement("owner", "repo", null, update)); Assert.Throws(() => client.UpdateReviewEnforcement("owner", "repo", "branch", null)); Assert.Throws(() => client.UpdateReviewEnforcement(1, null, update)); Assert.Throws(() => client.UpdateReviewEnforcement(1, "branch", null)); Assert.Throws(() => client.UpdateReviewEnforcement("", "repo", "branch", update)); Assert.Throws(() => client.UpdateReviewEnforcement("owner", "", "branch", update)); Assert.Throws(() => client.UpdateReviewEnforcement("owner", "repo", "", update)); Assert.Throws(() => client.UpdateReviewEnforcement(1, "", update)); } } public class TheRemoveReviewEnforcement { [Fact] public void RequestsTheCorrectUrl() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); client.RemoveReviewEnforcement("owner", "repo", "branch"); gitHubClient.Repository.Branch.Received().RemoveReviewEnforcement("owner", "repo", "branch"); } [Fact] public void RequestsTheCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); client.RemoveReviewEnforcement(1, "branch"); gitHubClient.Repository.Branch.Received().RemoveReviewEnforcement(1, "branch"); } [Fact] public async Task EnsuresNonNullArguments() { var client = new ObservableRepositoryBranchesClient(Substitute.For()); Assert.Throws(() => client.RemoveReviewEnforcement(null, "repo", "branch")); Assert.Throws(() => client.RemoveReviewEnforcement("owner", null, "branch")); Assert.Throws(() => client.RemoveReviewEnforcement("owner", "repo", null)); Assert.Throws(() => client.RemoveReviewEnforcement(1, null)); Assert.Throws(() => client.RemoveReviewEnforcement("", "repo", "branch")); Assert.Throws(() => client.RemoveReviewEnforcement("owner", "", "branch")); Assert.Throws(() => client.RemoveReviewEnforcement("owner", "repo", "")); Assert.Throws(() => client.RemoveReviewEnforcement(1, "")); } } public class TheGetAdminEnforcementMethod { [Fact] public void RequestsTheCorrectUrl() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); client.GetAdminEnforcement("owner", "repo", "branch"); gitHubClient.Repository.Branch.Received().GetAdminEnforcement("owner", "repo", "branch"); } [Fact] public void RequestsTheCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); client.GetAdminEnforcement(1, "branch"); gitHubClient.Repository.Branch.Received().GetAdminEnforcement(1, "branch"); } [Fact] public async Task EnsuresNonNullArguments() { var client = new ObservableRepositoryBranchesClient(Substitute.For()); Assert.Throws(() => client.GetAdminEnforcement(null, "repo", "branch")); Assert.Throws(() => client.GetAdminEnforcement("owner", null, "branch")); Assert.Throws(() => client.GetAdminEnforcement("owner", "repo", null)); Assert.Throws(() => client.GetAdminEnforcement(1, null)); Assert.Throws(() => client.GetAdminEnforcement("", "repo", "branch")); Assert.Throws(() => client.GetAdminEnforcement("owner", "", "branch")); Assert.Throws(() => client.GetAdminEnforcement("owner", "repo", "")); Assert.Throws(() => client.GetAdminEnforcement(1, "")); } } public class TheAddAdminEnforcement { [Fact] public void RequestsTheCorrectUrl() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); client.AddAdminEnforcement("owner", "repo", "branch"); gitHubClient.Repository.Branch.Received().AddAdminEnforcement("owner", "repo", "branch"); } [Fact] public void RequestsTheCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); client.AddAdminEnforcement(1, "branch"); gitHubClient.Repository.Branch.Received().AddAdminEnforcement(1, "branch"); } [Fact] public async Task EnsuresNonNullArguments() { var client = new ObservableRepositoryBranchesClient(Substitute.For()); Assert.Throws(() => client.AddAdminEnforcement(null, "repo", "branch")); Assert.Throws(() => client.AddAdminEnforcement("owner", null, "branch")); Assert.Throws(() => client.AddAdminEnforcement("owner", "repo", null)); Assert.Throws(() => client.AddAdminEnforcement(1, null)); Assert.Throws(() => client.AddAdminEnforcement("", "repo", "branch")); Assert.Throws(() => client.AddAdminEnforcement("owner", "", "branch")); Assert.Throws(() => client.AddAdminEnforcement("owner", "repo", "")); Assert.Throws(() => client.AddAdminEnforcement(1, "")); } } public class TheRemoveAdminEnforcement { [Fact] public void RequestsTheCorrectUrl() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); client.RemoveAdminEnforcement("owner", "repo", "branch"); gitHubClient.Repository.Branch.Received().RemoveAdminEnforcement("owner", "repo", "branch"); } [Fact] public void RequestsTheCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); client.RemoveAdminEnforcement(1, "branch"); gitHubClient.Repository.Branch.Received().RemoveAdminEnforcement(1, "branch"); } [Fact] public async Task EnsuresNonNullArguments() { var client = new ObservableRepositoryBranchesClient(Substitute.For()); Assert.Throws(() => client.RemoveAdminEnforcement(null, "repo", "branch")); Assert.Throws(() => client.RemoveAdminEnforcement("owner", null, "branch")); Assert.Throws(() => client.RemoveAdminEnforcement("owner", "repo", null)); Assert.Throws(() => client.RemoveAdminEnforcement(1, null)); Assert.Throws(() => client.RemoveAdminEnforcement("", "repo", "branch")); Assert.Throws(() => client.RemoveAdminEnforcement("owner", "", "branch")); Assert.Throws(() => client.RemoveAdminEnforcement("owner", "repo", "")); Assert.Throws(() => client.RemoveAdminEnforcement(1, "")); } } public class TheGetProtectedBranchRestrictionsMethod { [Fact] public void RequestsTheCorrectUrl() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); client.GetProtectedBranchRestrictions("owner", "repo", "branch"); gitHubClient.Repository.Branch.Received() .GetProtectedBranchRestrictions("owner", "repo", "branch"); } [Fact] public void RequestsTheCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); client.GetProtectedBranchRestrictions(1, "branch"); gitHubClient.Repository.Branch.Received() .GetProtectedBranchRestrictions(1, "branch"); } [Fact] public async Task EnsuresNonNullArguments() { var client = new ObservableRepositoryBranchesClient(Substitute.For()); Assert.Throws(() => client.GetProtectedBranchRestrictions(null, "repo", "branch")); Assert.Throws(() => client.GetProtectedBranchRestrictions("owner", null, "branch")); Assert.Throws(() => client.GetProtectedBranchRestrictions("owner", "repo", null)); Assert.Throws(() => client.GetProtectedBranchRestrictions(1, null)); Assert.Throws(() => client.GetProtectedBranchRestrictions("", "repo", "branch")); Assert.Throws(() => client.GetProtectedBranchRestrictions("owner", "", "branch")); Assert.Throws(() => client.GetProtectedBranchRestrictions("owner", "repo", "")); Assert.Throws(() => client.GetProtectedBranchRestrictions(1, "")); } } public class TheDeleteProtectedBranchRestrictionsMethod { [Fact] public void RequestsTheCorrectUrl() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); client.DeleteProtectedBranchRestrictions("owner", "repo", "branch"); gitHubClient.Repository.Branch.Received() .DeleteProtectedBranchRestrictions("owner", "repo", "branch"); } [Fact] public void RequestsTheCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); client.DeleteProtectedBranchRestrictions(1, "branch"); gitHubClient.Repository.Branch.Received() .DeleteProtectedBranchRestrictions(1, "branch"); } [Fact] public async Task EnsuresNonNullArguments() { var client = new ObservableRepositoryBranchesClient(Substitute.For()); Assert.Throws(() => client.DeleteProtectedBranchRestrictions(null, "repo", "branch")); Assert.Throws(() => client.DeleteProtectedBranchRestrictions("owner", null, "branch")); Assert.Throws(() => client.DeleteProtectedBranchRestrictions("owner", "repo", null)); Assert.Throws(() => client.DeleteProtectedBranchRestrictions(1, null)); Assert.Throws(() => client.DeleteProtectedBranchRestrictions("", "repo", "branch")); Assert.Throws(() => client.DeleteProtectedBranchRestrictions("owner", "", "branch")); Assert.Throws(() => client.DeleteProtectedBranchRestrictions("owner", "repo", "")); Assert.Throws(() => client.DeleteProtectedBranchRestrictions(1, "")); } } public class TheGetAllProtectedBranchTeamRestrictionsMethod { [Fact] public void RequestsTheCorrectUrl() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); client.GetAllProtectedBranchTeamRestrictions("owner", "repo", "branch"); gitHubClient.Repository.Branch.Received() .GetAllProtectedBranchTeamRestrictions("owner", "repo", "branch"); } [Fact] public void RequestsTheCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); client.GetAllProtectedBranchTeamRestrictions(1, "branch"); gitHubClient.Repository.Branch.Received() .GetAllProtectedBranchTeamRestrictions(1, "branch"); } [Fact] public async Task EnsuresNonNullArguments() { var client = new ObservableRepositoryBranchesClient(Substitute.For()); Assert.Throws(() => client.GetAllProtectedBranchTeamRestrictions(null, "repo", "branch")); Assert.Throws(() => client.GetAllProtectedBranchTeamRestrictions("owner", null, "branch")); Assert.Throws(() => client.GetAllProtectedBranchTeamRestrictions("owner", "repo", null)); Assert.Throws(() => client.GetAllProtectedBranchTeamRestrictions(1, null)); Assert.Throws(() => client.GetAllProtectedBranchTeamRestrictions("", "repo", "branch")); Assert.Throws(() => client.GetAllProtectedBranchTeamRestrictions("owner", "", "branch")); Assert.Throws(() => client.GetAllProtectedBranchTeamRestrictions("owner", "repo", "")); Assert.Throws(() => client.GetAllProtectedBranchTeamRestrictions(1, "")); } } public class TheSetProtectedBranchTeamRestrictionsMethod { [Fact] public void RequestsTheCorrectUrl() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); var newTeams = new BranchProtectionTeamCollection() { "test" }; client.UpdateProtectedBranchTeamRestrictions("owner", "repo", "branch", newTeams); gitHubClient.Repository.Branch.Received() .UpdateProtectedBranchTeamRestrictions("owner", "repo", "branch", newTeams); } [Fact] public void RequestsTheCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); var newTeams = new BranchProtectionTeamCollection() { "test" }; client.UpdateProtectedBranchTeamRestrictions(1, "branch", newTeams); gitHubClient.Repository.Branch.Received() .UpdateProtectedBranchTeamRestrictions(1, "branch", newTeams); } [Fact] public async Task EnsuresNonNullArguments() { var client = new ObservableRepositoryBranchesClient(Substitute.For()); var newTeams = new BranchProtectionTeamCollection() { "test" }; Assert.Throws(() => client.UpdateProtectedBranchTeamRestrictions(null, "repo", "branch", newTeams)); Assert.Throws(() => client.UpdateProtectedBranchTeamRestrictions("owner", null, "branch", newTeams)); Assert.Throws(() => client.UpdateProtectedBranchTeamRestrictions("owner", "repo", null, newTeams)); Assert.Throws(() => client.UpdateProtectedBranchTeamRestrictions("owner", "repo", "branch", null)); Assert.Throws(() => client.UpdateProtectedBranchTeamRestrictions(1, null, newTeams)); Assert.Throws(() => client.UpdateProtectedBranchTeamRestrictions(1, "branch", null)); Assert.Throws(() => client.UpdateProtectedBranchTeamRestrictions("", "repo", "branch", newTeams)); Assert.Throws(() => client.UpdateProtectedBranchTeamRestrictions("owner", "", "branch", newTeams)); Assert.Throws(() => client.UpdateProtectedBranchTeamRestrictions("owner", "repo", "", newTeams)); Assert.Throws(() => client.UpdateProtectedBranchTeamRestrictions(1, "", newTeams)); } } public class TheAddProtectedBranchTeamRestrictionsMethod { [Fact] public void RequestsTheCorrectUrl() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); var newTeams = new BranchProtectionTeamCollection() { "test" }; client.AddProtectedBranchTeamRestrictions("owner", "repo", "branch", newTeams); gitHubClient.Repository.Branch.Received() .AddProtectedBranchTeamRestrictions("owner", "repo", "branch", newTeams); } [Fact] public void RequestsTheCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); var newTeams = new BranchProtectionTeamCollection() { "test" }; client.AddProtectedBranchTeamRestrictions(1, "branch", newTeams); gitHubClient.Repository.Branch.Received() .AddProtectedBranchTeamRestrictions(1, "branch", newTeams); } [Fact] public async Task EnsuresNonNullArguments() { var client = new ObservableRepositoryBranchesClient(Substitute.For()); var newTeams = new BranchProtectionTeamCollection() { "test" }; Assert.Throws(() => client.AddProtectedBranchTeamRestrictions(null, "repo", "branch", newTeams)); Assert.Throws(() => client.AddProtectedBranchTeamRestrictions("owner", null, "branch", newTeams)); Assert.Throws(() => client.AddProtectedBranchTeamRestrictions("owner", "repo", null, newTeams)); Assert.Throws(() => client.AddProtectedBranchTeamRestrictions("owner", "repo", "branch", null)); Assert.Throws(() => client.AddProtectedBranchTeamRestrictions(1, null, newTeams)); Assert.Throws(() => client.AddProtectedBranchTeamRestrictions(1, "branch", null)); Assert.Throws(() => client.AddProtectedBranchTeamRestrictions("", "repo", "branch", newTeams)); Assert.Throws(() => client.AddProtectedBranchTeamRestrictions("owner", "", "branch", newTeams)); Assert.Throws(() => client.AddProtectedBranchTeamRestrictions("owner", "repo", "", newTeams)); Assert.Throws(() => client.AddProtectedBranchTeamRestrictions(1, "", newTeams)); } } public class TheDeleteProtectedBranchTeamRestrictions { [Fact] public void RequestsTheCorrectUrl() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); var teamsToRemove = new BranchProtectionTeamCollection() { "test" }; client.DeleteProtectedBranchTeamRestrictions("owner", "repo", "branch", teamsToRemove); gitHubClient.Repository.Branch.Received() .DeleteProtectedBranchTeamRestrictions("owner", "repo", "branch", teamsToRemove); } [Fact] public void RequestsTheCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); var teamsToRemove = new BranchProtectionTeamCollection() { "test" }; client.DeleteProtectedBranchTeamRestrictions(1, "branch", teamsToRemove); gitHubClient.Repository.Branch.Received() .DeleteProtectedBranchTeamRestrictions(1, "branch", teamsToRemove); } [Fact] public async Task EnsuresNonNullArguments() { var client = new ObservableRepositoryBranchesClient(Substitute.For()); var teamsToRemove = new BranchProtectionTeamCollection() { "test" }; Assert.Throws(() => client.DeleteProtectedBranchTeamRestrictions(null, "repo", "branch", teamsToRemove)); Assert.Throws(() => client.DeleteProtectedBranchTeamRestrictions("owner", null, "branch", teamsToRemove)); Assert.Throws(() => client.DeleteProtectedBranchTeamRestrictions("owner", "repo", null, teamsToRemove)); Assert.Throws(() => client.DeleteProtectedBranchTeamRestrictions("owner", "repo", "branch", null)); Assert.Throws(() => client.DeleteProtectedBranchTeamRestrictions(1, null, teamsToRemove)); Assert.Throws(() => client.DeleteProtectedBranchTeamRestrictions(1, "branch", null)); Assert.Throws(() => client.DeleteProtectedBranchTeamRestrictions("", "repo", "branch", teamsToRemove)); Assert.Throws(() => client.DeleteProtectedBranchTeamRestrictions("owner", "", "branch", teamsToRemove)); Assert.Throws(() => client.DeleteProtectedBranchTeamRestrictions("owner", "repo", "", teamsToRemove)); Assert.Throws(() => client.DeleteProtectedBranchTeamRestrictions(1, "", teamsToRemove)); } } public class TheGetAllProtectedBranchUserRestrictionsMethod { [Fact] public void RequestsTheCorrectUrl() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); client.GetAllProtectedBranchUserRestrictions("owner", "repo", "branch"); gitHubClient.Repository.Branch.Received() .GetAllProtectedBranchUserRestrictions("owner", "repo", "branch"); } [Fact] public void RequestsTheCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); client.GetAllProtectedBranchUserRestrictions(1, "branch"); gitHubClient.Repository.Branch.Received() .GetAllProtectedBranchUserRestrictions(1, "branch"); } [Fact] public async Task EnsuresNonNullArguments() { var client = new ObservableRepositoryBranchesClient(Substitute.For()); Assert.Throws(() => client.GetAllProtectedBranchUserRestrictions(null, "repo", "branch")); Assert.Throws(() => client.GetAllProtectedBranchUserRestrictions("owner", null, "branch")); Assert.Throws(() => client.GetAllProtectedBranchUserRestrictions("owner", "repo", null)); Assert.Throws(() => client.GetAllProtectedBranchUserRestrictions(1, null)); Assert.Throws(() => client.GetAllProtectedBranchUserRestrictions("", "repo", "branch")); Assert.Throws(() => client.GetAllProtectedBranchUserRestrictions("owner", "", "branch")); Assert.Throws(() => client.GetAllProtectedBranchUserRestrictions("owner", "repo", "")); Assert.Throws(() => client.GetAllProtectedBranchUserRestrictions(1, "")); } } public class TheSetProtectedBranchUserRestrictionsMethod { [Fact] public void RequestsTheCorrectUrl() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); var newUsers = new BranchProtectionUserCollection() { "test" }; client.UpdateProtectedBranchUserRestrictions("owner", "repo", "branch", newUsers); gitHubClient.Repository.Branch.Received() .UpdateProtectedBranchUserRestrictions("owner", "repo", "branch", newUsers); } [Fact] public void RequestsTheCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); var newUsers = new BranchProtectionUserCollection() { "test" }; client.UpdateProtectedBranchUserRestrictions(1, "branch", newUsers); gitHubClient.Repository.Branch.Received() .UpdateProtectedBranchUserRestrictions(1, "branch", newUsers); } [Fact] public async Task EnsuresNonNullArguments() { var client = new ObservableRepositoryBranchesClient(Substitute.For()); var newUsers = new BranchProtectionUserCollection() { "test" }; Assert.Throws(() => client.UpdateProtectedBranchUserRestrictions(null, "repo", "branch", newUsers)); Assert.Throws(() => client.UpdateProtectedBranchUserRestrictions("owner", null, "branch", newUsers)); Assert.Throws(() => client.UpdateProtectedBranchUserRestrictions("owner", "repo", null, newUsers)); Assert.Throws(() => client.UpdateProtectedBranchUserRestrictions("owner", "repo", "branch", null)); Assert.Throws(() => client.UpdateProtectedBranchUserRestrictions(1, null, newUsers)); Assert.Throws(() => client.UpdateProtectedBranchUserRestrictions(1, "branch", null)); Assert.Throws(() => client.UpdateProtectedBranchUserRestrictions("", "repo", "branch", newUsers)); Assert.Throws(() => client.UpdateProtectedBranchUserRestrictions("owner", "", "branch", newUsers)); Assert.Throws(() => client.UpdateProtectedBranchUserRestrictions("owner", "repo", "", newUsers)); Assert.Throws(() => client.UpdateProtectedBranchUserRestrictions(1, "", newUsers)); } } public class TheAddProtectedBranchUserRestrictionsMethod { [Fact] public void RequestsTheCorrectUrl() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); var newUsers = new BranchProtectionUserCollection() { "test" }; client.AddProtectedBranchUserRestrictions("owner", "repo", "branch", newUsers); gitHubClient.Repository.Branch.Received() .AddProtectedBranchUserRestrictions("owner", "repo", "branch", newUsers); } [Fact] public void RequestsTheCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); var newUsers = new BranchProtectionUserCollection() { "test" }; client.AddProtectedBranchUserRestrictions(1, "branch", newUsers); gitHubClient.Repository.Branch.Received() .AddProtectedBranchUserRestrictions(1, "branch", newUsers); } [Fact] public async Task EnsuresNonNullArguments() { var client = new ObservableRepositoryBranchesClient(Substitute.For()); var newUsers = new BranchProtectionUserCollection() { "test" }; Assert.Throws(() => client.AddProtectedBranchUserRestrictions(null, "repo", "branch", newUsers)); Assert.Throws(() => client.AddProtectedBranchUserRestrictions("owner", null, "branch", newUsers)); Assert.Throws(() => client.AddProtectedBranchUserRestrictions("owner", "repo", null, newUsers)); Assert.Throws(() => client.AddProtectedBranchUserRestrictions("owner", "repo", "branch", null)); Assert.Throws(() => client.AddProtectedBranchUserRestrictions(1, null, newUsers)); Assert.Throws(() => client.AddProtectedBranchUserRestrictions(1, "branch", null)); Assert.Throws(() => client.AddProtectedBranchUserRestrictions("", "repo", "branch", newUsers)); Assert.Throws(() => client.AddProtectedBranchUserRestrictions("owner", "", "branch", newUsers)); Assert.Throws(() => client.AddProtectedBranchUserRestrictions("owner", "repo", "", newUsers)); Assert.Throws(() => client.AddProtectedBranchUserRestrictions(1, "", newUsers)); } } public class TheDeleteProtectedBranchUserRestrictions { [Fact] public void RequestsTheCorrectUrl() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); var usersToRemove = new BranchProtectionUserCollection() { "test" }; client.DeleteProtectedBranchUserRestrictions("owner", "repo", "branch", usersToRemove); gitHubClient.Repository.Branch.Received() .DeleteProtectedBranchUserRestrictions("owner", "repo", "branch", usersToRemove); } [Fact] public void RequestsTheCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); var usersToRemove = new BranchProtectionUserCollection() { "test" }; client.DeleteProtectedBranchUserRestrictions(1, "branch", usersToRemove); gitHubClient.Repository.Branch.Received() .DeleteProtectedBranchUserRestrictions(1, "branch", usersToRemove); } [Fact] public async Task EnsuresNonNullArguments() { var client = new ObservableRepositoryBranchesClient(Substitute.For()); var usersToRemove = new BranchProtectionUserCollection() { "test" }; Assert.Throws(() => client.DeleteProtectedBranchUserRestrictions(null, "repo", "branch", usersToRemove)); Assert.Throws(() => client.DeleteProtectedBranchUserRestrictions("owner", null, "branch", usersToRemove)); Assert.Throws(() => client.DeleteProtectedBranchUserRestrictions("owner", "repo", null, usersToRemove)); Assert.Throws(() => client.DeleteProtectedBranchUserRestrictions("owner", "repo", "branch", null)); Assert.Throws(() => client.DeleteProtectedBranchUserRestrictions(1, null, usersToRemove)); Assert.Throws(() => client.DeleteProtectedBranchUserRestrictions(1, "branch", null)); Assert.Throws(() => client.DeleteProtectedBranchUserRestrictions("", "repo", "branch", usersToRemove)); Assert.Throws(() => client.DeleteProtectedBranchUserRestrictions("owner", "", "branch", usersToRemove)); Assert.Throws(() => client.DeleteProtectedBranchUserRestrictions("owner", "repo", "", usersToRemove)); Assert.Throws(() => client.DeleteProtectedBranchUserRestrictions(1, "", usersToRemove)); } } } }