diff --git a/Octokit.Tests/Clients/EventsClientTests.cs b/Octokit.Tests/Clients/EventsClientTests.cs index fb38f29252..29d19660aa 100644 --- a/Octokit.Tests/Clients/EventsClientTests.cs +++ b/Octokit.Tests/Clients/EventsClientTests.cs @@ -565,6 +565,7 @@ public async Task EnsuresNonNullArguments() {"PullRequestReviewEvent", typeof(PullRequestReviewEventPayload)}, {"PullRequestReviewCommentEvent", typeof(PullRequestCommentPayload)}, {"PushEvent", typeof(PushEventPayload)}, + {"ReleaseEvent", typeof(ReleaseEventPayload)}, {"StatusEvent", typeof(StatusEventPayload)}, {"WatchEvent", typeof(StarredEventPayload)}, {"unknown", typeof(ActivityPayload)} @@ -901,6 +902,37 @@ public async Task DeserializesPushEventCorrectly() Assert.Equal("message", payload.Commits.FirstOrDefault().Message); } + [Fact] + public async Task DeserializesReleaseEventCorrectly() + { + var jsonObj = new JsonObject + { + { "type", "ReleaseEvent" }, + { + "payload", new + { + action = "published", + release = new + { + id = 17372790, + tag_name = "0.0.1", + prerelease = false, + } + } + } + }; + + var client = GetTestingEventsClient(jsonObj); + var activities = await client.GetAll(); + var activity = Assert.Single(activities); + var payload = Assert.IsType(activity.Payload); + + Assert.Equal("published", payload.Action); + Assert.Equal(17372790, payload.Release.Id); + Assert.Equal("0.0.1", payload.Release.TagName); + Assert.False(payload.Release.Prerelease); + } + [Fact] public async Task DeserializesStatusEventCorrectly() { diff --git a/Octokit/Http/SimpleJsonSerializer.cs b/Octokit/Http/SimpleJsonSerializer.cs index 9070d608b2..b4bb555828 100644 --- a/Octokit/Http/SimpleJsonSerializer.cs +++ b/Octokit/Http/SimpleJsonSerializer.cs @@ -242,6 +242,8 @@ private static Type GetPayloadType(string activityType) return typeof(PullRequestCommentPayload); case "PushEvent": return typeof(PushEventPayload); + case "ReleaseEvent": + return typeof(ReleaseEventPayload); case "StatusEvent": return typeof(StatusEventPayload); case "WatchEvent": diff --git a/Octokit/Models/Response/ActivityPayloads/ReleaseEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/ReleaseEventPayload.cs new file mode 100644 index 0000000000..ffaac4cc76 --- /dev/null +++ b/Octokit/Models/Response/ActivityPayloads/ReleaseEventPayload.cs @@ -0,0 +1,12 @@ +using System.Diagnostics; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class ReleaseEventPayload : ActivityPayload + { + public string Action { get; protected set; } + + public Release Release { get; protected set; } + } +}