Skip to content

Commit

Permalink
Add ProjectCard property to Issue Events model (#2102)
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim Lobanov authored Feb 24, 2020
1 parent 0074e76 commit fe6639f
Show file tree
Hide file tree
Showing 13 changed files with 173 additions and 61 deletions.
8 changes: 4 additions & 4 deletions Octokit.Reactive/Clients/IObservableIssuesEventsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public interface IObservableIssuesEventsClient
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="number">The issue number</param>
IObservable<EventInfo> GetAllForIssue(string owner, string name, int number);
IObservable<IssueEvent> GetAllForIssue(string owner, string name, int number);

/// <summary>
/// Gets all events for the issue.
Expand All @@ -30,7 +30,7 @@ public interface IObservableIssuesEventsClient
/// </remarks>
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="number">The issue number</param>
IObservable<EventInfo> GetAllForIssue(long repositoryId, int number);
IObservable<IssueEvent> GetAllForIssue(long repositoryId, int number);

/// <summary>
/// Gets all events for the issue.
Expand All @@ -42,7 +42,7 @@ public interface IObservableIssuesEventsClient
/// <param name="name">The name of the repository</param>
/// <param name="number">The issue number</param>
/// <param name="options">Options for changing the API response</param>
IObservable<EventInfo> GetAllForIssue(string owner, string name, int number, ApiOptions options);
IObservable<IssueEvent> GetAllForIssue(string owner, string name, int number, ApiOptions options);

/// <summary>
/// Gets all events for the issue.
Expand All @@ -53,7 +53,7 @@ public interface IObservableIssuesEventsClient
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="number">The issue number</param>
/// <param name="options">Options for changing the API response</param>
IObservable<EventInfo> GetAllForIssue(long repositoryId, int number, ApiOptions options);
IObservable<IssueEvent> GetAllForIssue(long repositoryId, int number, ApiOptions options);

/// <summary>
/// Gets all events for the repository.
Expand Down
12 changes: 6 additions & 6 deletions Octokit.Reactive/Clients/ObservableIssuesEventsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public ObservableIssuesEventsClient(IGitHubClient client)
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="number">The issue number</param>
public IObservable<EventInfo> GetAllForIssue(string owner, string name, int number)
public IObservable<IssueEvent> GetAllForIssue(string owner, string name, int number)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Expand All @@ -48,7 +48,7 @@ public IObservable<EventInfo> GetAllForIssue(string owner, string name, int numb
/// </remarks>
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="number">The issue number</param>
public IObservable<EventInfo> GetAllForIssue(long repositoryId, int number)
public IObservable<IssueEvent> GetAllForIssue(long repositoryId, int number)
{
return GetAllForIssue(repositoryId, number, ApiOptions.None);
}
Expand All @@ -63,13 +63,13 @@ public IObservable<EventInfo> GetAllForIssue(long repositoryId, int number)
/// <param name="name">The name of the repository</param>
/// <param name="number">The issue number</param>
/// <param name="options">Options for changing the API response</param>
public IObservable<EventInfo> GetAllForIssue(string owner, string name, int number, ApiOptions options)
public IObservable<IssueEvent> GetAllForIssue(string owner, string name, int number, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<EventInfo>(ApiUrls.IssuesEvents(owner, name, number), options);
return _connection.GetAndFlattenAllPages<IssueEvent>(ApiUrls.IssuesEvents(owner, name, number), options);
}

/// <summary>
Expand All @@ -81,11 +81,11 @@ public IObservable<EventInfo> GetAllForIssue(string owner, string name, int numb
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="number">The issue number</param>
/// <param name="options">Options for changing the API response</param>
public IObservable<EventInfo> GetAllForIssue(long repositoryId, int number, ApiOptions options)
public IObservable<IssueEvent> GetAllForIssue(long repositoryId, int number, ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<EventInfo>(ApiUrls.IssuesEvents(repositoryId, number), options);
return _connection.GetAndFlattenAllPages<IssueEvent>(ApiUrls.IssuesEvents(repositoryId, number), options);
}

/// <summary>
Expand Down
8 changes: 4 additions & 4 deletions Octokit.Tests/Clients/IssueTimelineClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public async Task RequestsTheCorrectUrl()
connection.Received().GetAll<TimelineEventInfo>(
Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/timeline"),
Arg.Any<Dictionary<string, string>>(),
"application/vnd.github.mockingbird-preview",
"application/vnd.github.mockingbird-preview,application/vnd.github.starfox-preview",
Arg.Any<ApiOptions>());
}

Expand All @@ -46,7 +46,7 @@ public async Task RequestsTheCorrectUrlWithApiOptions()
connection.Received().GetAll<TimelineEventInfo>(
Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/timeline"),
Arg.Any<Dictionary<string, string>>(),
"application/vnd.github.mockingbird-preview",
"application/vnd.github.mockingbird-preview,application/vnd.github.starfox-preview",
Arg.Is<ApiOptions>(ao => ao.PageSize == 30));
}

Expand All @@ -61,7 +61,7 @@ public async Task RequestsTheCorrectUrlWithRepositoryId()
connection.Received().GetAll<TimelineEventInfo>(
Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/timeline"),
Arg.Any<Dictionary<string, string>>(),
"application/vnd.github.mockingbird-preview",
"application/vnd.github.mockingbird-preview,application/vnd.github.starfox-preview",
Arg.Any<ApiOptions>());
}

