public void EnsuresArguments() { var client = new RepositoriesClient(Substitute.For <IApiConnection>()); Assert.Throws <ArgumentNullException>(() => client.GetAllContributors(null, "repo")); Assert.Throws <ArgumentNullException>(() => client.GetAllContributors("owner", null)); Assert.Throws <ArgumentException>(() => client.GetAllContributors("", "repo")); Assert.Throws <ArgumentException>(() => client.GetAllContributors("owner", "")); }
public async Task <IEnumerable <RepositoryContributor> > GetContributorsForRepository(long repositoryId, GitHubClient gitHubClient) { if (_repositoriesClient == null) { _repositoriesClient = new RepositoriesClient(new ApiConnection(gitHubClient.Connection)); } return(await _repositoriesClient.GetAllContributors(repositoryId)); }
public void GetsCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new RepositoriesClient(connection); client.GetAllContributors("owner", "name"); connection.Received() .GetAll <RepositoryContributor>(Arg.Is <Uri>(u => u.ToString() == "repos/owner/name/contributors"), Arg.Any <IDictionary <string, string> >()); }
public async Task RequestsTheCorrectUrlWithRepositoryIdIncludeAnonymous() { var connection = Substitute.For <IApiConnection>(); var client = new RepositoriesClient(connection); await client.GetAllContributors(1, true); connection.Received() .GetAll <RepositoryContributor>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/contributors"), Arg.Is <IDictionary <string, string> >(d => d["anon"] == "1"), Args.ApiOptions); }
public async Task RequestsTheCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new RepositoriesClient(connection); await client.GetAllContributors("owner", "name"); connection.Received() .GetAll <RepositoryContributor>(Arg.Is <Uri>(u => u.ToString() == "repos/owner/name/contributors"), Arg.Any <IDictionary <string, string> >(), Args.ApiOptions); }
public async Task RequestsTheCorrectUrlWithApiOptionsIncludeAnonymous() { var connection = Substitute.For <IApiConnection>(); var client = new RepositoriesClient(connection); var options = new ApiOptions { PageCount = 1, StartPage = 1, PageSize = 1 }; await client.GetAllContributors("owner", "name", true, options); connection.Received() .GetAll <RepositoryContributor>(Arg.Is <Uri>(u => u.ToString() == "repos/owner/name/contributors"), Arg.Is <IDictionary <string, string> >(d => d["anon"] == "1"), options); }
public void RequestsTheCorrectUrlWithRepositoryIdWithApiOptions() { var connection = Substitute.For <IApiConnection>(); var client = new RepositoriesClient(connection); var options = new ApiOptions { PageCount = 1, StartPage = 1, PageSize = 1 }; client.GetAllContributors(1, options); connection.Received() .GetAll <RepositoryContributor>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/contributors"), Arg.Any <IDictionary <string, string> >(), options); }
public async Task EnsuresNonNullArguments() { var client = new RepositoriesClient(Substitute.For <IApiConnection>()); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllContributors(null, "repo")); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllContributors("owner", null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllContributors(null, "repo", ApiOptions.None)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllContributors("owner", null, ApiOptions.None)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllContributors("owner", "repo", null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllContributors(null, "repo", false, ApiOptions.None)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllContributors("owner", null, false, ApiOptions.None)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllContributors("owner", "repo", false, null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllContributors(1, null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllContributors(1, false, null)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllContributors("", "repo")); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllContributors("owner", "")); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllContributors("", "repo", ApiOptions.None)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllContributors("owner", "", ApiOptions.None)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllContributors("", "repo", false, ApiOptions.None)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllContributors("owner", "", false, ApiOptions.None)); }
public async Task EnsuresNonNullArguments() { var client = new RepositoriesClient(Substitute.For<IApiConnection>()); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllContributors(null, "repo")); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllContributors("owner", null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllContributors(null, "repo", ApiOptions.None)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllContributors("owner", null, ApiOptions.None)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllContributors("owner", "repo", null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllContributors(null, "repo", false, ApiOptions.None)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllContributors("owner", null, false, ApiOptions.None)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllContributors("owner", "repo", false, null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllContributors(1, null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllContributors(1, false, null)); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllContributors("", "repo")); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllContributors("owner", "")); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllContributors("", "repo", ApiOptions.None)); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllContributors("owner", "", ApiOptions.None)); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllContributors("", "repo", false, ApiOptions.None)); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllContributors("owner", "", false, ApiOptions.None)); }
public async Task RequestsTheCorrectUrlWithRepositoryIdWithApiOptionsIncludeAnonymous() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoriesClient(connection); var options = new ApiOptions { PageCount = 1, StartPage = 1, PageSize = 1 }; await client.GetAllContributors(1, true, options); connection.Received() .GetAll<RepositoryContributor>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/contributors"), Arg.Is<IDictionary<string, string>>(d => d["anon"] == "1"), options); }
public async Task RequestsTheCorrectUrlIncludeAnonymous() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoriesClient(connection); await client.GetAllContributors("owner", "name", true); connection.Received() .GetAll<RepositoryContributor>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/contributors"), Arg.Is<IDictionary<string, string>>(d => d["anon"] == "1"), Args.ApiOptions); }
public void RequestsTheCorrectUrlWithRepositoryIdWithApiOptions() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoriesClient(connection); var options = new ApiOptions { PageCount = 1, StartPage = 1, PageSize = 1 }; client.GetAllContributors(1, options); connection.Received() .GetAll<RepositoryContributor>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/contributors"), Arg.Any<IDictionary<string, string>>(), options); }
public async Task RequestsTheCorrectUrlWithApiOptions() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoriesClient(connection); var options = new ApiOptions { PageCount = 1, StartPage = 1, PageSize = 1 }; await client.GetAllContributors("owner", "name", options); connection.Received() .GetAll<RepositoryContributor>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/contributors"), Arg.Any<IDictionary<string, string>>(), options); }
public async Task RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoriesClient(connection); await client.GetAllContributors(1); connection.Received() .GetAll<RepositoryContributor>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/contributors"), Arg.Any<IDictionary<string, string>>(), Args.ApiOptions); }
public void GetsCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoriesClient(connection); client.GetAllContributors("owner", "name"); connection.Received() .GetAll<RepositoryContributor>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/contributors"), Arg.Any<IDictionary<string, string>>()); }