public void EnsuresNonNullArguments() { var client = new RepoCollaboratorsClient(Substitute.For<IApiConnection>()); Assert.Throws<ArgumentNullException>(() => client.GetAll(null,"test")); Assert.Throws<ArgumentException>(() => client.GetAll("", "test")); Assert.Throws<ArgumentNullException>(() => client.GetAll("owner", null)); Assert.Throws<ArgumentException>(() => client.GetAll("owner", "")); }
public void EnsuresNonNullArguments() { var client = new RepoCollaboratorsClient(Substitute.For <IApiConnection>()); Assert.Throws <ArgumentNullException>(() => client.GetAll(null, "test")); Assert.Throws <ArgumentException>(() => client.GetAll("", "test")); Assert.Throws <ArgumentNullException>(() => client.GetAll("owner", null)); Assert.Throws <ArgumentException>(() => client.GetAll("owner", "")); }
public void RequestsCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new RepoCollaboratorsClient(connection); client.GetAll("owner", "test"); connection.Received().GetAll<User>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/test/collaborators"), null, "application/vnd.github.ironman-preview+json", Args.ApiOptions); }
public async Task <IEnumerable <User> > GetCollaboratorsForRepository(long repositoryId, GitHubClient gitHubClient) { if (_repoCollaboratorsClient == null) { _repoCollaboratorsClient = new RepoCollaboratorsClient(new ApiConnection(gitHubClient.Connection)); } return(await _repoCollaboratorsClient.GetAll(repositoryId)); }
public void RequestsCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new RepoCollaboratorsClient(connection); client.GetAll("owner", "test"); connection.Received().GetAll <User>(Arg.Is <Uri>(u => u.ToString() == "repos/owner/test/collaborators")); }
public void RequestsCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new RepoCollaboratorsClient(connection); client.GetAll("owner", "test"); connection.Received().GetAll<User>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/test/collaborators")); }
public void RequestsCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new RepoCollaboratorsClient(connection); client.GetAll("owner", "test"); connection.Received().GetAll <User>(Arg.Is <Uri>(u => u.ToString() == "repos/owner/test/collaborators"), null, "application/vnd.github.ironman-preview+json", Args.ApiOptions); }
public void RequestsCorrectUrlWithRepositoryId() { var connection = Substitute.For <IApiConnection>(); var client = new RepoCollaboratorsClient(connection); client.GetAll(1); connection.Received().GetAll <User>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/collaborators"), Args.ApiOptions); }
public void RequestsCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new RepoCollaboratorsClient(connection); client.GetAll(1); connection.Received().GetAll<User>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/collaborators"), Args.ApiOptions); }
public void RequestsCorrectUrlWithCollaboratorFilterAndRepositoryId() { var connection = Substitute.For <IApiConnection>(); var client = new RepoCollaboratorsClient(connection); var request = new RepositoryCollaboratorListRequest(); client.GetAll(1, request); connection.Received() .GetAll <User>( Arg.Is <Uri>(u => u.ToString() == "repositories/1/collaborators"), Arg.Is <Dictionary <string, string> >(d => d["affiliation"] == "all"), "application/vnd.github.hellcat-preview+json", Args.ApiOptions); request = new RepositoryCollaboratorListRequest { Affiliation = CollaboratorAffiliation.Direct }; client.GetAll(1, request); connection.Received() .GetAll <User>( Arg.Is <Uri>(u => u.ToString() == "repositories/1/collaborators"), Arg.Is <Dictionary <string, string> >(d => d["affiliation"] == "direct"), "application/vnd.github.hellcat-preview+json", Args.ApiOptions); request = new RepositoryCollaboratorListRequest { Affiliation = CollaboratorAffiliation.Outside }; client.GetAll(1, request); connection.Received() .GetAll <User>( Arg.Is <Uri>(u => u.ToString() == "repositories/1/collaborators"), Arg.Is <Dictionary <string, string> >(d => d["affiliation"] == "outside"), "application/vnd.github.hellcat-preview+json", Args.ApiOptions); }
public void RequestsCorrectUrlWithRepositoryId() { var connection = Substitute.For <IApiConnection>(); var client = new RepoCollaboratorsClient(connection); client.GetAll(1); connection.Received().GetAll <User>( Arg.Is <Uri>(u => u.ToString() == "repositories/1/collaborators"), Arg.Any <Dictionary <string, string> >(), "application/vnd.github.hellcat-preview+json", Args.ApiOptions); }
public void RequestsCorrectUrlWithCollaboratorFilter() { var connection = Substitute.For <IApiConnection>(); var client = new RepoCollaboratorsClient(connection); var request = new RepositoryCollaboratorListRequest(); client.GetAll("owner", "test", request); connection.Received() .GetAll <User>(Arg.Is <Uri>(u => u.ToString() == "repos/owner/test/collaborators"), Arg.Is <Dictionary <string, string> >(d => d["affiliation"] == "all"), Args.ApiOptions); request = new RepositoryCollaboratorListRequest { Affiliation = CollaboratorAffiliation.Direct }; client.GetAll("owner", "test", request); connection.Received() .GetAll <User>(Arg.Is <Uri>(u => u.ToString() == "repos/owner/test/collaborators"), Arg.Is <Dictionary <string, string> >(d => d["affiliation"] == "direct"), Args.ApiOptions); request = new RepositoryCollaboratorListRequest { Affiliation = CollaboratorAffiliation.Outside }; client.GetAll("owner", "test", request); connection.Received() .GetAll <User>(Arg.Is <Uri>(u => u.ToString() == "repos/owner/test/collaborators"), Arg.Is <Dictionary <string, string> >(d => d["affiliation"] == "outside"), Args.ApiOptions); }
public async Task EnsuresNonNullArguments() { var client = new RepoCollaboratorsClient(Substitute.For<IApiConnection>()); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null, "test")); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("", "test")); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", null)); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("owner", "")); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null, "test", ApiOptions.None)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", null, ApiOptions.None)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", "test", null)); }
public async Task EnsuresNonNullArguments() { var client = new RepoCollaboratorsClient(Substitute.For <IApiConnection>()); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAll(null, "test")); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAll("", "test")); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAll("owner", null)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAll("owner", "")); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAll(null, "test", ApiOptions.None)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAll("owner", null, ApiOptions.None)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAll("owner", "test", options: null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAll("owner", "test", request: null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAll(1, options: null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAll(1, request: null)); }
public void RequestsCorrectUrlWithApiOptionsAndRepositoryId() { var connection = Substitute.For <IApiConnection>(); var client = new RepoCollaboratorsClient(connection); var options = new ApiOptions { PageSize = 1, PageCount = 1, StartPage = 1 }; client.GetAll(1, options); connection.Received() .GetAll <User>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/collaborators"), options); }
public void RequestsCorrectUrlWithApiOptionsAndRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new RepoCollaboratorsClient(connection); var options = new ApiOptions { PageSize = 1, PageCount = 1, StartPage = 1 }; client.GetAll(1, options); connection.Received() .GetAll<User>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/collaborators"), options); }
public void RequestsCorrectUrlWithApiOptions() { var connection = Substitute.For <IApiConnection>(); var client = new RepoCollaboratorsClient(connection); var options = new ApiOptions { PageSize = 1, PageCount = 1, StartPage = 1 }; client.GetAll("owner", "test", options); connection.Received() .GetAll <User>(Arg.Is <Uri>(u => u.ToString() == "repos/owner/test/collaborators"), Arg.Any <Dictionary <string, string> >(), options); }