Add test to ensure we can deserialize an issue comment with the reactions object

This commit is contained in:
Henrik Andersson
2016-06-04 21:33:14 +10:00
parent 5010538d68
commit f6ed0a3e22
@@ -250,5 +250,51 @@ namespace Octokit.Tests.Clients
Assert.Equal(issueResponseJson, response.HttpResponse.Body);
Assert.Equal(1, response.Body.Id);
}
[Fact]
public void CanDeserializeIssueCommentWithReactions()
{
const string issueResponseJson =
"{\"id\": 1," +
"\"url\": \"https://api.github.com/repos/octocat/Hello-World/issues/comments/1\"," +
"\"html_url\": \"https://github.com/octocat/Hello-World/issues/1347#issuecomment-1\"," +
"\"body\": \"Me too\"," +
"\"user\": {" +
"\"login\": \"octocat\"," +
"\"id\": 1," +
"\"avatar_url\": \"https://github.com/images/error/octocat_happy.gif\"," +
"\"gravatar_id\": \"somehexcode\"," +
"\"url\": \"https://api.github.com/users/octocat\"" +
"}," +
"\"created_at\": \"2011-04-14T16:00:49Z\"," +
"\"updated_at\": \"2011-04-14T16:00:49Z\"," +
"\"reactions\": {" +
"\"total_count\": 5," +
"\"+1\": 3," +
"\"-1\": 1," +
"\"laugh\": 0," +
"\"confused\": 0," +
"\"heart\": 1," +
"\"hooray\": 0," +
"\"url\": \"https://api.github.com/repos/octocat/Hello-World/issues/comments/1/reactions\"" +
"}" +
"}";
var httpResponse = new Response(
HttpStatusCode.OK,
issueResponseJson,
new Dictionary<string, string>(),
"application/json");
var jsonPipeline = new JsonHttpPipeline();
var response = jsonPipeline.DeserializeResponse<IssueComment>(httpResponse);
Assert.NotNull(response.Body);
Assert.Equal(issueResponseJson, response.HttpResponse.Body);
Assert.Equal(1, response.Body.Id);
Assert.NotNull(response.Body.Reactions);
Assert.Equal(5, response.Body.Reactions.TotalCount);
Assert.Equal(3, response.Body.Reactions.Plus1);
}
}
}