Merge pull request #2 from Haacked/refactorings

Add Users method and integration tests for UsersEndpoint
This commit is contained in:
Phil Haack
2013-01-09 12:31:29 -08:00
11 changed files with 402 additions and 37 deletions
@@ -47,6 +47,7 @@
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Readme.cs" />
<Compile Include="UsersEndpointTests.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Burr\Burr.csproj">
+9 -9
View File
@@ -21,13 +21,13 @@ namespace Burr.Tests
var github = new GitHubClient { Login = "xapitestaccountx", Password = "octocat11" };
// Get the authenticated user
var user = await github.Users.GetAsync();
var user = await github.User.Current();
// Get a user by username
user = await github.Users.GetAsync("tclem");
user = await github.User.Get("tclem");
// Update a user
user = await github.Users.UpdateAsync(new UserUpdate { Name = "octolish" });
user = await github.User.Update(new UserUpdate { Name = "octolish" });
}
public async Task AuthorizationsApi()
@@ -35,19 +35,19 @@ namespace Burr.Tests
var github = new GitHubClient { Login = "xapitestaccountx", Password = "octocat11" };
// create a new auth
var auth = await github.Authorizations.CreateAsync(new AuthorizationUpdate { Note = "integration test", NoteUrl = "http://example.com", Scopes = new[] { "public_repo" } });
var auth = await github.Authorization.CreateAsync(new AuthorizationUpdate { Note = "integration test", NoteUrl = "http://example.com", Scopes = new[] { "public_repo" } });
// list all authorizations for the authenticated user
var auths = await github.Authorizations.GetAllAsync();
var auths = await github.Authorization.GetAllAsync();
// get a specific auth
auth = await github.Authorizations.GetAsync(auth.Id);
auth = await github.Authorization.GetAsync(auth.Id);
// update an auth
auth = await github.Authorizations.UpdateAsync(auth.Id, new AuthorizationUpdate { Note = "integration test update" });
auth = await github.Authorization.UpdateAsync(auth.Id, new AuthorizationUpdate { Note = "integration test update" });
// delete a specific auth
await github.Authorizations.DeleteAsync(auth.Id);
await github.Authorization.DeleteAsync(auth.Id);
}
public async Task ReposApi()
@@ -55,7 +55,7 @@ namespace Burr.Tests
var github = new GitHubClient { Token = "945c6aa4194a6916c9eb1d845d2ff9f357dfe43e" };
// list all repos for the authenticated user
var repos = await github.Repositories.GetAllAsync();
var repos = await github.Repository.GetAllAsync();
// list repos for a user
//github.Repositories.GetAllAsync(new RepositoryQuery { Login = "tclem" });
@@ -0,0 +1,52 @@
using System;
using System.Threading.Tasks;
using Xunit;
namespace Burr.Tests.Integration
{
public class UsersEndpointTests
{
public class TheGetUserAsyncMethod
{
[Fact]
public async Task ReturnsSpecifiedUser()
{
var github = new GitHubClient { Login = "xapitestaccountx", Password = "octocat11" };
// Get a user by username
var user = await github.User.Get("tclem");
Assert.Equal("GitHub", user.Company);
}
}
public class TheGetAuthenticatedUserAsyncMethod
{
[Fact]
public async Task ReturnsSpecifiedUser()
{
var github = new GitHubClient { Login = "xapitestaccountx", Password = "octocat11" };
// Get a user by username
var user = await github.User.Current();
Assert.Equal("xapitestaccountx", user.Login);
}
}
public class TheGetUsersAsyncMethod
{
[Fact]
public async Task ReturnsAllUsers()
{
var github = new GitHubClient();
// Get a user by username
var users = await github.User.GetAll();
Console.WriteLine(users);
}
}
}
}
+5 -5
View File
@@ -76,7 +76,7 @@ namespace Burr.Tests
Connection = c.Object
};
var auths = await client.Authorizations.GetAllAsync();
var auths = await client.Authorization.GetAllAsync();
auths.Should().NotBeNull();
auths.Count().Should().Be(1);
@@ -123,7 +123,7 @@ namespace Burr.Tests
Connection = c.Object
};
var auth = await client.Authorizations.GetAsync(1);
var auth = await client.Authorization.GetAsync(1);
auth.Should().NotBeNull();
c.Verify(x => x.GetAsync<Authorization>(endpoint));
@@ -169,7 +169,7 @@ namespace Burr.Tests
Connection = c.Object
};
var auth = await client.Authorizations.UpdateAsync(1, new AuthorizationUpdate());
var auth = await client.Authorization.UpdateAsync(1, new AuthorizationUpdate());
auth.Should().NotBeNull();
c.Verify(x => x.PatchAsync<Authorization>(endpoint, It.IsAny<AuthorizationUpdate>()));
@@ -215,7 +215,7 @@ namespace Burr.Tests
Connection = c.Object
};
var auth = await client.Authorizations.CreateAsync(new AuthorizationUpdate());
var auth = await client.Authorization.CreateAsync(new AuthorizationUpdate());
auth.Should().NotBeNull();
c.Verify(x => x.PostAsync<Authorization>(endpoint, It.IsAny<AuthorizationUpdate>()));
@@ -261,7 +261,7 @@ namespace Burr.Tests
Connection = c.Object
};
await client.Authorizations.DeleteAsync(1);
await client.Authorization.DeleteAsync(1);
c.Verify(x => x.DeleteAsync<Authorization>(endpoint));
}
+1 -1
View File
@@ -41,7 +41,7 @@ namespace Burr.Tests
Connection = c.Object
};
var repos = await client.Repositories.GetAllAsync();
var repos = await client.Repository.GetAllAsync();
repos.Should().NotBeNull();
repos.Items.Count.Should().Be(1);
+7 -7
View File
@@ -41,7 +41,7 @@ namespace Burr.Tests
Connection = c.Object
};
var user = await client.Users.GetAsync();
var user = await client.User.Current();
user.Should().NotBeNull();
c.Verify(x => x.GetAsync<User>(endpoint));
@@ -59,7 +59,7 @@ namespace Burr.Tests
Connection = c.Object
};
var user = await client.Users.GetAsync();
var user = await client.User.Current();
user.Should().NotBeNull();
c.Verify(x => x.GetAsync<User>(endpoint));
@@ -70,7 +70,7 @@ namespace Burr.Tests
{
try
{
var user = await (new GitHubClient { Token = "axy" }).Users.UpdateAsync(null);
var user = await (new GitHubClient { Token = "axy" }).User.Update(null);
Assert.True(false, "ArgumentNullException was not thrown");
}
@@ -84,7 +84,7 @@ namespace Burr.Tests
{
try
{
var user = await new GitHubClient().Users.GetAsync();
var user = await new GitHubClient().User.Current();
Assert.True(false, "AuthenticationException was not thrown");
}
@@ -109,7 +109,7 @@ namespace Burr.Tests
Connection = c.Object
};
var user = await client.Users.UpdateAsync(new UserUpdate { Name = "Tim" });
var user = await client.User.Update(new UserUpdate { Name = "Tim" });
user.Should().NotBeNull();
c.Verify(x => x.PatchAsync<User>(endpoint, It.IsAny<UserUpdate>()));
@@ -127,7 +127,7 @@ namespace Burr.Tests
Connection = c.Object
};
var user = await client.Users.UpdateAsync(new UserUpdate { Name = "Tim" });
var user = await client.User.Update(new UserUpdate { Name = "Tim" });
user.Should().NotBeNull();
c.Verify(x => x.PatchAsync<User>(endpoint, It.IsAny<UserUpdate>()));
@@ -138,7 +138,7 @@ namespace Burr.Tests
{
try
{
var user = await new GitHubClient().Users.UpdateAsync(new UserUpdate());
var user = await new GitHubClient().User.Update(new UserUpdate());
Assert.True(false, "AuthenticationException was not thrown");
}
+261
View File
@@ -0,0 +1,261 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeEditing/ContextActionTable/DisabledContextActions/=JetBrains_002EReSharper_002EIntentions_002ECSharp_002EContextActions_002EInvokeAsStaticMethodAction/@EntryIndexedValue">True</s:Boolean>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantArgumentNameForLiteralExpression/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=CodeReformat/@EntryIndexedValue">&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;Profile name="CodeReformat"&gt;&lt;JsReformatCode&gt;True&lt;/JsReformatCode&gt;&lt;CSReformatCode&gt;True&lt;/CSReformatCode&gt;&lt;CSUseVar&gt;&lt;BehavourStyle&gt;DISABLED&lt;/BehavourStyle&gt;&lt;LocalVariableStyle&gt;IMPLICIT_WHEN_INITIALIZER_HAS_TYPE&lt;/LocalVariableStyle&gt;&lt;ForeachVariableStyle&gt;IMPLICIT_EXCEPT_SIMPLE_TYPES&lt;/ForeachVariableStyle&gt;&lt;/CSUseVar&gt;&lt;CSMakeFieldReadonly&gt;True&lt;/CSMakeFieldReadonly&gt;&lt;CSUseAutoProperty&gt;True&lt;/CSUseAutoProperty&gt;&lt;HtmlReformatCode&gt;True&lt;/HtmlReformatCode&gt;&lt;AspOptimizeRegisterDirectives&gt;True&lt;/AspOptimizeRegisterDirectives&gt;&lt;CssReformatCode&gt;True&lt;/CssReformatCode&gt;&lt;CSRemoveCodeRedundancies&gt;True&lt;/CSRemoveCodeRedundancies&gt;&lt;CSOptimizeUsings&gt;&lt;OptimizeUsings&gt;True&lt;/OptimizeUsings&gt;&lt;EmbraceInRegion&gt;False&lt;/EmbraceInRegion&gt;&lt;RegionName&gt;&lt;/RegionName&gt;&lt;/CSOptimizeUsings&gt;&lt;/Profile&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/CodeCleanup/SilentCleanupProfile/@EntryValue">CodeReformat</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_LINQ_QUERY/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_ARGUMENT/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_ARRAY_AND_OBJECT_INITIALIZER/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_CALLS_CHAIN/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_EXPRESSION/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_EXTENDS_LIST/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_FOR_STMT/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_PARAMETER/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTIPLE_DECLARATION/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTLINE_TYPE_PARAMETER_CONSTRAINS/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTLINE_TYPE_PARAMETER_LIST/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ANONYMOUS_METHOD_DECLARATION_BRACES/@EntryValue">NEXT_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/CASE_BLOCK_BRACES/@EntryValue">NEXT_LINE</s:String>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/CONTINUOUS_INDENT_MULTIPLIER/@EntryValue">1</s:Int64>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/EXPLICIT_PRIVATE_MODIFIER/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_ANONYMOUS_METHOD_BLOCK/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_EMBRACED_INITIALIZER_BLOCK/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INITIALIZER_BRACES/@EntryValue">NEXT_LINE</s:String>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_BLANK_LINES_IN_CODE/@EntryValue">1</s:Int64>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_BLANK_LINES_IN_DECLARATIONS/@EntryValue">1</s:Int64>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/LINE_FEED_AT_FILE_END/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_FIELD_ATTRIBUTE_ON_SAME_LINE/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_AFTER_TYPECAST_PARENTHESES/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_BEFORE_TYPEOF_PARENTHESES/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_IN_SINGLELINE_ANONYMOUS_METHOD/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_WITHIN_SINGLE_LINE_ARRAY_INITIALIZER_BRACES/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/STICK_COMMENT/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_LINES/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CSharpMemberOrderPattern/CustomPattern/@EntryValue">&lt;?xml version="1.0" encoding="utf-8"?&gt;&#xD;
&#xD;
&lt;!--&#xD;
II. Available match operands&#xD;
&#xD;
Each operand may have Weight="..." attribute. This weight will be added to the match weight if the operand is evaluated to 'true'.&#xD;
The default weight is 1&#xD;
&#xD;
II.1 Boolean functions:&#xD;
II.1.1 &lt;And&gt;....&lt;/And&gt;&#xD;
II.1.2 &lt;Or&gt;....&lt;/Or&gt;&#xD;
II.1.3 &lt;Not&gt;....&lt;/Not&gt;&#xD;
&#xD;
II.2 Operands&#xD;
II.2.1 &lt;Kind Is="..."/&gt;. Kinds are: class, struct, interface, enum, delegate, type, constructor, destructor, property, indexer, method, operator, field, constant, event, member&#xD;
II.2.2 &lt;Name Is="..." [IgnoreCase="true/false"] /&gt;. The 'Is' attribute contains regular expression&#xD;
II.2.3 &lt;HasAttribute CLRName="..." [Inherit="true/false"] /&gt;. The 'CLRName' attribute contains regular expression&#xD;
II.2.4 &lt;Access Is="..."/&gt;. The 'Is' values are: public, protected, internal, protected internal, private&#xD;
II.2.5 &lt;Static/&gt;&#xD;
II.2.6 &lt;Abstract/&gt;&#xD;
II.2.7 &lt;Virtual/&gt;&#xD;
II.2.8 &lt;Override/&gt;&#xD;
II.2.9 &lt;Sealed/&gt;&#xD;
II.2.10 &lt;Readonly/&gt;&#xD;
II.2.11 &lt;ImplementsInterface CLRName="..."/&gt;. The 'CLRName' attribute contains regular expression&#xD;
II.2.12 &lt;HandlesEvent /&gt;&#xD;
--&gt;&#xD;
&#xD;
&lt;Patterns xmlns="urn:shemas-jetbrains-com:member-reordering-patterns"&gt;&#xD;
&#xD;
&lt;!--Do not reorder COM interfaces and structs marked by StructLayout attribute--&gt;&#xD;
&lt;Pattern&gt;&#xD;
&lt;Match&gt;&#xD;
&lt;Or Weight="100"&gt;&#xD;
&lt;And&gt;&#xD;
&lt;Kind Is="interface"/&gt;&#xD;
&lt;Or&gt;&#xD;
&lt;HasAttribute CLRName="System.Runtime.InteropServices.InterfaceTypeAttribute"/&gt;&#xD;
&lt;HasAttribute CLRName="System.Runtime.InteropServices.ComImport"/&gt;&#xD;
&lt;/Or&gt;&#xD;
&lt;/And&gt;&#xD;
&lt;HasAttribute CLRName="System.Runtime.InteropServices.StructLayoutAttribute"/&gt;&#xD;
&lt;/Or&gt;&#xD;
&lt;/Match&gt;&#xD;
&lt;/Pattern&gt;&#xD;
&#xD;
&lt;!--Special formatting of NUnit test fixture--&gt;&#xD;
&lt;Pattern RemoveAllRegions="true"&gt;&#xD;
&lt;Match&gt;&#xD;
&lt;And Weight="100"&gt;&#xD;
&lt;Kind Is="class"/&gt;&#xD;
&lt;HasAttribute CLRName="NUnit.Framework.TestFixtureAttribute" Inherit="true"/&gt;&#xD;
&lt;/And&gt;&#xD;
&lt;/Match&gt;&#xD;
&#xD;
&lt;!--Setup/Teardown--&gt;&#xD;
&lt;Entry&gt;&#xD;
&lt;Match&gt;&#xD;
&lt;And&gt;&#xD;
&lt;Kind Is="method"/&gt;&#xD;
&lt;Or&gt;&#xD;
&lt;HasAttribute CLRName="NUnit.Framework.SetUpAttribute" Inherit="true"/&gt;&#xD;
&lt;HasAttribute CLRName="NUnit.Framework.TearDownAttribute" Inherit="true"/&gt;&#xD;
&lt;HasAttribute CLRName="NUnit.Framework.TestFixtureSetUpAttribute" Inherit="true"/&gt;&#xD;
&lt;HasAttribute CLRName="NUnit.Framework.TestFixtureTearDownAttribute" Inherit="true"/&gt;&#xD;
&lt;/Or&gt;&#xD;
&lt;/And&gt;&#xD;
&lt;/Match&gt;&#xD;
&lt;Group Region="Setup/Teardown"/&gt;&#xD;
&lt;/Entry&gt;&#xD;
&#xD;
&lt;!--Test methods--&gt;&#xD;
&lt;Entry&gt;&#xD;
&lt;Match&gt;&#xD;
&lt;And Weight="100"&gt;&#xD;
&lt;Kind Is="method"/&gt;&#xD;
&lt;HasAttribute CLRName="NUnit.Framework.TestAttribute" Inherit="false"/&gt;&#xD;
&lt;/And&gt;&#xD;
&lt;/Match&gt;&#xD;
&lt;Sort&gt;&#xD;
&lt;Name/&gt;&#xD;
&lt;/Sort&gt;&#xD;
&lt;/Entry&gt;&#xD;
&#xD;
&lt;!--All other members--&gt;&#xD;
&lt;Entry&gt;&#xD;
&lt;Group Region="Supporting Code"/&gt;&#xD;
&lt;/Entry&gt;&#xD;
&#xD;
&lt;/Pattern&gt;&#xD;
&#xD;
&lt;!--Default pattern--&gt;&#xD;
&lt;Pattern&gt;&#xD;
&#xD;
&lt;!--public delegate--&gt;&#xD;
&lt;Entry&gt;&#xD;
&lt;Match&gt;&#xD;
&lt;And Weight="100"&gt;&#xD;
&lt;Access Is="public"/&gt;&#xD;
&lt;Kind Is="delegate"/&gt;&#xD;
&lt;/And&gt;&#xD;
&lt;/Match&gt;&#xD;
&lt;Sort&gt;&#xD;
&lt;Name/&gt;&#xD;
&lt;/Sort&gt;&#xD;
&lt;/Entry&gt;&#xD;
&#xD;
&lt;!--public enum--&gt;&#xD;
&lt;Entry&gt;&#xD;
&lt;Match&gt;&#xD;
&lt;And Weight="100"&gt;&#xD;
&lt;Access Is="public"/&gt;&#xD;
&lt;Kind Is="enum"/&gt;&#xD;
&lt;/And&gt;&#xD;
&lt;/Match&gt;&#xD;
&lt;Sort&gt;&#xD;
&lt;Name/&gt;&#xD;
&lt;/Sort&gt;&#xD;
&lt;Group&gt;&#xD;
&lt;Name/&gt;&#xD;
&lt;/Group&gt;&#xD;
&lt;/Entry&gt;&#xD;
&#xD;
&lt;!--static fields and constants--&gt;&#xD;
&lt;Entry&gt;&#xD;
&lt;Match&gt;&#xD;
&lt;Or&gt;&#xD;
&lt;Kind Is="constant"/&gt;&#xD;
&lt;And&gt;&#xD;
&lt;Kind Is="field"/&gt;&#xD;
&lt;Static/&gt;&#xD;
&lt;/And&gt;&#xD;
&lt;/Or&gt;&#xD;
&lt;/Match&gt;&#xD;
&lt;Sort&gt;&#xD;
&lt;Kind Order="constant field"/&gt;&#xD;
&lt;/Sort&gt;&#xD;
&lt;/Entry&gt;&#xD;
&#xD;
&lt;!--instance fields--&gt;&#xD;
&lt;Entry&gt;&#xD;
&lt;Match&gt;&#xD;
&lt;And&gt;&#xD;
&lt;Kind Is="field"/&gt;&#xD;
&lt;Not&gt;&#xD;
&lt;Static/&gt;&#xD;
&lt;/Not&gt;&#xD;
&lt;/And&gt;&#xD;
&lt;/Match&gt;&#xD;
&lt;Sort&gt;&#xD;
&lt;Readonly/&gt;&#xD;
&lt;Name/&gt;&#xD;
&lt;/Sort&gt;&#xD;
&lt;/Entry&gt;&#xD;
&#xD;
&lt;!--Constructors. Place static one first--&gt;&#xD;
&lt;Entry&gt;&#xD;
&lt;Match&gt;&#xD;
&lt;Kind Is="constructor"/&gt;&#xD;
&lt;/Match&gt;&#xD;
&lt;Sort&gt;&#xD;
&lt;Static/&gt;&#xD;
&lt;/Sort&gt;&#xD;
&lt;/Entry&gt;&#xD;
&#xD;
&lt;!--properties, indexers--&gt;&#xD;
&lt;Entry&gt;&#xD;
&lt;Match&gt;&#xD;
&lt;Or&gt;&#xD;
&lt;Kind Is="property"/&gt;&#xD;
&lt;Kind Is="indexer"/&gt;&#xD;
&lt;/Or&gt;&#xD;
&lt;/Match&gt;&#xD;
&lt;Sort&gt;&#xD;
&lt;Name/&gt;&#xD;
&lt;/Sort&gt;&#xD;
&lt;/Entry&gt;&#xD;
&#xD;
&lt;!--interface implementations--&gt;&#xD;
&lt;Entry&gt;&#xD;
&lt;Match&gt;&#xD;
&lt;And Weight="100"&gt;&#xD;
&lt;Kind Is="member"/&gt;&#xD;
&lt;ImplementsInterface/&gt;&#xD;
&lt;/And&gt;&#xD;
&lt;/Match&gt;&#xD;
&lt;Sort&gt;&#xD;
&lt;ImplementsInterface Immediate="true"/&gt;&#xD;
&lt;/Sort&gt;&#xD;
&lt;/Entry&gt;&#xD;
&#xD;
&lt;!--public methods--&gt;&#xD;
&lt;Entry&gt;&#xD;
&lt;Match&gt;&#xD;
&lt;And&gt;&#xD;
&lt;Kind Is="method"/&gt;&#xD;
&lt;Access Is="public"/&gt;&#xD;
&lt;/And&gt;&#xD;
&lt;/Match&gt;&#xD;
&lt;Sort&gt;&#xD;
&lt;Name/&gt;&#xD;
&lt;/Sort&gt;&#xD;
&lt;/Entry&gt;&#xD;
&#xD;
&lt;!--all other members--&gt;&#xD;
&lt;Entry&gt;&#xD;
&lt;Sort&gt;&#xD;
&lt;Name/&gt;&#xD;
&lt;/Sort&gt;&#xD;
&lt;/Entry&gt;&#xD;
&#xD;
&lt;!--nested types--&gt;&#xD;
&lt;Entry&gt;&#xD;
&lt;Match&gt;&#xD;
&lt;Kind Is="type"/&gt;&#xD;
&lt;/Match&gt;&#xD;
&lt;Sort&gt;&#xD;
&lt;Name/&gt;&#xD;
&lt;/Sort&gt;&#xD;
&lt;Group&gt;&#xD;
&lt;Name/&gt;&#xD;
&lt;/Group&gt;&#xD;
&lt;/Entry&gt;&#xD;
&lt;/Pattern&gt;&#xD;
&#xD;
&lt;/Patterns&gt;&#xD;
</s:String>
</wpf:ResourceDictionary>
+3 -3
View File
@@ -140,7 +140,7 @@ namespace Burr
/// Supports the ability to get and update users.
/// http://developer.github.com/v3/users/
/// </summary>
public IUsersEndpoint Users
public IUsersEndpoint User
{
get { return users ?? (users = new UsersEndpoint(this)); }
}
@@ -151,14 +151,14 @@ namespace Burr
/// Supports the ability to list, get, update and create oauth application authorizations.
/// http://developer.github.com/v3/oauth/#oauth-authorizations-api
/// </summary>
public IAuthorizationsEndpoint Authorizations
public IAuthorizationsEndpoint Authorization
{
get { return authorizations ?? (authorizations = new AuthorizationsEndpoint(this)); }
}
IRepositoriesEndpoint repositories;
public IRepositoriesEndpoint Repositories
public IRepositoriesEndpoint Repository
{
get { return repositories ?? (repositories = new RepositoriesEndpoint(this)); }
}
+2 -1
View File
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
namespace Burr.Http
@@ -9,7 +10,7 @@ namespace Burr.Http
Task<IResponse<T>> GetAsync<T>(string endpoint);
Task<IResponse<T>> PatchAsync<T>(string endpoint, object body);
Task<IResponse<T>> PostAsync<T>(string endpoint, object body);
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter")]
[SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter")]
Task DeleteAsync<T>(string endpoint);
}
}
+28 -3
View File
@@ -1,10 +1,35 @@
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Burr
{
public interface IUsersEndpoint
{
Task<User> GetAsync(string login = null);
Task<User> UpdateAsync(UserUpdate user);
/// <summary>
/// Returns the user specified by the login.
/// </summary>
/// <param name="login">The login name for the user</param>
Task<User> Get(string login);
/// <summary>
/// Returns a <see cref="User"/> for the current authenticated user.
/// </summary>
/// <exception cref="AuthenticationException">Thrown if the client is not authenticated.</exception>
/// <returns>A <see cref="User"/></returns>
Task<User> Current();
/// <summary>
/// Update the specified <see cref="UserUpdate"/>.
/// </summary>
/// <param name="user"></param>
/// <exception cref="AuthenticationException">Thrown if the client is not authenticated.</exception>
/// <returns>A <see cref="User"/></returns>
Task<User> Update(UserUpdate user);
/// <summary>
/// Returns a list of public <see cref="User"/>s on GitHub.com.
/// </summary>
/// <returns>A <see cref="User"/></returns>
Task<List<User>> GetAll();
}
}
+33 -8
View File
@@ -1,4 +1,5 @@
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Threading.Tasks;
using Burr.Helpers;
namespace Burr
@@ -9,7 +10,7 @@ namespace Burr
/// </summary>
public class UsersEndpoint : IUsersEndpoint
{
IGitHubClient client;
readonly IGitHubClient client;
public UsersEndpoint(IGitHubClient client)
{
@@ -24,16 +25,28 @@ namespace Burr
/// </summary>
/// <param name="login">Optional GitHub login (username)</param>
/// <returns>A <see cref="User"/></returns>
public async Task<User> GetAsync(string login = null)
public async Task<User> Get(string login)
{
if (login.IsBlank() && client.AuthenticationType == AuthenticationType.Anonymous)
Ensure.ArgumentNotNull(login, "login");
var res = await client.Connection.GetAsync<User>(string.Format("/users/{0}", login));
return res.BodyAsObject;
}
/// <summary>
/// Returns a <see cref="User"/> for the current authenticated user.
/// </summary>
/// <exception cref="AuthenticationException">Thrown if the client is not authenticated.</exception>
/// <returns>A <see cref="User"/></returns>
public async Task<User> Current()
{
if (client.AuthenticationType == AuthenticationType.Anonymous)
{
throw new AuthenticationException("You must be authenticated to call this method. Either supply a login/password or an oauth token.");
}
var endpoint = login.IsBlank() ? "/user" : string.Format("/users/{0}", login);
var res = await client.Connection.GetAsync<User>(endpoint);
var res = await client.Connection.GetAsync<User>("/user");
return res.BodyAsObject;
}
@@ -41,8 +54,9 @@ namespace Burr
/// Update the specified <see cref="UserUpdate"/>.
/// </summary>
/// <param name="user"></param>
/// <exception cref="AuthenticationException">Thrown if the client is not authenticated.</exception>
/// <returns>A <see cref="User"/></returns>
public async Task<User> UpdateAsync(UserUpdate user)
public async Task<User> Update(UserUpdate user)
{
Ensure.ArgumentNotNull(user, "user");
@@ -55,5 +69,16 @@ namespace Burr
return res.BodyAsObject;
}
/// <summary>
/// Returns a list of public <see cref="User"/>s on GitHub.com.
/// </summary>
/// <returns>A <see cref="User"/></returns>
public async Task<List<User>> GetAll()
{
var res = await client.Connection.GetAsync<List<User>>(string.Format("/users"));
return res.BodyAsObject;
}
}
}