mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-08 12:42:32 +00:00
Removed fluent assertions
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using FluentAssertions;
|
||||
using Octokit.Authentication;
|
||||
using Octokit.Http;
|
||||
using Xunit;
|
||||
@@ -8,10 +7,6 @@ namespace Octokit.Tests
|
||||
{
|
||||
public class BasicAuthenticatorTests
|
||||
{
|
||||
public class TheConstructor
|
||||
{
|
||||
}
|
||||
|
||||
public class TheAuthenticateMethod
|
||||
{
|
||||
[Fact]
|
||||
@@ -22,8 +17,8 @@ namespace Octokit.Tests
|
||||
|
||||
authenticator.Authenticate(request, new Credentials("that-creepy-dude", "Fahrvergnügen"));
|
||||
|
||||
request.Headers.Should().ContainKey("Authorization");
|
||||
request.Headers["Authorization"].Should().Be("Basic dGhhdC1jcmVlcHktZHVkZTpGYWhydmVyZ27DvGdlbg==");
|
||||
Assert.Contains("Authorization", request.Headers.Keys);
|
||||
Assert.Equal("Basic dGhhdC1jcmVlcHktZHVkZTpGYWhydmVyZ27DvGdlbg==", request.Headers["Authorization"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using FluentAssertions;
|
||||
using Octokit.Http;
|
||||
using Xunit;
|
||||
|
||||
@@ -13,21 +12,21 @@ namespace Octokit.Tests.Authentication
|
||||
public void ReturnsAnonymousForEmptyCtor()
|
||||
{
|
||||
var credentials = Credentials.Anonymous;
|
||||
credentials.AuthenticationType.Should().Be(AuthenticationType.Anonymous);
|
||||
Assert.Equal(AuthenticationType.Anonymous, credentials.AuthenticationType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReturnsBasicWhenProvidedLoginAndPassword()
|
||||
{
|
||||
var credentials = new Credentials("login", "password");
|
||||
credentials.AuthenticationType.Should().Be(AuthenticationType.Basic);
|
||||
Assert.Equal(AuthenticationType.Basic, credentials.AuthenticationType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReturnsOuthWhenProvidedToken()
|
||||
{
|
||||
var credentials = new Credentials("token");
|
||||
credentials.AuthenticationType.Should().Be(AuthenticationType.Oauth);
|
||||
Assert.Equal(AuthenticationType.Oauth, credentials.AuthenticationType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +36,7 @@ namespace Octokit.Tests.Authentication
|
||||
public void IsSetFromCtor()
|
||||
{
|
||||
var credentials = new Credentials("login", "password");
|
||||
credentials.Login.Should().Be("login");
|
||||
Assert.Equal("login", credentials.Login);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +46,7 @@ namespace Octokit.Tests.Authentication
|
||||
public void IsSetFromCtor()
|
||||
{
|
||||
var credentials = new Credentials("login", "password");
|
||||
credentials.Password.Should().Be("password");
|
||||
Assert.Equal("password", credentials.Password);
|
||||
}
|
||||
}
|
||||
public class TheCtor
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using FluentAssertions;
|
||||
using NSubstitute;
|
||||
using Octokit.Authentication;
|
||||
using Octokit.Http;
|
||||
@@ -19,8 +18,8 @@ namespace Octokit.Tests
|
||||
|
||||
authenticator.Authenticate(request, new Credentials("abcda1234a"));
|
||||
|
||||
request.Headers.Should().ContainKey("Authorization");
|
||||
request.Headers["Authorization"].Should().Be("Token abcda1234a");
|
||||
Assert.Contains("Authorization", request.Headers.Keys);
|
||||
Assert.Equal("Token abcda1234a", request.Headers["Authorization"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using FluentAssertions;
|
||||
using NSubstitute;
|
||||
using Octokit.Clients;
|
||||
using Octokit.Http;
|
||||
@@ -42,7 +41,7 @@ namespace Octokit.Tests.Clients
|
||||
|
||||
var emojis = await autoComplete.GetEmojis();
|
||||
|
||||
emojis.Count.Should().Be(2);
|
||||
Assert.Equal(2, emojis.Count);
|
||||
connection.Received()
|
||||
.GetAsync<Dictionary<string, string>>(Arg.Is<Uri>(u => u.ToString() == "/emojis"), null);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using FluentAssertions;
|
||||
using NSubstitute;
|
||||
using Octokit.Clients;
|
||||
using Octokit.Http;
|
||||
@@ -130,13 +129,13 @@ namespace Octokit.Tests.Clients
|
||||
|
||||
var readme = await reposEndpoint.GetReadme("fake", "repo");
|
||||
|
||||
readme.Name.Should().Be("README.md");
|
||||
Assert.Equal("README.md", readme.Name);
|
||||
client.Received().GetItem<ReadmeResponse>(Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/readme"),
|
||||
null);
|
||||
client.DidNotReceive().GetHtml(Arg.Is<Uri>(u => u.ToString() == "https://github.example.com/readme"),
|
||||
null);
|
||||
var htmlReadme = await readme.GetHtmlContent();
|
||||
htmlReadme.Should().Be("<html>README</html>");
|
||||
Assert.Equal("<html>README</html>", htmlReadme);
|
||||
client.Received().GetHtml(Arg.Is<Uri>(u => u.ToString() == "https://github.example.com/readme"), null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using FluentAssertions;
|
||||
using NSubstitute;
|
||||
using Octokit.Http;
|
||||
using Xunit;
|
||||
@@ -15,7 +14,7 @@ namespace Octokit.Tests
|
||||
{
|
||||
var client = new GitHubClient();
|
||||
|
||||
client.Credentials.AuthenticationType.Should().Be(AuthenticationType.Anonymous);
|
||||
Assert.Equal(AuthenticationType.Anonymous, client.Credentials.AuthenticationType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -23,7 +22,7 @@ namespace Octokit.Tests
|
||||
{
|
||||
var client = new GitHubClient { Credentials = new Credentials("tclem", "pwd") };
|
||||
|
||||
client.Credentials.AuthenticationType.Should().Be(AuthenticationType.Basic);
|
||||
Assert.Equal(AuthenticationType.Basic, client.Credentials.AuthenticationType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -31,7 +30,7 @@ namespace Octokit.Tests
|
||||
{
|
||||
var client = new GitHubClient { Credentials = new Credentials("token") };
|
||||
|
||||
client.Credentials.AuthenticationType.Should().Be(AuthenticationType.Oauth);
|
||||
Assert.Equal(AuthenticationType.Oauth, client.Credentials.AuthenticationType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -52,7 +51,7 @@ namespace Octokit.Tests
|
||||
{
|
||||
var client = new GitHubClient();
|
||||
|
||||
client.BaseAddress.Should().Be("https://api.github.com");
|
||||
Assert.Equal(new Uri("https://api.github.com"), client.BaseAddress);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +61,7 @@ namespace Octokit.Tests
|
||||
public void DefaultsToAnonymous()
|
||||
{
|
||||
var client = new GitHubClient();
|
||||
client.Credentials.Should().BeSameAs(Credentials.Anonymous);
|
||||
Assert.Same(Credentials.Anonymous, client.Credentials);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -74,8 +73,8 @@ namespace Octokit.Tests
|
||||
Credentials = credentials
|
||||
};
|
||||
|
||||
client.Connection.CredentialStore.Should().BeOfType<InMemoryCredentialStore>();
|
||||
client.Credentials.Should().BeSameAs(credentials);
|
||||
Assert.IsType<InMemoryCredentialStore>(client.Connection.CredentialStore);
|
||||
Assert.Same(credentials, client.Credentials);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -85,8 +84,8 @@ namespace Octokit.Tests
|
||||
credentialStore.GetCredentials().Returns(new Credentials("foo", "bar"));
|
||||
var client = new GitHubClient(credentialStore);
|
||||
|
||||
client.Credentials.Login.Should().Be("foo");
|
||||
client.Credentials.Password.Should().Be("bar");
|
||||
Assert.Equal("foo", client.Credentials.Login);
|
||||
Assert.Equal("bar", client.Credentials.Password);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using FluentAssertions;
|
||||
using Xunit;
|
||||
using Xunit.Extensions;
|
||||
|
||||
@@ -16,7 +15,7 @@ namespace Octokit.Tests.Helpers
|
||||
[Theory]
|
||||
public void ProperlyDetectsBlankStrings(string data, bool expected)
|
||||
{
|
||||
data.IsBlank().Should().Be(expected);
|
||||
Assert.Equal(expected, data.IsBlank());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +28,7 @@ namespace Octokit.Tests.Helpers
|
||||
[Theory]
|
||||
public void ProperlyDetectsBlankStrings(string data, bool expected)
|
||||
{
|
||||
data.IsNotBlank().Should().Be(expected);
|
||||
Assert.Equal(expected, data.IsNotBlank());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +39,7 @@ namespace Octokit.Tests.Helpers
|
||||
[InlineData("FirstName", "first_name")]
|
||||
public void ConvertsPascalToRuby(string source, string expected)
|
||||
{
|
||||
source.ToRubyCase().Should().Be(expected);
|
||||
Assert.Equal(expected, source.ToRubyCase());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using FluentAssertions;
|
||||
using NSubstitute;
|
||||
using Octokit.Http;
|
||||
using Octokit.Tests.Helpers;
|
||||
@@ -24,7 +23,7 @@ namespace Octokit.Tests.Http
|
||||
|
||||
var data = await apiConnection.Get(getUri);
|
||||
|
||||
data.Should().BeSameAs(response.BodyAsObject);
|
||||
Assert.Same(response.BodyAsObject, data);
|
||||
connection.Received().GetAsync<object>(getUri);
|
||||
}
|
||||
|
||||
@@ -49,7 +48,7 @@ namespace Octokit.Tests.Http
|
||||
|
||||
var data = await apiConnection.GetItem<object>(getUri, null);
|
||||
|
||||
data.Should().BeSameAs(response.BodyAsObject);
|
||||
Assert.Same(response.BodyAsObject, data);
|
||||
connection.Received().GetAsync<object>(getUri);
|
||||
}
|
||||
|
||||
@@ -74,7 +73,7 @@ namespace Octokit.Tests.Http
|
||||
|
||||
var data = await apiConnection.GetHtml(getUri);
|
||||
|
||||
data.Should().Be("<html />");
|
||||
Assert.Same("<html />", data);
|
||||
connection.Received().GetHtml(getUri);
|
||||
}
|
||||
|
||||
@@ -105,7 +104,7 @@ namespace Octokit.Tests.Http
|
||||
|
||||
var data = await apiConnection.GetAll(getAllUri);
|
||||
|
||||
data.Count.Should().Be(2);
|
||||
Assert.Equal(2, data.Count);
|
||||
connection.Received().GetAsync<List<object>>(getAllUri, null);
|
||||
}
|
||||
|
||||
@@ -131,7 +130,7 @@ namespace Octokit.Tests.Http
|
||||
|
||||
var data = await apiConnection.Update(patchUri, sentData);
|
||||
|
||||
data.Should().BeSameAs(response.BodyAsObject);
|
||||
Assert.Same(data, response.BodyAsObject);
|
||||
connection.Received().PatchAsync<object>(patchUri, sentData);
|
||||
|
||||
}
|
||||
@@ -160,7 +159,7 @@ namespace Octokit.Tests.Http
|
||||
|
||||
var data = await apiConnection.Create(postUri, sentData);
|
||||
|
||||
data.Should().BeSameAs(response.BodyAsObject);
|
||||
Assert.Same(data, response.BodyAsObject);
|
||||
connection.Received().PostAsync<object>(postUri, sentData);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FluentAssertions;
|
||||
using Octokit.Http;
|
||||
using Xunit;
|
||||
using Xunit.Extensions;
|
||||
@@ -30,12 +29,12 @@ namespace Octokit.Tests
|
||||
parser.ParseApiHttpHeaders(response);
|
||||
|
||||
var apiInfo = response.ApiInfo;
|
||||
apiInfo.Should().NotBeNull();
|
||||
apiInfo.AcceptedOauthScopes.Should().BeEquivalentTo(new[] { "user" });
|
||||
apiInfo.OauthScopes.Should().BeEquivalentTo(new[] { "user", "public_repo", "repo", "gist" });
|
||||
apiInfo.RateLimit.Should().Be(5000);
|
||||
apiInfo.RateLimitRemaining.Should().Be(4997);
|
||||
apiInfo.Etag.Should().Be("5634b0b187fd2e91e3126a75006cc4fa");
|
||||
Assert.NotNull(apiInfo);
|
||||
Assert.Equal(new[] { "user" }, apiInfo.AcceptedOauthScopes);
|
||||
Assert.Equal(new[] { "user", "public_repo", "repo", "gist" }, apiInfo.OauthScopes);
|
||||
Assert.Equal(5000, apiInfo.RateLimit);
|
||||
Assert.Equal(4997, apiInfo.RateLimitRemaining);
|
||||
Assert.Equal("5634b0b187fd2e91e3126a75006cc4fa", apiInfo.Etag);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -57,8 +56,8 @@ namespace Octokit.Tests
|
||||
parser.ParseApiHttpHeaders(response);
|
||||
|
||||
var apiInfo = response.ApiInfo;
|
||||
apiInfo.Should().NotBeNull();
|
||||
apiInfo.Links.Count.Should().Be(0);
|
||||
Assert.NotNull(apiInfo);
|
||||
Assert.Equal(0, apiInfo.Links.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -70,7 +69,10 @@ namespace Octokit.Tests
|
||||
{
|
||||
{
|
||||
"Link",
|
||||
"<https://api.github.com/repos/rails/rails/issues?page=4&per_page=5>; rel=\"next\", <https://api.github.com/repos/rails/rails/issues?page=131&per_page=5>; rel=\"last\", <https://api.github.com/repos/rails/rails/issues?page=1&per_page=5>; rel=\"first\", <https://api.github.com/repos/rails/rails/issues?page=2&per_page=5>; rel=\"prev\""
|
||||
"<https://api.github.com/repos/rails/rails/issues?page=4&per_page=5>; rel=\"next\", " +
|
||||
"<https://api.github.com/repos/rails/rails/issues?page=131&per_page=5>; rel=\"last\", " +
|
||||
"<https://api.github.com/repos/rails/rails/issues?page=1&per_page=5>; rel=\"first\", " +
|
||||
"<https://api.github.com/repos/rails/rails/issues?page=2&per_page=5>; rel=\"prev\""
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -79,16 +81,20 @@ namespace Octokit.Tests
|
||||
parser.ParseApiHttpHeaders(response);
|
||||
|
||||
var apiInfo = response.ApiInfo;
|
||||
apiInfo.Should().NotBeNull();
|
||||
apiInfo.Links.Count.Should().Be(4);
|
||||
apiInfo.Links.ContainsKey("next").Should().BeTrue();
|
||||
apiInfo.Links["next"].Should().Be(new Uri("https://api.github.com/repos/rails/rails/issues?page=4&per_page=5"));
|
||||
apiInfo.Links.ContainsKey("prev").Should().BeTrue();
|
||||
apiInfo.Links["prev"].Should().Be(new Uri("https://api.github.com/repos/rails/rails/issues?page=2&per_page=5"));
|
||||
apiInfo.Links.ContainsKey("first").Should().BeTrue();
|
||||
apiInfo.Links["first"].Should().Be(new Uri("https://api.github.com/repos/rails/rails/issues?page=1&per_page=5"));
|
||||
apiInfo.Links.ContainsKey("last").Should().BeTrue();
|
||||
apiInfo.Links["last"].Should().Be(new Uri("https://api.github.com/repos/rails/rails/issues?page=131&per_page=5"));
|
||||
Assert.NotNull(apiInfo);
|
||||
Assert.Equal(4, apiInfo.Links.Count);
|
||||
Assert.Contains("next", apiInfo.Links.Keys);
|
||||
Assert.Equal(new Uri("https://api.github.com/repos/rails/rails/issues?page=4&per_page=5"),
|
||||
apiInfo.Links["next"]);
|
||||
Assert.Contains("prev", apiInfo.Links.Keys);
|
||||
Assert.Equal(new Uri("https://api.github.com/repos/rails/rails/issues?page=2&per_page=5"),
|
||||
apiInfo.Links["prev"]);
|
||||
Assert.Contains("first", apiInfo.Links.Keys);
|
||||
Assert.Equal(new Uri("https://api.github.com/repos/rails/rails/issues?page=1&per_page=5"),
|
||||
apiInfo.Links["first"]);
|
||||
Assert.Contains("last", apiInfo.Links.Keys);
|
||||
Assert.Equal(new Uri("https://api.github.com/repos/rails/rails/issues?page=131&per_page=5"),
|
||||
apiInfo.Links["last"]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +111,7 @@ namespace Octokit.Tests
|
||||
{ linkName, pageUri }
|
||||
};
|
||||
var info = BuildApiInfo(links);
|
||||
pagingMethod(info).Should().BeSameAs(pageUri);
|
||||
Assert.Same(pageUri, pagingMethod(info));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@@ -115,7 +121,7 @@ namespace Octokit.Tests
|
||||
var links = new Dictionary<string, Uri>();
|
||||
var info = BuildApiInfo(links);
|
||||
|
||||
pagingMethod(info).Should().BeNull();
|
||||
Assert.Null(pagingMethod(info));
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> PagingMethods
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using FluentAssertions;
|
||||
using NSubstitute;
|
||||
using Octokit.Http;
|
||||
using Xunit;
|
||||
@@ -49,7 +48,7 @@ namespace Octokit.Tests.Http
|
||||
public void CreatesConnectionWithBaseAddress()
|
||||
{
|
||||
var connection = new Connection(new Uri("https://github.com/"));
|
||||
connection.BaseAddress.Should().Be(new Uri("https://github.com/"));
|
||||
Assert.Equal(new Uri("https://github.com/"), connection.BaseAddress);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,8 +113,8 @@ namespace Octokit.Tests.Http
|
||||
Substitute.For<IJsonSerializer>());
|
||||
|
||||
var resp = await connection.GetAsync<string>(new Uri("/endpoint", UriKind.Relative));
|
||||
resp.ApiInfo.Should().NotBeNull();
|
||||
resp.ApiInfo.AcceptedOauthScopes.First().Should().Be("user");
|
||||
Assert.NotNull(resp.ApiInfo);
|
||||
Assert.Equal("user", resp.ApiInfo.AcceptedOauthScopes.First());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using FluentAssertions;
|
||||
using Octokit.Http;
|
||||
using Xunit;
|
||||
|
||||
@@ -30,13 +29,13 @@ namespace Octokit.Tests.Http
|
||||
|
||||
var responseMessage = tester.BuildRequestMessageTester(request);
|
||||
|
||||
responseMessage.Headers.Count().Should().Be(2);
|
||||
Assert.Equal(2, responseMessage.Headers.Count());
|
||||
var firstHeader = responseMessage.Headers.First();
|
||||
firstHeader.Key.Should().Be("foo");
|
||||
firstHeader.Value.First().Should().Be("bar");
|
||||
Assert.Equal("foo", firstHeader.Key);
|
||||
Assert.Equal("bar", firstHeader.Value.First());
|
||||
var lastHeader = responseMessage.Headers.Last();
|
||||
lastHeader.Key.Should().Be("blah");
|
||||
lastHeader.Value.First().Should().Be("blase");
|
||||
Assert.Equal("blah", lastHeader.Key);
|
||||
Assert.Equal("blase", lastHeader.Value.First());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -66,11 +65,11 @@ namespace Octokit.Tests.Http
|
||||
var response = await tester.BuildResponseTester<string>(responseMessage);
|
||||
|
||||
var firstHeader = response.Headers.First();
|
||||
firstHeader.Key.Should().Be("peanut");
|
||||
firstHeader.Value.Should().Be("butter");
|
||||
Assert.Equal("peanut", firstHeader.Key);
|
||||
Assert.Equal("butter", firstHeader.Value);
|
||||
var lastHeader = response.Headers.Last();
|
||||
lastHeader.Key.Should().Be("ele");
|
||||
lastHeader.Value.Should().Be("phant");
|
||||
Assert.Equal("ele", lastHeader.Key);
|
||||
Assert.Equal("phant", lastHeader.Value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using FluentAssertions;
|
||||
using Octokit.Http;
|
||||
using Xunit;
|
||||
|
||||
@@ -26,8 +25,8 @@ namespace Octokit.Tests.Http
|
||||
|
||||
jsonPipeline.SerializeRequest(request);
|
||||
|
||||
request.Headers.Should().ContainKey("Accept");
|
||||
request.Headers["Accept"].Should().Be("application/vnd.github.v3+json; charset=utf-8");
|
||||
Assert.Contains("Accept", request.Headers.Keys);
|
||||
Assert.Equal("application/vnd.github.v3+json; charset=utf-8", request.Headers["Accept"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -39,7 +38,7 @@ namespace Octokit.Tests.Http
|
||||
|
||||
jsonPipeline.SerializeRequest(request);
|
||||
|
||||
request.Body.Should().Be(json);
|
||||
Assert.Equal(json, request.Body);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -50,7 +49,7 @@ namespace Octokit.Tests.Http
|
||||
|
||||
jsonPipeline.SerializeRequest(request);
|
||||
|
||||
request.Body.Should().Be("{\"test\":\"value\"}");
|
||||
Assert.Equal("{\"test\":\"value\"}", request.Body);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -73,8 +72,8 @@ namespace Octokit.Tests.Http
|
||||
|
||||
jsonPipeline.DeserializeResponse(response);
|
||||
|
||||
response.BodyAsObject.Should().NotBeNull();
|
||||
response.BodyAsObject.Should().Be(data);
|
||||
Assert.NotNull(response.BodyAsObject);
|
||||
Assert.Equal(data, response.BodyAsObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using FluentAssertions;
|
||||
using Octokit.Http;
|
||||
using Octokit.Http;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Http
|
||||
@@ -13,7 +12,7 @@ namespace Octokit.Tests.Http
|
||||
{
|
||||
var r = new Request();
|
||||
|
||||
r.Headers.Should().NotBeNull();
|
||||
Assert.NotNull(r.Headers);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using FluentAssertions;
|
||||
using Octokit.Http;
|
||||
using Octokit.Http;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Http
|
||||
@@ -13,7 +12,7 @@ namespace Octokit.Tests.Http
|
||||
{
|
||||
var r = new ApiResponse<string>();
|
||||
|
||||
r.Headers.Should().NotBeNull();
|
||||
Assert.NotNull(r.Headers);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,9 +30,6 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="FluentAssertions">
|
||||
<HintPath>..\packages\FluentAssertions.1.7.1.1\Lib\net40\FluentAssertions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NSubstitute, Version=1.4.3.0, Culture=neutral, PublicKeyToken=92dd2e9066daa5ca, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\NSubstitute.1.4.3.0\lib\NET40\NSubstitute.dll</HintPath>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using FluentAssertions;
|
||||
using Octokit.Http;
|
||||
using Octokit.Http;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests
|
||||
@@ -11,11 +10,11 @@ namespace Octokit.Tests
|
||||
[Fact]
|
||||
public void UsesRubyCasing()
|
||||
{
|
||||
var item = new Sample { Id = 42, FirstName = "Phil" };
|
||||
var item = new Sample { Id = 42, FirstName = "Phil", IsSomething = true, Private = true };
|
||||
|
||||
var json = new SimpleJsonSerializer().Serialize(item);
|
||||
|
||||
json.Should().Be("{\"id\":42,\"first_name\":\"Phil\"}");
|
||||
Assert.Equal("{\"id\":42,\"first_name\":\"Phil\",\"is_something\":true,\"private\":true}", json);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,12 +23,14 @@ namespace Octokit.Tests
|
||||
[Fact]
|
||||
public void UnderstandsRubyCasing()
|
||||
{
|
||||
const string json = "{\"id\":42,\"first_name\":\"Phil\"}";
|
||||
const string json = "{\"id\":42,\"first_name\":\"Phil\",\"is_something\":true,\"private\":true}";
|
||||
|
||||
var sample = new SimpleJsonSerializer().Deserialize<Sample>(json);
|
||||
|
||||
sample.Id.Should().Be(42);
|
||||
sample.FirstName.Should().Be("Phil");
|
||||
Assert.Equal(42, sample.Id);
|
||||
Assert.Equal("Phil", sample.FirstName);
|
||||
Assert.True(sample.IsSomething);
|
||||
Assert.True(sample.Private);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +38,8 @@ namespace Octokit.Tests
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string FirstName { get; set; }
|
||||
public bool IsSomething { get; set; }
|
||||
public bool Private { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="FluentAssertions" version="1.7.1.1" />
|
||||
<package id="NSubstitute" version="1.4.3.0" targetFramework="net45" />
|
||||
<package id="xunit" version="1.9.1" targetFramework="net45" />
|
||||
<package id="xunit.extensions" version="1.9.1" targetFramework="net45" />
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using Octokit.Http;
|
||||
|
||||
|
||||
@@ -2,16 +2,16 @@
|
||||
{
|
||||
public class SimpleJsonSerializer : IJsonSerializer
|
||||
{
|
||||
readonly GitHubSerializerStrategy serializationStrategy = new GitHubSerializerStrategy();
|
||||
readonly GitHubSerializerStrategy _serializationStrategy = new GitHubSerializerStrategy();
|
||||
|
||||
public string Serialize(object item)
|
||||
{
|
||||
return SimpleJson.SerializeObject(item, serializationStrategy);
|
||||
return SimpleJson.SerializeObject(item, _serializationStrategy);
|
||||
}
|
||||
|
||||
public T Deserialize<T>(string json)
|
||||
{
|
||||
return SimpleJson.DeserializeObject<T>(json, serializationStrategy);
|
||||
return SimpleJson.DeserializeObject<T>(json, _serializationStrategy);
|
||||
}
|
||||
|
||||
class GitHubSerializerStrategy : PocoJsonSerializerStrategy
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
-5260
File diff suppressed because it is too large
Load Diff
BIN
Binary file not shown.
BIN
Binary file not shown.
-3429
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -4,5 +4,4 @@
|
||||
<repository path="..\Octokit.Tests.Integration\packages.config" />
|
||||
<repository path="..\Octokit.Tests\packages.config" />
|
||||
<repository path="..\Octokit\packages.config" />
|
||||
<repository path="..\Octopi.Reactive\packages.config" />
|
||||
</repositories>
|
||||
Reference in New Issue
Block a user