Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup, conistency, and RT unit tests #54

Merged
merged 3 commits into from
Oct 4, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Octokit.Reactive/Clients/ObservableAuthorizationsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,42 @@ namespace Octokit.Reactive.Clients
{
public class ObservableAuthorizationsClient : IObservableAuthorizationsClient
{
readonly IAuthorizationsClient client;
readonly IAuthorizationsClient _client;

public ObservableAuthorizationsClient(IAuthorizationsClient client)
{
Ensure.ArgumentNotNull(client, "client");

this.client = client;
_client = client;
}

public IObservable<IReadOnlyCollection<Authorization>> GetAll()
public IObservable<IReadOnlyList<Authorization>> GetAll()
{
return client.GetAll().ToObservable();
return _client.GetAll().ToObservable();
}

public IObservable<Authorization> Get(int id)
{
return client.Get(id).ToObservable();
return _client.Get(id).ToObservable();
}

public IObservable<Authorization> Update(int id, AuthorizationUpdate authorization)
{
Ensure.ArgumentNotNull(authorization, "authorization");

return client.Update(id, authorization).ToObservable();
return _client.Update(id, authorization).ToObservable();
}

public IObservable<Authorization> Create(AuthorizationUpdate authorization)
{
Ensure.ArgumentNotNull(authorization, "authorization");

return client.Create(authorization).ToObservable();
return _client.Create(authorization).ToObservable();
}

public IObservable<Unit> Delete(int id)
{
return client.Delete(id).ToObservable();
return _client.Delete(id).ToObservable();
}
}
}
6 changes: 3 additions & 3 deletions Octokit.Reactive/Clients/ObservableAutoCompleteClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ namespace Octokit.Reactive.Clients
{
public class ObservableAutoCompleteClient : IObservableAutoCompleteClient
{
readonly IAutoCompleteClient client;
readonly IAutoCompleteClient _client;

public ObservableAutoCompleteClient(IAutoCompleteClient client)
{
Ensure.ArgumentNotNull(client, "client");

this.client = client;
_client = client;
}

public IObservable<IReadOnlyDictionary<string, Uri>> GetEmojis()
{
return client.GetEmojis().ToObservable();
return _client.GetEmojis().ToObservable();
}
}
}
14 changes: 7 additions & 7 deletions Octokit.Reactive/Clients/ObservableOrganizationsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@ namespace Octokit.Reactive.Clients
{
public class ObservableOrganizationsClient : IObservableOrganizationsClient
{
readonly IOrganizationsClient client;
readonly IOrganizationsClient _client;

public ObservableOrganizationsClient(IOrganizationsClient client)
{
Ensure.ArgumentNotNull(client, "client");

this.client = client;
_client = client;
}

public IObservable<Organization> Get(string org)
{
Ensure.ArgumentNotNullOrEmptyString(org, "org");

return client.Get(org).ToObservable();
return _client.Get(org).ToObservable();
}

public IObservable<IReadOnlyCollection<Organization>> GetAllForCurrent()
public IObservable<IReadOnlyList<Organization>> GetAllForCurrent()
{
return client.GetAllForCurrent().ToObservable();
return _client.GetAllForCurrent().ToObservable();
}

public IObservable<IReadOnlyCollection<Organization>> GetAll(string user)
public IObservable<IReadOnlyList<Organization>> GetAll(string user)
{
Ensure.ArgumentNotNullOrEmptyString(user, "user");

return client.GetAll(user).ToObservable();
return _client.GetAll(user).ToObservable();
}
}
}
20 changes: 10 additions & 10 deletions Octokit.Reactive/Clients/ObservableRepositoriesClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,48 @@ namespace Octokit.Reactive.Clients
{
public class ObservableRepositoriesClient : IObservableRepositoriesClient
{
readonly IRepositoriesClient client;
readonly IRepositoriesClient _client;

public ObservableRepositoriesClient(IRepositoriesClient client)
{
Ensure.ArgumentNotNull(client, "client");

this.client = client;
_client = client;
}

public IObservable<Repository> Get(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");

return client.Get(owner, name).ToObservable();
return _client.Get(owner, name).ToObservable();
}

public IObservable<IReadOnlyCollection<Repository>> GetAllForCurrent()
public IObservable<IReadOnlyList<Repository>> GetAllForCurrent()
{
return client.GetAllForCurrent().ToObservable();
return _client.GetAllForCurrent().ToObservable();
}

public IObservable<IReadOnlyCollection<Repository>> GetAllForUser(string login)
public IObservable<IReadOnlyList<Repository>> GetAllForUser(string login)
{
Ensure.ArgumentNotNullOrEmptyString(login, "login");

return client.GetAllForUser(login).ToObservable();
return _client.GetAllForUser(login).ToObservable();
}

public IObservable<IReadOnlyCollection<Repository>> GetAllForOrg(string organization)
public IObservable<IReadOnlyList<Repository>> GetAllForOrg(string organization)
{
Ensure.ArgumentNotNullOrEmptyString(organization, "organization");

return client.GetAllForOrg(organization).ToObservable();
return _client.GetAllForOrg(organization).ToObservable();
}

public IObservable<Readme> GetReadme(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");

return client.GetReadme(owner, name).ToObservable();
return _client.GetReadme(owner, name).ToObservable();
}
}
}
20 changes: 10 additions & 10 deletions Octokit.Reactive/Clients/ObservableSshKeysClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,49 @@ namespace Octokit.Reactive.Clients
{
public class ObservableSshKeysClient : IObservableSshKeysClient
{
readonly ISshKeysClient client;
readonly ISshKeysClient _client;

public ObservableSshKeysClient(ISshKeysClient client)
{
Ensure.ArgumentNotNull(client, "client");

this.client = client;
_client = client;
}

public IObservable<SshKey> Get(int id)
{
return client.Get(id).ToObservable();
return _client.Get(id).ToObservable();
}

public IObservable<IReadOnlyCollection<SshKey>> GetAll(string user)
public IObservable<IReadOnlyList<SshKey>> GetAll(string user)
{
Ensure.ArgumentNotNullOrEmptyString(user, "user");

return client.GetAll(user).ToObservable();
return _client.GetAll(user).ToObservable();
}

public IObservable<IReadOnlyCollection<SshKey>> GetAllForCurrent()
public IObservable<IReadOnlyList<SshKey>> GetAllForCurrent()
{
return client.GetAllForCurrent().ToObservable();
return _client.GetAllForCurrent().ToObservable();
}

public IObservable<SshKey> Create(SshKeyUpdate key)
{
Ensure.ArgumentNotNull(key, "key");

return client.Create(key).ToObservable();
return _client.Create(key).ToObservable();
}

public IObservable<SshKey> Update(int id, SshKeyUpdate key)
{
Ensure.ArgumentNotNull(key, "key");

return client.Update(id, key).ToObservable();
return _client.Update(id, key).ToObservable();
}

public IObservable<Unit> Delete(int id)
{
return client.Delete(id).ToObservable();
return _client.Delete(id).ToObservable();
}
}
}
2 changes: 1 addition & 1 deletion Octokit.Reactive/Clients/ObservableUsersClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public ObservableUsersClient(IUsersClient client)
{
Ensure.ArgumentNotNull(client, "client");

this._client = client;
_client = client;
}