Expand All @@ -76,7 +76,7 @@ public async Task RequestsTheCorrectUrlWithRepositoryIdAndApiOptions()
connection.Received().GetAll<TimelineEventInfo>(
Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/timeline"),
Arg.Any<Dictionary<string, string>>(),
"application/vnd.github.mockingbird-preview",
"application/vnd.github.mockingbird-preview,application/vnd.github.starfox-preview",
Arg.Is<ApiOptions>(ao => ao.PageSize == 30));
}

Expand Down
21 changes: 10 additions & 11 deletions Octokit.Tests/Clients/IssuesEventsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ public async Task RequestsCorrectUrl()
var client = new IssuesEventsClient(connection);

await client.GetAllForIssue("fake", "repo", 42);

connection.Received().GetAll<EventInfo>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/events"), Args.ApiOptions);
connection.Received().GetAll<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/events"), null, "application/vnd.github.starfox-preview", Args.ApiOptions);
}

[Fact]
Expand All @@ -38,7 +37,7 @@ public async Task RequestsCorrectUrlWithRepositoryId()

await client.GetAllForIssue(1, 42);

connection.Received().GetAll<EventInfo>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/events"), Args.ApiOptions);
connection.Received().GetAll<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/events"), null, "application/vnd.github.starfox-preview", Args.ApiOptions);
}

[Fact]
Expand All @@ -56,7 +55,7 @@ public async Task RequestsCorrectUrlWithApiOptions()

await client.GetAllForIssue("fake", "repo", 42, options);

connection.Received().GetAll<EventInfo>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/events"), options);
connection.Received().GetAll<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/events"), null, "application/vnd.github.starfox-preview", options);
}

[Fact]
Expand All @@ -74,7 +73,7 @@ public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions()

await client.GetAllForIssue(1, 42, options);

connection.Received().GetAll<EventInfo>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/events"), options);
connection.Received().GetAll<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/events"), null, "application/vnd.github.starfox-preview", options);
}

[Fact]
Expand Down Expand Up @@ -107,7 +106,7 @@ public async Task RequestsCorrectUrl()

await client.GetAllForRepository("fake", "repo");

connection.Received().GetAll<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/events"), Args.ApiOptions);
connection.Received().GetAll<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/events"), null, "application/vnd.github.starfox-preview", Args.ApiOptions);
}

[Fact]
Expand All @@ -118,7 +117,7 @@ public async Task RequestsCorrectUrlWithRepositoryId()

await client.GetAllForRepository(1);

connection.Received().GetAll<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/events"), Args.ApiOptions);
connection.Received().GetAll<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/events"), null, "application/vnd.github.starfox-preview", Args.ApiOptions);
}

[Fact]
Expand All @@ -136,7 +135,7 @@ public async Task RequestsCorrectUrlWithApiOptions()

await client.GetAllForRepository("fake", "repo", options);

connection.Received().GetAll<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/events"), options);
connection.Received().GetAll<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/events"), null, "application/vnd.github.starfox-preview", options);
}

[Fact]
Expand All @@ -154,7 +153,7 @@ public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions()

await client.GetAllForRepository(1, options);

connection.Received().GetAll<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/events"), options);
connection.Received().GetAll<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/events"), null, "application/vnd.github.starfox-preview", options);
}

[Fact]
Expand Down Expand Up @@ -187,7 +186,7 @@ public void RequestsCorrectUrl()

client.Get("fake", "repo", 42);

connection.Received().Get<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/events/42"));
connection.Received().Get<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/events/42"), null, "application/vnd.github.starfox-preview");
}

[Fact]
Expand All @@ -198,7 +197,7 @@ public void RequestsCorrectUrlWithRepositoryId()

client.Get(1, 42);

connection.Received().Get<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/events/42"));
connection.Received().Get<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/events/42"), null, "application/vnd.github.starfox-preview");
}

