Fix convention tests running for gists

This commit is contained in:
Marius Ungureanu
2014-02-26 04:11:27 +02:00
parent 6f3e3232ed
commit f3f2b9f132
6 changed files with 377 additions and 4 deletions
@@ -1,5 +1,6 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Reactive;
namespace Octokit.Reactive
{
@@ -16,6 +17,143 @@ namespace Octokit.Reactive
/// <param name="id">The id of the gist</param>
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get",
Justification = "Method makes a network request")]
IObservable<Gist> Get(string id);
IObservable<Gist> Get(string id);
/// <summary>
/// List the authenticated users gists or if called anonymously,
/// this will return all public gists
/// </summary>
/// <remarks>
/// http://developer.github.com/v3/gists/#list-gists
/// </remarks>
IObservable<Gist> GetAll();
/// <summary>
/// List the authenticated users gists or if called anonymously,
/// this will return all public gists
/// </summary>
/// <remarks>
/// http://developer.github.com/v3/gists/#list-gists
/// </remarks>
/// <param name="since">Only gists updated at or after this time are returned</param>
IObservable<Gist> GetAll(DateTimeOffset since);
/// <summary>
/// Lists all public gists
/// </summary>
/// <remarks>
/// http://developer.github.com/v3/gists/#list-gists
/// </remarks>
IObservable<Gist> GetAllPublic();
/// <summary>
/// Lists all public gists
/// </summary>
/// <remarks>
/// http://developer.github.com/v3/gists/#list-gists
/// </remarks>
/// <param name="since">Only gists updated at or after this time are returned</param>
IObservable<Gist> GetAllPublic(DateTimeOffset since);
/// <summary>
/// List the authenticated users starred gists
/// </summary>
/// <remarks>
/// http://developer.github.com/v3/gists/#list-gists
/// </remarks>
IObservable<Gist> GetAllStarred();
/// <summary>
/// List the authenticated users starred gists
/// </summary>
/// <remarks>
/// http://developer.github.com/v3/gists/#list-gists
/// </remarks>
/// <param name="since">Only gists updated at or after this time are returned</param>
IObservable<Gist> GetAllStarred(DateTimeOffset since);
/// <summary>
/// List a user's gists
/// </summary>
/// <remarks>
/// http://developer.github.com/v3/gists/#list-gists
/// </remarks>
/// <param name="user">The user</param>
IObservable<Gist> GetAllForUser(string user);
/// <summary>
/// List a user's gists
/// </summary>
/// <remarks>
/// http://developer.github.com/v3/gists/#list-gists
/// </remarks>
/// <param name="user">The user</param>
/// <param name="since">Only gists updated at or after this time are returned</param>
IObservable<Gist> GetAllForUser(string user, DateTimeOffset since);
/// <summary>
/// Creates a new gist
/// </summary>
/// <remarks>
/// http://developer.github.com/v3/gists/#create-a-gist
/// </remarks>
/// <param name="newGist">The new gist to create</param>
IObservable<Gist> Create(NewGist newGist);
/// <summary>
/// Creates a fork of a gist
/// </summary>
/// <remarks>
/// http://developer.github.com/v3/gists/#fork-a-gist
/// </remarks>
/// <param name="id">The id of the gist to fork</param>
IObservable<Gist> Fork(string id);
/// <summary>
/// Edits a gist
/// </summary>
/// <remarks>
/// http://developer.github.com/v3/gists/#delete-a-gist
/// </remarks>
/// <param name="id">The id of the gist</param>
/// <param name="gistUpdate">The update to the gist</param>
IObservable<Gist> Edit(string id, GistUpdate gistUpdate);
/// <summary>
/// Deletes a gist
/// </summary>
/// <remarks>
/// http://developer.github.com/v3/gists/#delete-a-gist
/// </remarks>
/// <param name="id">The id of the gist</param>
IObservable<Unit> Delete(string id);
/// <summary>
/// Stars a gist
/// </summary>
/// <remarks>
/// http://developer.github.com/v3/gists/#star-a-gist
/// </remarks>
/// <param name="id">The id of the gist</param>
IObservable<Unit> Star(string id);
/// <summary>
/// Unstars a gist
/// </summary>
/// <remarks>
/// http://developer.github.com/v3/gists/#unstar-a-gist
/// </remarks>
/// <param name="id">The id of the gist</param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Unstar")]
IObservable<Unit> Unstar(string id);
/// <summary>
/// Checks if the gist is starred
/// </summary>
/// <remarks>
/// http://developer.github.com/v3/gists/#check-if-a-gist-is-starred
/// </remarks>
/// <param name="id">The id of the gist</param>
IObservable<bool> IsStarred(string id);
}
}
@@ -1,17 +1,22 @@
using System;
using System.Reactive.Threading.Tasks;
using System.Reactive;
using System.Net;
using Octokit.Reactive.Internal;
namespace Octokit.Reactive
{
public class ObservableGistsClient : IObservableGistsClient
{
readonly IGistsClient _client;
readonly IConnection _connection;
public ObservableGistsClient(IGitHubClient client)
{
Ensure.ArgumentNotNull(client, "client");
_client = client.Gist;
_connection = client.Connection;
Comment = new ObservableGistCommentsClient(client);
}
@@ -31,5 +36,203 @@ namespace Octokit.Reactive
return _client.Get(id).ToObservable();
}
/// <summary>
/// Creates a new gist
/// </summary>
/// <remarks>
/// http://developer.github.com/v3/gists/#create-a-gist
/// </remarks>
/// <param name="newGist">The new gist to create</param>
public IObservable<Gist> Create(NewGist newGist)
{
Ensure.ArgumentNotNull(newGist, "newGist");
return _client.Create(newGist).ToObservable();
}
/// <summary>
/// Creates a fork of a gist
/// </summary>
/// <remarks>
/// http://developer.github.com/v3/gists/#fork-a-gist
/// </remarks>
/// <param name="id">The id of the gist to fork</param>
public IObservable<Gist> Fork(string id)
{
return _client.Fork(id).ToObservable();
}
/// <summary>
/// Deletes a gist
/// </summary>
/// <remarks>
/// http://developer.github.com/v3/gists/#delete-a-gist
/// </remarks>
/// <param name="id">The id of the gist</param>
public IObservable<Unit> Delete(string id)
{
Ensure.ArgumentNotNull(id, "id");
return _client.Delete(id).ToObservable();
}
/// <summary>
/// List the authenticated users gists or if called anonymously,
/// this will return all public gists
/// </summary>
/// <remarks>
/// http://developer.github.com/v3/gists/#list-gists
/// </remarks>
public IObservable<Gist> GetAll()
{
return _connection.GetAndFlattenAllPages<Gist>(ApiUrls.Gist());
}
/// <summary>
/// List the authenticated users gists or if called anonymously,
/// this will return all public gists
/// </summary>
/// <remarks>
/// http://developer.github.com/v3/gists/#list-gists
/// </remarks>
/// <param name="since">Only gists updated at or after this time are returned</param>
public IObservable<Gist> GetAll(DateTimeOffset since)
{
var request = new GistRequest(since);
return _connection.GetAndFlattenAllPages<Gist>(ApiUrls.Gist(), request.ToParametersDictionary());
}
/// <summary>
/// Lists all public gists
/// </summary>
/// <remarks>
/// http://developer.github.com/v3/gists/#list-gists
/// </remarks>
public IObservable<Gist> GetAllPublic()
{
return _connection.GetAndFlattenAllPages<Gist>(ApiUrls.PublicGists());
}
/// <summary>
/// Lists all public gists
/// </summary>
/// <remarks>
/// http://developer.github.com/v3/gists/#list-gists
/// </remarks>
/// <param name="since">Only gists updated at or after this time are returned</param>
public IObservable<Gist> GetAllPublic(DateTimeOffset since)
{
var request = new GistRequest(since);
return _connection.GetAndFlattenAllPages<Gist>(ApiUrls.PublicGists(), request.ToParametersDictionary());
}
/// <summary>
/// List the authenticated users starred gists
/// </summary>
/// <remarks>
/// http://developer.github.com/v3/gists/#list-gists
/// </remarks>
public IObservable<Gist> GetAllStarred()
{
return _connection.GetAndFlattenAllPages<Gist>(ApiUrls.StarredGists());
}
/// <summary>
/// List the authenticated users starred gists
/// </summary>
/// <remarks>
/// http://developer.github.com/v3/gists/#list-gists
/// </remarks>
/// <param name="since">Only gists updated at or after this time are returned</param>
public IObservable<Gist> GetAllStarred(DateTimeOffset since)
{
var request = new GistRequest(since);
return _connection.GetAndFlattenAllPages<Gist>(ApiUrls.StarredGists(), request.ToParametersDictionary());
}
/// <summary>
/// List a user's gists
/// </summary>
/// <remarks>
/// http://developer.github.com/v3/gists/#list-gists
/// </remarks>
/// <param name="user">The user</param>
public IObservable<Gist> GetAllForUser(string user)
{
Ensure.ArgumentNotNull(user, "user");
return _connection.GetAndFlattenAllPages<Gist>(ApiUrls.UsersGists(user));
}
/// <summary>
/// List a user's gists
/// </summary>
/// <remarks>
/// http://developer.github.com/v3/gists/#list-gists
/// </remarks>
/// <param name="user">The user</param>
/// <param name="since">Only gists updated at or after this time are returned</param>
public IObservable<Gist> GetAllForUser(string user, DateTimeOffset since)
{
Ensure.ArgumentNotNull(user, "user");
var request = new GistRequest(since);
return _connection.GetAndFlattenAllPages<Gist>(ApiUrls.UsersGists(user), request.ToParametersDictionary());
}
/// <summary>
/// Edits a gist
/// </summary>
/// <remarks>
/// http://developer.github.com/v3/gists/#delete-a-gist
/// </remarks>
/// <param name="id">The id of the gist</param>
/// <param name="gistUpdate">The update to the gist</param>
public IObservable<Gist> Edit(string id, GistUpdate gistUpdate)
{
Ensure.ArgumentNotNull(id, "id");
Ensure.ArgumentNotNull(gistUpdate, "gistUpdate");
return _client.Edit(id, gistUpdate).ToObservable();
}
/// <summary>
/// Stars a gist
/// </summary>
/// <remarks>
/// http://developer.github.com/v3/gists/#star-a-gist
/// </remarks>
/// <param name="id">The id of the gist</param>
public IObservable<Unit> Star(string id)
{
return _client.Star(id).ToObservable();
}
/// <summary>
/// Unstars a gist
/// </summary>
/// <remarks>
/// http://developer.github.com/v3/gists/#unstar-a-gist
/// </remarks>
/// <param name="id">The id of the gist</param>
public IObservable<Unit> Unstar(string id)
{
return _client.Unstar(id).ToObservable();
}
/// <summary>
/// Checks if the gist is starred
/// </summary>
/// <remarks>
/// http://developer.github.com/v3/gists/#check-if-a-gist-is-starred
/// </remarks>
/// <param name="id">The id of the gist</param>
public IObservable<bool> IsStarred(string id)
{
Ensure.ArgumentNotNullOrEmptyString(id, "id");
return _client.IsStarred(id).ToObservable();
}
}
}
+1 -1
View File
@@ -602,7 +602,7 @@ namespace Octokit
/// <returns></returns>
public static Uri Feeds()
{
return "feeds".FormatUri ();
return "feeds".FormatUri();
}
/// <summary>
+11 -1
View File
@@ -1,8 +1,10 @@
using System;
using Octokit.Internal;
using System.Diagnostics;
using System.Globalization;
namespace Octokit
{
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class GistRequest : RequestParameters
{
public GistRequest(DateTimeOffset since)
@@ -11,5 +13,13 @@ namespace Octokit
}
public DateTimeOffset Since { get; set; }
internal string DebuggerDisplay
{
get
{
return String.Format(CultureInfo.InvariantCulture, "Since: {0}", Since);
}
}
}
}
+11 -1
View File
@@ -1,9 +1,11 @@
using System;
using System.Collections.Generic;
using Octokit.Internal;
using System.Diagnostics;
using System.Globalization;
namespace Octokit
{
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class GistUpdate
{
public GistUpdate()
@@ -13,6 +15,14 @@ namespace Octokit
public string Description { get; set; }
public IDictionary<string, GistFileUpdate> Files { get; private set; }
internal string DebuggerDisplay
{
get
{
return String.Format(CultureInfo.InvariantCulture, "Description: {0}", Description);
}
}
}
public class GistFileUpdate
+12
View File
@@ -1,8 +1,12 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics;
using System;
using System.Globalization;
namespace Octokit
{
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class NewGist
{
public NewGist()
@@ -25,5 +29,13 @@ namespace Octokit
/// and value as Content
/// </summary>
public IDictionary<string, string> Files { get; private set; }
internal string DebuggerDisplay
{
get
{
return String.Format(CultureInfo.InvariantCulture, "Description: {0}", Description);
}
}
}
}