public void RequestsTheCorrectUrlWithRepositoryId() { var github = Substitute.For <IGitHubClient>(); var client = new ObservableRepositoryBranchesClient(github); client.Get(1, "branch"); github.Repository.Branch.Received(1).Get(1, "branch"); }
public void RequestsTheCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For <IGitHubClient>(); var client = new ObservableRepositoryBranchesClient(gitHubClient); var expected = new Uri("repositories/1/branches", UriKind.Relative); client.GetAll(1); gitHubClient.Connection.Received(1).Get <List <Branch> >(expected, Args.EmptyDictionary, null); }
public void RequestsTheCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For <IGitHubClient>(); var client = new ObservableRepositoryBranchesClient(gitHubClient); client.DeleteBranchProtection(1, "branch"); gitHubClient.Repository.Branch.Received() .DeleteBranchProtection(1, "branch"); }
public void RequestsTheCorrectUrl() { var gitHubClient = Substitute.For <IGitHubClient>(); var client = new ObservableRepositoryBranchesClient(gitHubClient); client.GetBranchProtection("owner", "repo", "branch"); gitHubClient.Repository.Branch.Received() .GetBranchProtection("owner", "repo", "branch"); }
public void RequestsTheCorrectUrl() { var github = Substitute.For <IGitHubClient>(); var client = new ObservableRepositoryBranchesClient(github); var update = new BranchUpdate(); client.Edit("owner", "repo", "branch", update); github.Repository.Branch.Received(1).Edit("owner", "repo", "branch", update); }
public void RequestsTheCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For <IGitHubClient>(); var client = new ObservableRepositoryBranchesClient(gitHubClient); var update = new BranchProtectionSettingsUpdate( new BranchProtectionRequiredStatusChecksUpdate(true, true, new[] { "test" })); client.UpdateBranchProtection(1, "branch", update); gitHubClient.Repository.Branch.Received() .UpdateBranchProtection(1, "branch", update); }
public async Task EnsuresNonNullArguments() { var client = new ObservableRepositoryBranchesClient(Substitute.For <IGitHubClient>()); Assert.Throws <ArgumentNullException>(() => client.DeleteBranchProtection(null, "repo", "branch")); Assert.Throws <ArgumentNullException>(() => client.DeleteBranchProtection("owner", null, "branch")); Assert.Throws <ArgumentNullException>(() => client.DeleteBranchProtection("owner", "repo", null)); Assert.Throws <ArgumentNullException>(() => client.DeleteBranchProtection(1, null)); Assert.Throws <ArgumentException>(() => client.DeleteBranchProtection("", "repo", "branch")); Assert.Throws <ArgumentException>(() => client.DeleteBranchProtection("owner", "", "branch")); Assert.Throws <ArgumentException>(() => client.DeleteBranchProtection("owner", "repo", "")); Assert.Throws <ArgumentException>(() => client.DeleteBranchProtection(1, "")); }
public void RequestsTheCorrectUrlWithRepositoryIdWithApiOptions() { var gitHubClient = Substitute.For <IGitHubClient>(); 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 <List <Branch> >(expected, Arg.Is <IDictionary <string, string> >(d => d.Count == 2 && d["page"] == "1" && d["per_page"] == "1"), null); }
public void EnsuresNonNullArguments() { var client = new ObservableRepositoryBranchesClient(Substitute.For <IGitHubClient>()); Assert.Throws <ArgumentNullException>(() => client.GetAll(null, "name")); Assert.Throws <ArgumentNullException>(() => client.GetAll("owner", null)); Assert.Throws <ArgumentNullException>(() => client.GetAll(null, "name", ApiOptions.None)); Assert.Throws <ArgumentNullException>(() => client.GetAll("owner", null, ApiOptions.None)); Assert.Throws <ArgumentNullException>(() => client.GetAll("owner", "name", null)); Assert.Throws <ArgumentNullException>(() => client.GetAll(1, null)); Assert.Throws <ArgumentException>(() => client.GetAll("", "name")); Assert.Throws <ArgumentException>(() => client.GetAll("owner", "")); Assert.Throws <ArgumentException>(() => client.GetAll("", "name", ApiOptions.None)); Assert.Throws <ArgumentException>(() => client.GetAll("owner", "", ApiOptions.None)); }
public async Task EnsuresNonNullArguments() { var client = new ObservableRepositoryBranchesClient(Substitute.For <IGitHubClient>()); var update = new BranchUpdate(); Assert.Throws <ArgumentNullException>(() => client.Edit(null, "repo", "branch", update)); Assert.Throws <ArgumentNullException>(() => client.Edit("owner", null, "branch", update)); Assert.Throws <ArgumentNullException>(() => client.Edit("owner", "repo", null, update)); Assert.Throws <ArgumentNullException>(() => client.Edit("owner", "repo", "branch", null)); Assert.Throws <ArgumentNullException>(() => client.Edit(1, null, update)); Assert.Throws <ArgumentNullException>(() => client.Edit(1, "branch", null)); Assert.Throws <ArgumentException>(() => client.Edit("", "repo", "branch", update)); Assert.Throws <ArgumentException>(() => client.Edit("owner", "", "branch", update)); Assert.Throws <ArgumentException>(() => client.Edit("owner", "repo", "", update)); Assert.Throws <ArgumentException>(() => client.Edit(1, "", update)); }
public async Task EnsuresNonNullArguments() { var client = new ObservableRepositoryBranchesClient(Substitute.For <IGitHubClient>()); var update = new BranchProtectionSettingsUpdate( new BranchProtectionRequiredStatusChecksUpdate(true, true, new[] { "test" })); Assert.Throws <ArgumentNullException>(() => client.UpdateBranchProtection(null, "repo", "branch", update)); Assert.Throws <ArgumentNullException>(() => client.UpdateBranchProtection("owner", null, "branch", update)); Assert.Throws <ArgumentNullException>(() => client.UpdateBranchProtection("owner", "repo", null, update)); Assert.Throws <ArgumentNullException>(() => client.UpdateBranchProtection("owner", "repo", "branch", null)); Assert.Throws <ArgumentNullException>(() => client.UpdateBranchProtection(1, null, update)); Assert.Throws <ArgumentNullException>(() => client.UpdateBranchProtection(1, "branch", null)); Assert.Throws <ArgumentException>(() => client.UpdateBranchProtection("", "repo", "branch", update)); Assert.Throws <ArgumentException>(() => client.UpdateBranchProtection("owner", "", "branch", update)); Assert.Throws <ArgumentException>(() => client.UpdateBranchProtection("owner", "repo", "", update)); Assert.Throws <ArgumentException>(() => client.UpdateBranchProtection(1, "", update)); }