[Fact]
Expand Down
32 changes: 16 additions & 16 deletions Octokit.Tests/Reactive/ObservableIssuesEventsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,53 +26,53 @@ public class TheGetForIssueMethod
[Fact]
public async Task RequestsCorrectUrl()
{
var result = new List<EventInfo> { new EventInfo() };
var result = new List<IssueEvent> { new IssueEvent() };

var connection = Substitute.For<IConnection>();
var gitHubClient = new GitHubClient(connection);
var client = new ObservableIssuesEventsClient(gitHubClient);

IApiResponse<List<EventInfo>> response = new ApiResponse<List<EventInfo>>(
IApiResponse<List<IssueEvent>> response = new ApiResponse<List<IssueEvent>>(
new Response
{
ApiInfo = new ApiInfo(new Dictionary<string, Uri>(), new List<string>(), new List<string>(), "etag", new RateLimit()),
}, result);
gitHubClient.Connection.Get<List<EventInfo>>(Args.Uri, Args.EmptyDictionary, null)
gitHubClient.Connection.Get<List<IssueEvent>>(Args.Uri, Args.EmptyDictionary, null)
.Returns(Task.FromResult(response));

var eventInfos = await client.GetAllForIssue("fake", "repo", 42).ToList();

connection.Received().Get<List<EventInfo>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/events"), Args.EmptyDictionary, null);
connection.Received().Get<List<IssueEvent>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/events"), Args.EmptyDictionary, null);
Assert.Equal(1, eventInfos.Count);
}

[Fact]
public async Task RequestsCorrectUrlWithRepositoryId()
{
var result = new List<EventInfo> { new EventInfo() };
var result = new List<IssueEvent> { new IssueEvent() };

var connection = Substitute.For<IConnection>();
var gitHubClient = new GitHubClient(connection);
var client = new ObservableIssuesEventsClient(gitHubClient);

IApiResponse<List<EventInfo>> response = new ApiResponse<List<EventInfo>>(
IApiResponse<List<IssueEvent>> response = new ApiResponse<List<IssueEvent>>(
new Response
{
ApiInfo = new ApiInfo(new Dictionary<string, Uri>(), new List<string>(), new List<string>(), "etag", new RateLimit()),
}, result);
gitHubClient.Connection.Get<List<EventInfo>>(Args.Uri, Args.EmptyDictionary, null)
gitHubClient.Connection.Get<List<IssueEvent>>(Args.Uri, Args.EmptyDictionary, null)
.Returns(Task.FromResult(response));

var eventInfos = await client.GetAllForIssue(1, 42).ToList();

connection.Received().Get<List<EventInfo>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/events"), Args.EmptyDictionary, null);
connection.Received().Get<List<IssueEvent>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/events"), Args.EmptyDictionary, null);
Assert.Equal(1, eventInfos.Count);
}

[Fact]
public async Task RequestsCorrectUrlWithApiOptions()
{
var result = new List<EventInfo> { new EventInfo() };
var result = new List<IssueEvent> { new IssueEvent() };

var connection = Substitute.For<IConnection>();
var gitHubClient = new GitHubClient(connection);
Expand All @@ -85,24 +85,24 @@ public async Task RequestsCorrectUrlWithApiOptions()
PageSize = 1
};

IApiResponse<List<EventInfo>> response = new ApiResponse<List<EventInfo>>(
IApiResponse<List<IssueEvent>> response = new ApiResponse<List<IssueEvent>>(
new Response
{
ApiInfo = new ApiInfo(new Dictionary<string, Uri>(), new List<string>(), new List<string>(), "etag", new RateLimit()),
}, result);
gitHubClient.Connection.Get<List<EventInfo>>(Args.Uri, Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null)
gitHubClient.Connection.Get<List<IssueEvent>>(Args.Uri, Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null)
.Returns(Task.FromResult(response));

var eventInfos = await client.GetAllForIssue("fake", "repo", 42, options).ToList();

connection.Received().Get<List<EventInfo>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/events"), Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null);
connection.Received().Get<List<IssueEvent>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/events"), Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null);
Assert.Equal(1, eventInfos.Count);
}

[Fact]
public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions()
{
var result = new List<EventInfo> { new EventInfo() };
var result = new List<IssueEvent> { new IssueEvent() };

var connection = Substitute.For<IConnection>();
var gitHubClient = new GitHubClient(connection);
Expand All @@ -115,17 +115,17 @@ public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions()
PageSize = 1
};

IApiResponse<List<EventInfo>> response = new ApiResponse<List<EventInfo>>(
IApiResponse<List<IssueEvent>> response = new ApiResponse<List<IssueEvent>>(
new Response
{
ApiInfo = new ApiInfo(new Dictionary<string, Uri>(), new List<string>(), new List<string>(), "etag", new RateLimit()),
}, result);
gitHubClient.Connection.Get<List<EventInfo>>(Args.Uri, Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null)
gitHubClient.Connection.Get<List<IssueEvent>>(Args.Uri, Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null)
.Returns(Task.FromResult(response));

var eventInfos = await client.GetAllForIssue(1, 42, options).ToList();

connection.Received().Get<List<EventInfo>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/events"), Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null);
connection.Received().Get<List<IssueEvent>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/events"), Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null);
Assert.Equal(1, eventInfos.Count);
}

Expand Down
Loading

0 comments on commit fe6639f

Please sign in to comment.