public void EnsuresNotNullAndNonEmptyArguments() { var github = Substitute.For<IGitHubClient>(); var client = new ObservableTeamsClient(github); Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("shield", null).ToTask()); Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(null, new NewTeam("avengers")).ToTask()); Assert.ThrowsAsync<ArgumentException>(() => client.Create("", new NewTeam("avengers")).ToTask()); }
public async Task GetsAllMembersWhenAuthenticated() { var github = Helper.GetAuthenticatedClient(); var client = new ObservableTeamsClient(github); var member = await client.GetMembers(team.Id); Assert.Equal(Helper.UserName, member.Login); }
/// <summary> /// Initializes a new Organization API client. /// </summary> /// <param name="client">An <see cref="IGitHubClient" /> used to make the requests</param> public ObservableOrganizationsClient(IGitHubClient client) { Ensure.ArgumentNotNull(client, "client"); Member = new ObservableOrganizationMembersClient(client); Team = new ObservableTeamsClient(client); _client = client.Organization; _connection = client.Connection; }
public void PostsToCorrectUrl() { var team = new NewTeam("avengers"); var github = Substitute.For<IGitHubClient>(); var client = new ObservableTeamsClient(github); client.Create("shield", team); github.Organization.Team.Received().Create("shield", team); }
public async Task GetsAllMembersWhenAuthenticated() { var github = Helper.GetAuthenticatedClient(); var client = new ObservableTeamsClient(github); var observable = client.GetAllMembers(_team.Id, ApiOptions.None); var members = await observable.ToList(); Assert.True(members.Count > 0); Assert.True(members.Any(x => x.Login == Helper.UserName)); }
/// <summary> /// Initializes a new Organization API client. /// </summary> /// <param name="client">An <see cref="IGitHubClient" /> used to make the requests</param> public ObservableOrganizationsClient(IGitHubClient client) { Ensure.ArgumentNotNull(client, nameof(client)); Member = new ObservableOrganizationMembersClient(client); Team = new ObservableTeamsClient(client); OutsideCollaborator = new ObservableOrganizationOutsideCollaboratorsClient(client); _client = client.Organization; _connection = client.Connection; }
public async Task GetsAllMembersWhenAuthenticated() { var github = new GitHubClient(new ProductHeaderValue("OctokitTests")) { Credentials = Helper.Credentials }; var client = new ObservableTeamsClient(github); var member = await client.GetMembers(team.Id); Assert.Equal(Helper.UserName, member.Login); }
public async Task GetsAllRepositories() { var github = Helper.GetAuthenticatedClient(); var client = new ObservableTeamsClient(github); using (var repositoryContext = await github.CreateRepositoryContext(Helper.Organization, new NewRepository(Helper.MakeNameWithTimestamp("teamrepo")))) { client.AddRepository(_team.Id, Helper.Organization, repositoryContext.RepositoryName); var observable = client.GetAllRepositories(_team.Id, ApiOptions.None); var repos = await observable.ToList(); Assert.True(repos.Count() > 0); Assert.NotNull(repos[0].Permissions); } }