public IObservable<User> Get(string login)
Expand Down
2 changes: 1 addition & 1 deletion Octokit.Reactive/IObservableAuthorizationsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public interface IObservableAuthorizationsClient
{
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
Justification = "It's an API call, so it's not a property.")]
IObservable<IReadOnlyCollection<Authorization>> GetAll();
IObservable<IReadOnlyList<Authorization>> GetAll();
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get",
Justification = "It's fiiiine. It's fine. Trust us.")]
IObservable<Authorization> Get(int id);
Expand Down
4 changes: 2 additions & 2 deletions Octokit.Reactive/IObservableOrganizationsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ public interface IObservableOrganizationsClient
/// <returns></returns>
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
Justification = "Method makes a network request")]
IObservable<IReadOnlyCollection<Organization>> GetAllForCurrent();
IObservable<IReadOnlyList<Organization>> GetAllForCurrent();

/// <summary>
/// Returns all the organizations for the specified user
/// </summary>
/// <param name="user"></param>
/// <returns></returns>
IObservable<IReadOnlyCollection<Organization>> GetAll(string user);
IObservable<IReadOnlyList<Organization>> GetAll(string user);
}
}
6 changes: 3 additions & 3 deletions Octokit.Reactive/IObservableRepositoriesClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public interface IObservableRepositoriesClient
/// <returns>A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>.</returns>
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
Justification = "Makes a network request")]
IObservable<IReadOnlyCollection<Repository>> GetAllForCurrent();
IObservable<IReadOnlyList<Repository>> GetAllForCurrent();

/// <summary>
/// Retrieves every <see cref="Repository"/> that belongs to the specified user.
Expand All @@ -36,7 +36,7 @@ public interface IObservableRepositoriesClient
/// <returns>A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>.</returns>
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
Justification = "Makes a network request")]
IObservable<IReadOnlyCollection<Repository>> GetAllForUser(string login);
IObservable<IReadOnlyList<Repository>> GetAllForUser(string login);

/// <summary>
/// Retrieves every <see cref="Repository"/> that belongs to the specified organization.
Expand All @@ -47,7 +47,7 @@ public interface IObservableRepositoriesClient
/// <returns>A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>.</returns>
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
Justification = "Makes a network request")]
IObservable<IReadOnlyCollection<Repository>> GetAllForOrg(string organization);
IObservable<IReadOnlyList<Repository>> GetAllForOrg(string organization);

/// <summary>
/// Returns the HTML rendered README.
Expand Down
4 changes: 2 additions & 2 deletions Octokit.Reactive/IObservableSshKeysClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public interface IObservableSshKeysClient
/// </summary>
/// <param name="user">The login of the user.</param>
/// <returns>A <see cref="IReadOnlyPagedCollection{SshKey}"/> of <see cref="SshKey"/>.</returns>
IObservable<IReadOnlyCollection<SshKey>> GetAll(string user);
IObservable<IReadOnlyList<SshKey>> GetAll(string user);

