mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-08 04:40:54 +00:00
Passing tests and fix build for MonoAndroid and MonoTouch
This commit is contained in:
committed by
Marius Ungureanu
parent
91db7e59e9
commit
6f3e3232ed
@@ -5,6 +5,8 @@ using Octokit.Tests.Integration;
|
||||
using Xunit;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
public class GistsClientTests
|
||||
{
|
||||
@@ -132,5 +134,4 @@ public class GistsClientTests
|
||||
|
||||
await _fixture.Delete(createdGist.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,14 @@
|
||||
using System;
|
||||
using NSubstitute;
|
||||
using NSubstitute;
|
||||
using Octokit;
|
||||
using Xunit;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Octokit.Internal;
|
||||
using Octokit.Tests.Helpers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
using Xunit.Extensions;
|
||||
|
||||
public class GistsClientTests
|
||||
{
|
||||
@@ -33,7 +36,7 @@ public class GistsClientTests
|
||||
|
||||
client.GetAll();
|
||||
|
||||
connection.Received().GetAll<Gist>(Arg.Is<Uri>(u => u.ToString() == "gists"), null);
|
||||
connection.Received().GetAll<Gist>(Arg.Is<Uri>(u => u.ToString() == "gists"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -56,8 +59,7 @@ public class GistsClientTests
|
||||
|
||||
client.GetAllPublic();
|
||||
|
||||
connection.Received().GetAll<Gist>(Arg.Is<Uri>(u => u.ToString() == "gists/public"),
|
||||
Arg.Is<IDictionary<string, string>>(x => x.ContainsKey("since")));
|
||||
connection.Received().GetAll<Gist>(Arg.Is<Uri>(u => u.ToString() == "gists/public"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -81,8 +83,7 @@ public class GistsClientTests
|
||||
|
||||
client.GetAllStarred();
|
||||
|
||||
connection.Received().GetAll<Gist>(Arg.Is<Uri>(u => u.ToString() == "gists/starred"),
|
||||
Arg.Is<IDictionary<string, string>>(x => x.ContainsKey("since")));
|
||||
connection.Received().GetAll<Gist>(Arg.Is<Uri>(u => u.ToString() == "gists/starred"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -106,8 +107,7 @@ public class GistsClientTests
|
||||
|
||||
client.GetAllForUser("octokit");
|
||||
|
||||
connection.Received().GetAll<Gist>(Arg.Is<Uri>(u => u.ToString() == "users/octokit/gists"),
|
||||
Arg.Is<IDictionary<string, string>>(x => x.ContainsKey("since")));
|
||||
connection.Received().GetAll<Gist>(Arg.Is<Uri>(u => u.ToString() == "users/octokit/gists"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -178,7 +178,7 @@ public class GistsClientTests
|
||||
|
||||
client.Star("1");
|
||||
|
||||
connection.Received().Get<Gist>(Arg.Is<Uri>(u => u.ToString() == "gists/1/star"), null);
|
||||
connection.Received().Put(Arg.Is<Uri>(u => u.ToString() == "gists/1/star"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -189,18 +189,42 @@ public class GistsClientTests
|
||||
|
||||
client.Unstar("1");
|
||||
|
||||
connection.Received().Get<Gist>(Arg.Is<Uri>(u => u.ToString() == "gists/1/star"), null);
|
||||
connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "gists/1/star"));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(HttpStatusCode.NoContent, true)]
|
||||
[InlineData(HttpStatusCode.NotFound, false)]
|
||||
public async Task RequestsCorrectValueForStatusCode(HttpStatusCode status, bool expected)
|
||||
{
|
||||
var response = Task.Factory.StartNew<IResponse<object>>(() =>
|
||||
new ApiResponse<object> { StatusCode = status });
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.GetAsync<object>(Arg.Is<Uri>(u => u.ToString() == "gists/1/star"),
|
||||
null, null).Returns(response);
|
||||
var apiConnection = Substitute.For<IApiConnection>();
|
||||
apiConnection.Connection.Returns(connection);
|
||||
var client = new GistsClient(apiConnection);
|
||||
|
||||
var result = await client.IsStarred("1");
|
||||
|
||||
Assert.Equal(expected, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RequestsCorrectCheckIfStarredUrl()
|
||||
public async Task ThrowsExceptionForInvalidStatusCode()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new GistsClient(connection);
|
||||
var response = Task.Factory.StartNew<IResponse<object>>(() =>
|
||||
new ApiResponse<object> { StatusCode = HttpStatusCode.Conflict });
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.GetAsync<object>(Arg.Is<Uri>(u => u.ToString() == "gists/1/star"),
|
||||
null, null).Returns(response);
|
||||
var apiConnection = Substitute.For<IApiConnection>();
|
||||
apiConnection.Connection.Returns(connection);
|
||||
|
||||
client.IsStarred("1");
|
||||
var client = new GistsClient(apiConnection);
|
||||
|
||||
connection.Received().Get<Gist>(Arg.Is<Uri>(u => u.ToString() == "gists/1/star"), null);
|
||||
AssertEx.Throws<ApiException>(async () => await client.IsStarred("1"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,8 +238,8 @@ public class GistsClientTests
|
||||
|
||||
client.Fork("1");
|
||||
|
||||
connection.Received().Post<Gist>(Arg.Is<Uri>(u => u.ToString() == "gists/1/fork"),
|
||||
Arg.Is<object>(o => o == null));
|
||||
connection.Received().Post<Gist>(Arg.Is<Uri>(u => u.ToString() == "gists/1/forks"),
|
||||
Arg.Any<object>());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,7 +263,7 @@ public class GistsClientTests
|
||||
|
||||
client.Edit("1", updateGist);
|
||||
|
||||
connection.Received().Post<Gist>(Arg.Is<Uri>(u => u.ToString() == "gists/1"), Arg.Any<object>());
|
||||
connection.Received().Patch<Gist>(Arg.Is<Uri>(u => u.ToString() == "gists/1"), Arg.Any<object>());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,6 @@ namespace Octokit
|
||||
/// <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 Task<IReadOnlyList<Gist>> GetAll()
|
||||
{
|
||||
return ApiConnection.GetAll<Gist>(ApiUrls.Gist());
|
||||
@@ -201,7 +200,7 @@ namespace Octokit
|
||||
/// Edits a gist
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/gists/#edit-a-gist
|
||||
/// 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>
|
||||
|
||||
@@ -309,6 +309,8 @@
|
||||
<Compile Include="Helpers\ApiErrorExtensions.cs" />
|
||||
<Compile Include="Exceptions\PrivateRepositoryQuotaExceededException.cs" />
|
||||
<Compile Include="Models\Request\NewGist.cs" />
|
||||
<Compile Include="Models\Request\GistUpdate.cs" />
|
||||
<Compile Include="Models\Request\GistRequest.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -248,7 +248,6 @@
|
||||
<Compile Include="Models\Response\GistFile.cs" />
|
||||
<Compile Include="Models\Response\GistFork.cs" />
|
||||
<Compile Include="Models\Response\GistHistory.cs" />
|
||||
<<<<<<< HEAD
|
||||
<Compile Include="Clients\IReferencesClient.cs" />
|
||||
<Compile Include="Clients\ReferencesClient.cs" />
|
||||
<Compile Include="Models\Request\NewReference.cs" />
|
||||
@@ -304,7 +303,8 @@
|
||||
<Compile Include="Exceptions\RepositoryExistsException.cs" />
|
||||
<Compile Include="Helpers\ApiErrorExtensions.cs" />
|
||||
<Compile Include="Exceptions\PrivateRepositoryQuotaExceededException.cs" />
|
||||
<Compile Include="Models\Response\GistHistory.cs" />
|
||||
<Compile Include="Models\Request\GistUpdate.cs" />
|
||||
<Compile Include="Models\Request\GistRequest.cs" />
|
||||
<Compile Include="Models\Request\NewGist.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
|
||||
Reference in New Issue
Block a user