Add repository property to Issue response model (#1292)

* Add repository property to Issue response model

Fixes #1243

* Fix typo
This commit is contained in:
Mordechai Zuber
2016-05-18 12:13:19 +03:00
committed by Brendan Forster
parent 60da3e0490
commit 1b51717f8d
2 changed files with 48 additions and 7 deletions

View File

@@ -7,6 +7,7 @@ using Octokit;
using Octokit.Tests.Integration;
using Xunit;
using Octokit.Tests.Integration.Helpers;
using System.Collections.Generic;
public class IssuesClientTests : IDisposable
{
@@ -66,19 +67,19 @@ public class IssuesClientTests : IDisposable
var newIssue = new NewIssue("a test issue") { Body = "A new unassigned issue" };
var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue);
Assert.False(issue.Locked);
await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number);
var retrieved = await _issuesClient.Get(_context.RepositoryOwner, _context.RepositoryName, issue.Number);
Assert.NotNull(retrieved);
Assert.True(retrieved.Locked);
await _issuesClient.Unlock(_context.RepositoryOwner, _context.RepositoryName, issue.Number);
retrieved = await _issuesClient.Get(_context.RepositoryOwner, _context.RepositoryName, issue.Number);
Assert.NotNull(retrieved);
Assert.False(retrieved.Locked);
}
[IntegrationTest]
}
[IntegrationTest]
public async Task CanListOpenIssuesWithDefaultSort()
{
var newIssue1 = new NewIssue("A test issue1") { Body = "A new unassigned issue" };
@@ -380,6 +381,40 @@ public class IssuesClientTests : IDisposable
Assert.Equal(new Uri(string.Format(expectedUri, _context.RepositoryOwner, _context.RepositoryName, issue.Number, "events")), issue.EventsUrl);
}
[IntegrationTest]
public async Task GetAllForCurrentContainsRepositoryData()
{
var issuesForCurrentUser = await _issuesClient.GetAllForCurrent();
foreach (var issue in issuesForCurrentUser)
{
Assert.Equal(Helper.UserName, issue.User.Login);
Assert.NotNull(issue.Repository);
}
}
[IntegrationTest]
public async Task GetAllForOwnedAndMemberRepositoriesContainsRepositoryData()
{
var issuesForOwnedAndMemberRepositories = await _issuesClient.GetAllForOwnedAndMemberRepositories();
foreach (var issue in issuesForOwnedAndMemberRepositories)
{
Assert.NotNull(issue.Repository);
}
}
[IntegrationTest]
public async Task GetAllForOrganizationContainsRepositoryData()
{
var issuesForOrganization = await _issuesClient.GetAllForOrganization(Helper.Organization);
foreach (var issue in issuesForOrganization)
{
Assert.NotNull(issue.Repository);
}
}
public void Dispose()
{
_context.Dispose();

View File

@@ -10,7 +10,7 @@ namespace Octokit
{
public Issue() { }
public Issue(Uri url, Uri htmlUrl, Uri commentsUrl, Uri eventsUrl, int number, ItemState state, string title, string body, User user, IReadOnlyList<Label> labels, User assignee, Milestone milestone, int comments, PullRequest pullRequest, DateTimeOffset? closedAt, DateTimeOffset createdAt, DateTimeOffset? updatedAt, int id, bool locked)
public Issue(Uri url, Uri htmlUrl, Uri commentsUrl, Uri eventsUrl, int number, ItemState state, string title, string body, User user, IReadOnlyList<Label> labels, User assignee, Milestone milestone, int comments, PullRequest pullRequest, DateTimeOffset? closedAt, DateTimeOffset createdAt, DateTimeOffset? updatedAt, int id, bool locked, Repository repository)
{
Id = id;
Url = url;
@@ -31,6 +31,7 @@ namespace Octokit
CreatedAt = createdAt;
UpdatedAt = updatedAt;
Locked = locked;
Repository = repository;
}
/// <summary>
@@ -121,10 +122,15 @@ namespace Octokit
public DateTimeOffset? UpdatedAt { get; protected set; }
/// <summary>
/// If the issue is locked or not
/// If the issue is locked or not.
/// </summary>
public bool Locked { get; protected set; }
/// <summary>
/// The repository the issue comes from.
/// </summary>
public Repository Repository { get; protected set; }
internal string DebuggerDisplay
{
get