public async Task EnsuresNonNullArguments() { var client = new RepositoryBranchesClient(Substitute.For <IApiConnection>()); var update = new BranchUpdate(); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Edit(null, "repo", "branch", update)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Edit("owner", null, "branch", update)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Edit("owner", "repo", null, update)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Edit("owner", "repo", "branch", null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Edit(1, null, update)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Edit(1, "branch", null)); await Assert.ThrowsAsync <ArgumentException>(() => client.Edit("", "repo", "branch", update)); await Assert.ThrowsAsync <ArgumentException>(() => client.Edit("owner", "", "branch", update)); await Assert.ThrowsAsync <ArgumentException>(() => client.Edit("owner", "repo", "", update)); await Assert.ThrowsAsync <ArgumentException>(() => client.Edit(1, "", update)); }
public async Task EnsuresNonNullArguments() { var client = new RepositoryBranchesClient(Substitute.For <IApiConnection>()); var update = new BranchProtectionSettingsUpdate( new BranchProtectionRequiredStatusChecksUpdate(true, true, new[] { "test" })); await Assert.ThrowsAsync <ArgumentNullException>(() => client.UpdateBranchProtection(null, "repo", "branch", update)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.UpdateBranchProtection("owner", null, "branch", update)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.UpdateBranchProtection("owner", "repo", null, update)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.UpdateBranchProtection("owner", "repo", "branch", null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.UpdateBranchProtection(1, null, update)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.UpdateBranchProtection(1, "branch", null)); await Assert.ThrowsAsync <ArgumentException>(() => client.UpdateBranchProtection("", "repo", "branch", update)); await Assert.ThrowsAsync <ArgumentException>(() => client.UpdateBranchProtection("owner", "", "branch", update)); await Assert.ThrowsAsync <ArgumentException>(() => client.UpdateBranchProtection("owner", "repo", "", update)); await Assert.ThrowsAsync <ArgumentException>(() => client.UpdateBranchProtection(1, "", update)); }
public async Task RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); await client.GetAll(1); connection.Received() .GetAll<Branch>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches"), null, "application/vnd.github.loki-preview+json", Args.ApiOptions); }
public async Task RequestsTheCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new RepositoryBranchesClient(connection); await client.Get("owner", "repo", "branch"); connection.Received() .Get <Branch>(Arg.Is <Uri>(u => u.ToString() == "repos/owner/repo/branches/branch"), null, "application/vnd.github.loki-preview+json"); }
public async Task RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For <IApiConnection>(); var client = new RepositoryBranchesClient(connection); await client.GetAll(1); connection.Received() .GetAll <Branch>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/branches"), null, "application/vnd.github.loki-preview+json", Args.ApiOptions); }
public void RequestsTheCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new RepositoryBranchesClient(connection); const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; client.GetBranchProtection("owner", "repo", "branch"); connection.Received() .Get <BranchProtectionSettings>(Arg.Is <Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection"), null, previewAcceptsHeader); }
public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For <IApiConnection>(); var client = new RepositoryBranchesClient(connection); const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; client.DeleteBranchProtection(1, "branch"); connection.Connection.Received() .Delete(Arg.Is <Uri>(u => u.ToString() == "repositories/1/branches/branch/protection"), Arg.Any <object>(), previewAcceptsHeader); }
public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For <IApiConnection>(); var client = new RepositoryBranchesClient(connection); var update = new BranchUpdate(); const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; client.Edit(1, "branch", update); connection.Received() .Patch <Branch>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/branches/branch"), Arg.Any <BranchUpdate>(), previewAcceptsHeader); }
public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For <IApiConnection>(); var client = new RepositoryBranchesClient(connection); var update = new BranchProtectionSettingsUpdate( new BranchProtectionRequiredStatusChecksUpdate(true, true, new[] { "test" })); const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; client.UpdateBranchProtection(1, "branch", update); connection.Received() .Put <BranchProtectionSettings>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/branches/branch/protection"), Arg.Any <BranchProtectionSettingsUpdate>(), null, previewAcceptsHeader); }
public async Task RequestsTheCorrectUrlWithApiOptions() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); var options = new ApiOptions { PageCount = 1, StartPage = 1, PageSize = 1 }; await client.GetAll("owner", "name", options); connection.Received() .GetAll<Branch>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/branches"), null, "application/vnd.github.loki-preview+json", options); }
public async Task RequestsTheCorrectUrlWithApiOptions() { var connection = Substitute.For <IApiConnection>(); var client = new RepositoryBranchesClient(connection); var options = new ApiOptions { PageCount = 1, StartPage = 1, PageSize = 1 }; await client.GetAll("owner", "name", options); connection.Received() .GetAll <Branch>(Arg.Is <Uri>(u => u.ToString() == "repos/owner/name/branches"), null, "application/vnd.github.loki-preview+json", options); }
public async Task EnsuresNonNullArguments() { var client = new RepositoryBranchesClient(Substitute.For <IApiConnection>()); await Assert.ThrowsAsync <ArgumentNullException>(() => client.DeleteBranchProtection(null, "repo", "branch")); await Assert.ThrowsAsync <ArgumentNullException>(() => client.DeleteBranchProtection("owner", null, "branch")); await Assert.ThrowsAsync <ArgumentNullException>(() => client.DeleteBranchProtection("owner", "repo", null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.DeleteBranchProtection(1, null)); await Assert.ThrowsAsync <ArgumentException>(() => client.DeleteBranchProtection("", "repo", "branch")); await Assert.ThrowsAsync <ArgumentException>(() => client.DeleteBranchProtection("owner", "", "branch")); await Assert.ThrowsAsync <ArgumentException>(() => client.DeleteBranchProtection("owner", "repo", "")); await Assert.ThrowsAsync <ArgumentException>(() => client.DeleteBranchProtection(1, "")); }
public async Task EnsuresNonNullArguments() { var client = new RepositoryBranchesClient(Substitute.For <IApiConnection>()); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAll(null, "name")); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAll("owner", null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAll(null, "name", ApiOptions.None)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAll("owner", null, ApiOptions.None)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAll("owner", "name", null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAll(1, null)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAll("", "name")); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAll("owner", "")); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAll("", "name", ApiOptions.None)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAll("owner", "", ApiOptions.None)); }
public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); var contextsToRemove = new List<string>() { "test" }; const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; client.DeleteRequiredStatusChecksContexts(1, "branch", contextsToRemove); connection.Received() .Delete<IReadOnlyList<string>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/required_status_checks/contexts"), Arg.Any<IReadOnlyList<string>>(), previewAcceptsHeader); }
public void RequestsTheCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); var newContexts = new List<string>() { "test" }; const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; client.AddRequiredStatusChecksContexts("owner", "repo", "branch", newContexts); connection.Received() .Post<IReadOnlyList<string>>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/required_status_checks/contexts"), Arg.Any<IReadOnlyList<string>>(), previewAcceptsHeader); }
public async Task EnsuresNonNullArguments() { var client = new RepositoryBranchesClient(Substitute.For<IApiConnection>()); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null, "name")); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null, "name", ApiOptions.None)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", null, ApiOptions.None)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", "name", null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(1, null)); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("", "name")); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("owner", "")); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("", "name", ApiOptions.None)); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("owner", "", ApiOptions.None)); }
public async Task EnsuresNonNullArguments() { var client = new RepositoryBranchesClient(Substitute.For<IApiConnection>()); var contextsToRemove = new List<string>() { "test" }; await Assert.ThrowsAsync<ArgumentNullException>(() => client.DeleteRequiredStatusChecksContexts(null, "repo", "branch", contextsToRemove)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.DeleteRequiredStatusChecksContexts("owner", null, "branch", contextsToRemove)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.DeleteRequiredStatusChecksContexts("owner", "repo", null, contextsToRemove)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.DeleteRequiredStatusChecksContexts("owner", "repo", "branch", null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.DeleteRequiredStatusChecksContexts(1, null, contextsToRemove)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.DeleteRequiredStatusChecksContexts(1, "branch", null)); await Assert.ThrowsAsync<ArgumentException>(() => client.DeleteRequiredStatusChecksContexts("", "repo", "branch", contextsToRemove)); await Assert.ThrowsAsync<ArgumentException>(() => client.DeleteRequiredStatusChecksContexts("owner", "", "branch", contextsToRemove)); await Assert.ThrowsAsync<ArgumentException>(() => client.DeleteRequiredStatusChecksContexts("owner", "repo", "", contextsToRemove)); await Assert.ThrowsAsync<ArgumentException>(() => client.DeleteRequiredStatusChecksContexts(1, "", contextsToRemove)); }
public void RequestsTheCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); var usersToRemove = new BranchProtectionUserCollection() { "test" }; const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; client.DeleteProtectedBranchUserRestrictions("owner", "repo", "branch", usersToRemove); connection.Received() .Delete<IReadOnlyList<User>>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/restrictions/users"), Arg.Any<IReadOnlyList<string>>(), previewAcceptsHeader); }
public async Task RequestsTheCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); await client.Get("owner", "repo", "branch"); connection.Received() .Get<Branch>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch"), null, "application/vnd.github.loki-preview+json"); }
public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; client.DeleteBranchProtection(1, "branch"); connection.Connection.Received() .Delete(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection"), Arg.Any<object>(), previewAcceptsHeader); }
public void RequestsTheCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); var update = new BranchProtectionRequiredStatusChecksUpdate(true, true, new[] { "test" }); const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; client.UpdateRequiredStatusChecks("owner", "repo", "branch", update); connection.Received() .Patch<BranchProtectionRequiredStatusChecks>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/required_status_checks"), Arg.Any<BranchProtectionRequiredStatusChecksUpdate>(), previewAcceptsHeader); }
public async Task EnsuresNonNullArguments() { var client = new RepositoryBranchesClient(Substitute.For<IApiConnection>()); var newUsers = new BranchProtectionUserCollection() { "test" }; await Assert.ThrowsAsync<ArgumentNullException>(() => client.AddProtectedBranchUserRestrictions(null, "repo", "branch", newUsers)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.AddProtectedBranchUserRestrictions("owner", null, "branch", newUsers)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.AddProtectedBranchUserRestrictions("owner", "repo", null, newUsers)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.AddProtectedBranchUserRestrictions("owner", "repo", "branch", null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.AddProtectedBranchUserRestrictions(1, null, newUsers)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.AddProtectedBranchUserRestrictions(1, "branch", null)); await Assert.ThrowsAsync<ArgumentException>(() => client.AddProtectedBranchUserRestrictions("", "repo", "branch", newUsers)); await Assert.ThrowsAsync<ArgumentException>(() => client.AddProtectedBranchUserRestrictions("owner", "", "branch", newUsers)); await Assert.ThrowsAsync<ArgumentException>(() => client.AddProtectedBranchUserRestrictions("owner", "repo", "", newUsers)); await Assert.ThrowsAsync<ArgumentException>(() => client.AddProtectedBranchUserRestrictions(1, "", newUsers)); }
public async Task EnsuresNonNullArguments() { var client = new RepositoryBranchesClient(Substitute.For<IApiConnection>()); var update = new BranchProtectionSettingsUpdate( new BranchProtectionRequiredStatusChecksUpdate(true, true, new[] { "test" })); await Assert.ThrowsAsync<ArgumentNullException>(() => client.UpdateBranchProtection(null, "repo", "branch", update)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.UpdateBranchProtection("owner", null, "branch", update)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.UpdateBranchProtection("owner", "repo", null, update)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.UpdateBranchProtection("owner", "repo", "branch", null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.UpdateBranchProtection(1, null, update)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.UpdateBranchProtection(1, "branch", null)); await Assert.ThrowsAsync<ArgumentException>(() => client.UpdateBranchProtection("", "repo", "branch", update)); await Assert.ThrowsAsync<ArgumentException>(() => client.UpdateBranchProtection("owner", "", "branch", update)); await Assert.ThrowsAsync<ArgumentException>(() => client.UpdateBranchProtection("owner", "repo", "", update)); await Assert.ThrowsAsync<ArgumentException>(() => client.UpdateBranchProtection(1, "", update)); }
public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); var teamsToRemove = new BranchProtectionTeamCollection() { "test" }; const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; client.DeleteProtectedBranchTeamRestrictions(1, "branch", teamsToRemove); connection.Received() .Delete<IReadOnlyList<Team>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions/teams"), Arg.Any<IReadOnlyList<string>>(), previewAcceptsHeader); }
public async Task EnsuresNonNullArguments() { var client = new RepositoryBranchesClient(Substitute.For<IApiConnection>()); var update = new BranchUpdate(); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Edit(null, "repo", "branch", update)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Edit("owner", null, "branch", update)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Edit("owner", "repo", null, update)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Edit("owner", "repo", "branch", null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Edit(1, null, update)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Edit(1, "branch", null)); await Assert.ThrowsAsync<ArgumentException>(() => client.Edit("", "repo", "branch", update)); await Assert.ThrowsAsync<ArgumentException>(() => client.Edit("owner", "", "branch", update)); await Assert.ThrowsAsync<ArgumentException>(() => client.Edit("owner", "repo", "", update)); await Assert.ThrowsAsync<ArgumentException>(() => client.Edit(1, "", update)); }
public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); var update = new BranchUpdate(); const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; client.Edit(1, "branch", update); connection.Received() .Patch<Branch>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch"), Arg.Any<BranchUpdate>(), previewAcceptsHeader); }
public async Task EnsuresNonNullArguments() { var client = new RepositoryBranchesClient(Substitute.For<IApiConnection>()); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetRequiredStatusChecksContexts(null, "repo", "branch")); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetRequiredStatusChecksContexts("owner", null, "branch")); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetRequiredStatusChecksContexts("owner", "repo", null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetRequiredStatusChecksContexts(1, null)); await Assert.ThrowsAsync<ArgumentException>(() => client.GetRequiredStatusChecksContexts("", "repo", "branch")); await Assert.ThrowsAsync<ArgumentException>(() => client.GetRequiredStatusChecksContexts("owner", "", "branch")); await Assert.ThrowsAsync<ArgumentException>(() => client.GetRequiredStatusChecksContexts("owner", "repo", "")); await Assert.ThrowsAsync<ArgumentException>(() => client.GetRequiredStatusChecksContexts(1, "")); }
public async Task EnsuresNonNullArguments() { var client = new RepositoryBranchesClient(Substitute.For<IApiConnection>()); await Assert.ThrowsAsync<ArgumentNullException>(() => client.DeleteBranchProtection(null, "repo", "branch")); await Assert.ThrowsAsync<ArgumentNullException>(() => client.DeleteBranchProtection("owner", null, "branch")); await Assert.ThrowsAsync<ArgumentNullException>(() => client.DeleteBranchProtection("owner", "repo", null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.DeleteBranchProtection(1, null)); await Assert.ThrowsAsync<ArgumentException>(() => client.DeleteBranchProtection("", "repo", "branch")); await Assert.ThrowsAsync<ArgumentException>(() => client.DeleteBranchProtection("owner", "", "branch")); await Assert.ThrowsAsync<ArgumentException>(() => client.DeleteBranchProtection("owner", "repo", "")); await Assert.ThrowsAsync<ArgumentException>(() => client.DeleteBranchProtection(1, "")); }
public void RequestsTheCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; client.DeleteRequiredStatusChecks("owner", "repo", "branch"); connection.Connection.Received() .Delete(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/required_status_checks"), Arg.Any<object>(), previewAcceptsHeader); }
public void RequestsTheCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); var newTeams = new BranchProtectionTeamCollection() { "test" }; const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; client.AddProtectedBranchTeamRestrictions("owner", "repo", "branch", newTeams); connection.Received() .Post<IReadOnlyList<Team>>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/restrictions/teams"), Arg.Any<IReadOnlyList<string>>(), previewAcceptsHeader); }
public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; client.GetRequiredStatusChecks(1, "branch"); connection.Received() .Get<BranchProtectionRequiredStatusChecks>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/required_status_checks"), null, previewAcceptsHeader); }
public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; client.GetProtectedBranchTeamRestrictions(1, "branch"); connection.Received() .Get<IReadOnlyList<Team>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions/teams"), null, previewAcceptsHeader); }
public void RequestsTheCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; client.GetBranchProtection("owner", "repo", "branch"); connection.Received() .Get<BranchProtectionSettings>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection"), null, previewAcceptsHeader); }
public async Task EnsuresNonNullArguments() { var client = new RepositoryBranchesClient(Substitute.For<IApiConnection>()); var teamsToRemove = new BranchProtectionTeamCollection() { "test" }; await Assert.ThrowsAsync<ArgumentNullException>(() => client.DeleteProtectedBranchTeamRestrictions(null, "repo", "branch", teamsToRemove)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.DeleteProtectedBranchTeamRestrictions("owner", null, "branch", teamsToRemove)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.DeleteProtectedBranchTeamRestrictions("owner", "repo", null, teamsToRemove)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.DeleteProtectedBranchTeamRestrictions("owner", "repo", "branch", null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.DeleteProtectedBranchTeamRestrictions(1, null, teamsToRemove)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.DeleteProtectedBranchTeamRestrictions(1, "branch", null)); await Assert.ThrowsAsync<ArgumentException>(() => client.DeleteProtectedBranchTeamRestrictions("", "repo", "branch", teamsToRemove)); await Assert.ThrowsAsync<ArgumentException>(() => client.DeleteProtectedBranchTeamRestrictions("owner", "", "branch", teamsToRemove)); await Assert.ThrowsAsync<ArgumentException>(() => client.DeleteProtectedBranchTeamRestrictions("owner", "repo", "", teamsToRemove)); await Assert.ThrowsAsync<ArgumentException>(() => client.DeleteProtectedBranchTeamRestrictions(1, "", teamsToRemove)); }
public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); var update = new BranchProtectionSettingsUpdate( new BranchProtectionRequiredStatusChecksUpdate(true, true, new[] { "test" })); const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; client.UpdateBranchProtection(1, "branch", update); connection.Received() .Put<BranchProtectionSettings>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection"), Arg.Any<BranchProtectionSettingsUpdate>(), null, previewAcceptsHeader); }
public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); var newUsers = new BranchProtectionUserCollection() { "test" }; const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; client.AddProtectedBranchUserRestrictions(1, "branch", newUsers); connection.Received() .Post<IReadOnlyList<User>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions/users"), Arg.Any<IReadOnlyList<string>>(), previewAcceptsHeader); }