public async Task RequestsCorrectUrlWithRepositoryId() { var connection = Substitute.For <IApiConnection>(); var client = new CommitsClient(connection); await client.Get(1, "reference"); connection.Received().Get <Commit>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/git/commits/reference")); }
public void RequestsCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new CommitsClient(connection); client.Get("owner", "repo", "reference"); connection.Received().Get <Commit>(Arg.Is <Uri>(u => u.ToString() == "repos/owner/repo/git/commits/reference")); }
public void RequestsCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new CommitsClient(connection); client.Get("owner", "repo", "reference"); connection.Received().Get <Commit>(Arg.Is <Uri>(u => u.ToString() == "repos/owner/repo/git/commits/reference"), Arg.Any <Dictionary <string, string> >(), "application/vnd.github.cryptographer-preview+sha"); }
public async Task EnsuresNonNullArguments() { var client = new CommitsClient(Substitute.For <IApiConnection>()); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Get(null, "name", "reference")); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Get("owner", null, "reference")); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Get("owner", "name", null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Get(1, null)); await Assert.ThrowsAsync <ArgumentException>(() => client.Get("", "name", "reference")); await Assert.ThrowsAsync <ArgumentException>(() => client.Get("owner", "", "reference")); await Assert.ThrowsAsync <ArgumentException>(() => client.Get("owner", "name", "")); await Assert.ThrowsAsync <ArgumentException>(() => client.Get(1, "")); }
/// <summary> /// Loads data from GitHub and puts it into an observable collection /// </summary> public async void LoadData() { if (!IsDataLoaded) { this.Items.Clear(); Octokit.ApiConnection apiConnection = new ApiConnection(App.GitHubClient.Connection); CommitsClient commitsClient = new CommitsClient(apiConnection); Repository repo = branch.Commit.Repository; IReadOnlyList <Octokit.Commit> commits = await GetAllCommits(apiConnection, repo.Owner.Login, repo.Name, branch.Commit.Sha); foreach (Octokit.Commit commit in commits) { Commit c = await commitsClient.Get(repo.Owner.Login, repo.Name, commit.Sha); this.Items.Add(new CommitItemViewModel(c)); } this.IsDataLoaded = true; } }