/// <summary>
/// Retrieves the <see cref="SshKey"/> for the specified id.
Expand All @@ -29,7 +29,7 @@ public interface IObservableSshKeysClient
/// <returns>A <see cref="IReadOnlyPagedCollection{SshKey}"/> of <see cref="SshKey"/>.</returns>
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
Justification = "Makes a network request")]
IObservable<IReadOnlyCollection<SshKey>> GetAllForCurrent();
IObservable<IReadOnlyList<SshKey>> GetAllForCurrent();

/// <summary>
/// Update the specified <see cref="UserUpdate"/>.
Expand Down
4 changes: 2 additions & 2 deletions Octokit.msbuild
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</Target>

<Target Name="RunRTUnitTests" DependsOnTargets="Build">
<xunit Assembly=".\OctokitRT.Tests\bin\$(Configuration)\OctokitRT.Tests.dll" Xml="OctokitRT.Tests.results.xml" />
<xunit Assembly=".\Octokit.Tests\bin\$(Configuration)\OctokitRT.Tests.dll" Xml="OctokitRT.Tests.results.xml" />
</Target>

<Target Name="RunIntegrationTests" DependsOnTargets="Build; DoNotSkipIntegrationTests; SkipIntegrationTests" />
Expand All @@ -31,5 +31,5 @@
<Warning Text ="The integration tests were skipped because the OCTOKIT_GITHUBUSERNAME and OCTOKIT_GITHUBUSERNAME environment variables are not set. Please configure these environment variables for a GitHub test account (DO NOT USE A &quot;REAL&quot; ACCOUNT)." />
</Target>

<Target Name="FullBuild" DependsOnTargets="RunUnitTests; RunIntegrationTests" />
<Target Name="FullBuild" DependsOnTargets="RunUnitTests; RunRTUnitTests; RunIntegrationTests" />
</Project>
7 changes: 3 additions & 4 deletions Octokit/ApiExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using System;
using System.Globalization;
using System.Linq;
#if NET_45
using System.Collections.Generic;
using System.Reflection;
#endif
using System.Threading.Tasks;
using Octokit.Http;

Expand All @@ -18,7 +17,7 @@ public static Task<T> Get<T>(this IApiConnection<T> connection, Uri endpoint)
return connection.Get(endpoint, null);
}

public static Task<IReadOnlyCollection<T>> GetAll<T>(this IApiConnection<T> connection, Uri endpoint)
public static Task<IReadOnlyList<T>> GetAll<T>(this IApiConnection<T> connection, Uri endpoint)
{
Ensure.ArgumentNotNull(connection, "connection");
Ensure.ArgumentNotNull(endpoint, "endpoint");
Expand Down
2 changes: 1 addition & 1 deletion Octokit/Clients/ApiPagination.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Octokit.Clients
/// <typeparam name="T"></typeparam>
public class ApiPagination<T> : IApiPagination<T>
{
public async Task<IReadOnlyCollection<T>> GetAllPages(Func<Task<IReadOnlyPagedCollection<T>>> getFirstPage)
public async Task<IReadOnlyList<T>> GetAllPages(Func<Task<IReadOnlyPagedCollection<T>>> getFirstPage)
{
Ensure.ArgumentNotNull(getFirstPage, "getFirstPage");

Expand Down
2 changes: 1 addition & 1 deletion Octokit/Clients/AuthorizationsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public AuthorizationsClient(IApiConnection<Authorization> client) : base(client)
/// Get all <see cref="Authorization"/>s for the authenticated user. This method requires basic auth.
/// </summary>
/// <returns>An <see cref="Authorization"/></returns>
public async Task<IReadOnlyCollection<Authorization>> GetAll()
public async Task<IReadOnlyList<Authorization>> GetAll()
{
return await Client.GetAll(authorizationsEndpoint);
}
Expand Down
7 changes: 4 additions & 3 deletions Octokit/Clients/AutoCompleteClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@ namespace Octokit.Clients
/// </summary>
public class AutoCompleteClient : IAutoCompleteClient
{
readonly IConnection connection;
readonly IConnection _connection;

public AutoCompleteClient(IConnection connection)
{
Ensure.ArgumentNotNull(connection, "connection");
this.connection = connection;

_connection = connection;
}

public async Task<IReadOnlyDictionary<string, Uri>> GetEmojis()
{
var endpoint = new Uri("/emojis", UriKind.Relative);
var response = await connection.GetAsync<Dictionary<string, string>>(endpoint, null);
var response = await _connection.GetAsync<Dictionary<string, string>>(endpoint, null);
return new ReadOnlyDictionary<string, Uri>(
response.BodyAsObject.ToDictionary(kvp => kvp.Key, kvp => new Uri(kvp.Value)));
}
Expand Down
Loading