Files
Martin Scholz 72e30a7f90 Add reactions to issue, commit comment and review payload (#1405)
* add reactions to issue response payload

* add reactions to commit comment payload

* add reactions to review comment payload

* create tests for issue client

* tests for commitcomment client

* tests for pull request review comment

* change observable tests

* simplify strings

* remove unnecessary clients

* change integration tests to retrieve all reaction types

* create integration test for issue comment client

* fix merge conflicts

* fix merge conflicts

* gets tests passing again

* fix some reaction integration tests

* Fixup unit tests wth preview accepts header
Also applied preview header to a couple of repositoryId based calls that were added by another PR

* Fixup unit tests wth preview accepts header
Also applied preview header to a couple of repositoryId based calls that were added by another PR

* Rework reaction payload tests for IssueComments to handle Get, GetAllForIssue and GetAllForRepository calls

* [WIP] reaction payload tests

* Rework reaction payload tests for IssueComments to handle Get, GetAllForIssue and GetAllForRepository calls

* Rework reaction payload tests for Issues client

* Rework reaction payload tests for PullRequestReviews client

* Rework reaction payload tests for CommitComments client

* Revert "[WIP] reaction payload tests"

This reverts commit a6179b0f21a3ddfe36bfd3ae5eafae0e69b52252.
2016-07-08 20:29:08 +10:00
..
2016-05-20 19:14:36 +05:30
2016-01-21 07:31:32 +02:00
2016-01-21 07:31:32 +02:00
2016-03-29 17:42:33 +07:00
2016-03-29 17:43:06 +07:00
2016-04-03 23:04:46 +10:00
2016-01-25 10:26:36 +02:00
2016-06-08 15:06:39 +02:00
2016-03-29 17:43:16 +07:00
2016-04-13 18:26:02 -04:00
2016-03-29 17:43:27 +07:00
2016-06-04 23:35:23 +10:00

using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Text;
using System.Threading.Tasks;

namespace Octokit
{
    [DebuggerDisplay("{DebuggerDisplay,nq}")]
    public class Readme
    {
        readonly Lazy<Task<string>> htmlContent;

        public Readme() { }

        internal Readme(ReadmeResponse response, IApiConnection client)
        {
            Ensure.ArgumentNotNull(response, "response");
            Ensure.ArgumentNotNull(client, "client");

            Name = response.Name;
            Url = new Uri(response.Url);
            HtmlUrl = new Uri(response.HtmlUrl);
            if (response.Encoding.Equals("base64", StringComparison.OrdinalIgnoreCase))
            {
                var contentAsBytes = Convert.FromBase64String(response.Content);
                Content = Encoding.UTF8.GetString(contentAsBytes, 0, contentAsBytes.Length);
            }
            htmlContent = new Lazy<Task<string>>(async () => await client.GetHtml(Url).ConfigureAwait(false));
        }

        public Readme(Lazy<Task<string>> htmlContent, string content, string name, Uri htmlUrl, Uri url)
        {
            this.htmlContent = htmlContent;
            Content = content;
            Name = name;
            HtmlUrl = htmlUrl;
            Url = url;
        }

        public string Content { get; private set; }
        public string Name { get; private set; }
        public Uri HtmlUrl { get; private set; }
        public Uri Url { get; private set; }

        [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
            Justification = "Makes a network request")]
        public Task<string> GetHtmlContent()
        {
            return htmlContent.Value;
        }

        internal string DebuggerDisplay
        {
            get
            {
                return string.Format(CultureInfo.InvariantCulture, "Name: {0} ", Name);
            }
        }
    }
}