diff --git a/Octokit.Tests/Http/ConnectionTests.cs b/Octokit.Tests/Http/ConnectionTests.cs index ad335e44..254c598d 100644 --- a/Octokit.Tests/Http/ConnectionTests.cs +++ b/Octokit.Tests/Http/ConnectionTests.cs @@ -4,8 +4,10 @@ using System.IO; using System.Linq; using System.Net; using System.Net.Http; +using System.Threading; using System.Threading.Tasks; using NSubstitute; +using NSubstitute.Core.Arguments; using Octokit.Internal; using Octokit.Tests.Helpers; using Xunit; @@ -571,7 +573,6 @@ namespace Octokit.Tests.Http public async Task ReturnsNullIfNew() { var httpClient = Substitute.For(); - httpClient.LastApiInfo.Returns((ApiInfo)null); var connection = new Connection(new ProductHeaderValue("OctokitTests"), _exampleUri, Substitute.For(), @@ -581,8 +582,6 @@ namespace Octokit.Tests.Http var result = connection.LastApiInfo; Assert.Null(result); - - var temp = httpClient.Received(1).LastApiInfo; } [Fact] @@ -624,13 +623,24 @@ namespace Octokit.Tests.Http ); var httpClient = Substitute.For(); - httpClient.LastApiInfo.Returns(apiInfo); + + // We really only care about the ApiInfo property... + var expectedResponse = new Response(HttpStatusCode.OK, null, new Dictionary(), "application/json") + { + ApiInfo = apiInfo + }; + + httpClient.Send(Arg.Any(), Arg.Any()) + .Returns(Task.FromResult(expectedResponse)); + var connection = new Connection(new ProductHeaderValue("OctokitTests"), _exampleUri, Substitute.For(), httpClient, Substitute.For()); + connection.Get(new Uri("https://example.com"), TimeSpan.MaxValue); + var result = connection.LastApiInfo; // No point checking all of the values as they are tested elsewhere @@ -640,8 +650,6 @@ namespace Octokit.Tests.Http Assert.Equal(4, result.AcceptedOauthScopes.Count); Assert.Equal("5634b0b187fd2e91e3126a75006cc4fa", result.Etag); Assert.Equal(100, result.RateLimit.Limit); - - var temp = httpClient.Received(1).LastApiInfo; } } } diff --git a/Octokit/Http/Response.cs b/Octokit/Http/Response.cs index 89b2750b..c143cddd 100644 --- a/Octokit/Http/Response.cs +++ b/Octokit/Http/Response.cs @@ -43,7 +43,7 @@ namespace Octokit.Internal /// /// Information about the API response parsed from the response headers. /// - public ApiInfo ApiInfo { get; private set; } + public ApiInfo ApiInfo { get; internal set; } // This setter is internal for use in tests. /// /// The response status code. ///