mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-04 19:26:51 +00:00
This commit is contained in:
committed by
Ryan Gribble
parent
5e751a6c38
commit
47c38bfd8e
@@ -556,6 +556,8 @@ namespace Octokit.Tests.Clients
|
||||
{"CheckRunEvent", typeof(CheckRunEventPayload)},
|
||||
{"CheckSuiteEvent", typeof(CheckSuiteEventPayload)},
|
||||
{"CommitCommentEvent", typeof(CommitCommentPayload)},
|
||||
{"CreateEvent", typeof(CreateEventPayload)},
|
||||
{"DeleteEvent", typeof(DeleteEventPayload)},
|
||||
{"ForkEvent", typeof(ForkEventPayload)},
|
||||
{"IssueCommentEvent", typeof(IssueCommentPayload)},
|
||||
{"IssuesEvent", typeof(IssueEventPayload)},
|
||||
@@ -623,6 +625,54 @@ namespace Octokit.Tests.Clients
|
||||
Assert.Equal(1337, payload.Comment.Id);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DeserializesCreateEventCorrectly()
|
||||
{
|
||||
var jsonObj = new JsonObject
|
||||
{
|
||||
{ "type", "CreateEvent" },
|
||||
{
|
||||
"payload", new
|
||||
{
|
||||
@ref = "master",
|
||||
ref_type = "branch",
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var client = GetTestingEventsClient(jsonObj);
|
||||
var activities = await client.GetAll();
|
||||
Assert.Equal(1, activities.Count);
|
||||
|
||||
var payload = activities.FirstOrDefault().Payload as CreateEventPayload;
|
||||
Assert.Equal("master", payload.Ref);
|
||||
Assert.Equal(RefType.Branch, payload.RefType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DeserializesDeleteEventCorrectly()
|
||||
{
|
||||
var jsonObj = new JsonObject
|
||||
{
|
||||
{ "type", "DeleteEvent" },
|
||||
{
|
||||
"payload", new
|
||||
{
|
||||
@ref = "master",
|
||||
ref_type = "branch",
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var client = GetTestingEventsClient(jsonObj);
|
||||
var activities = await client.GetAll();
|
||||
Assert.Equal(1, activities.Count);
|
||||
|
||||
var payload = activities.FirstOrDefault().Payload as DeleteEventPayload;
|
||||
Assert.Equal("master", payload.Ref);
|
||||
Assert.Equal(RefType.Branch, payload.RefType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DeserializesForkEventCorrectly()
|
||||
{
|
||||
|
||||
@@ -212,6 +212,10 @@ namespace Octokit.Internal
|
||||
return typeof(CheckSuiteEventPayload);
|
||||
case "CommitCommentEvent":
|
||||
return typeof(CommitCommentPayload);
|
||||
case "CreateEvent":
|
||||
return typeof(CreateEventPayload);
|
||||
case "DeleteEvent":
|
||||
return typeof(DeleteEventPayload);
|
||||
case "ForkEvent":
|
||||
return typeof(ForkEventPayload);
|
||||
case "IssueCommentEvent":
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||
public class CreateEventPayload : ActivityPayload
|
||||
{
|
||||
public string Ref { get; protected set; }
|
||||
|
||||
public StringEnum<RefType> RefType { get; protected set; }
|
||||
|
||||
public string MasterBranch { get; protected set; }
|
||||
|
||||
public string Description { get; protected set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||
public class DeleteEventPayload : ActivityPayload
|
||||
{
|
||||
public string Ref { get; protected set; }
|
||||
|
||||
public StringEnum<RefType> RefType { get; protected set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using Octokit.Internal;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the type of object created or deleted
|
||||
/// </summary>
|
||||
public enum RefType
|
||||
{
|
||||
/// <summary>
|
||||
/// The object is of type repository
|
||||
/// </summary>
|
||||
[Parameter(Value = "repository")]
|
||||
Repository,
|
||||
|
||||
/// <summary>
|
||||
/// The object is of type branch
|
||||
/// </summary>
|
||||
[Parameter(Value = "branch")]
|
||||
Branch,
|
||||
|
||||
/// <summary>
|
||||
/// The object is of type tag
|
||||
/// </summary>
|
||||
[Parameter(Value = "tag")]
|
||||
Tag
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user