Skip to content

Commit

Permalink
Merge pull request #897 from adamralph/893-readonlypagecollection-nul…
Browse files Browse the repository at this point in the history
…l-body

893 readonlypagecollection null body
  • Loading branch information
haacked committed Sep 17, 2015
2 parents 0925580 + afc8c2e commit 5610478
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 1 deletion.
26 changes: 26 additions & 0 deletions Octokit.Tests/Http/ReadOnlyPagedCollectionTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Octokit.Internal;
using NSubstitute;
using Xunit;

namespace Octokit.Tests.Http
{
public class ReadOnlyPagedCollectionTests
{
public class TheConstructor
{
[Fact]
public void AcceptsAResponseWithANullBody()
{
var response = Substitute.For<IApiResponse<List<string>>>();
response.Body.Returns((List<string>)null);

var exception = Record.Exception(() =>
new ReadOnlyPagedCollection<string>(response, uri => Task.FromResult(response)));

Assert.Null(exception);
}
}
}
}
1 change: 1 addition & 0 deletions Octokit.Tests/OctoKit.Tests-NetCore45.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
<Compile Include="Authentication\TokenAuthenticatorTests.cs" />
<Compile Include="Http\ConnectionTests.cs" />
<Compile Include="Http\RateLimitTests.cs" />
<Compile Include="Http\ReadOnlyPagedCollectionTests.cs" />
<Compile Include="Http\ResponseTests.cs" />
<Compile Include="Http\RequestTests.cs" />
<Compile Include="Models\DeploymentStatusTests.cs" />
Expand Down
1 change: 1 addition & 0 deletions Octokit.Tests/Octokit.Tests-Portable.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
<Compile Include="Authentication\TokenAuthenticatorTests.cs" />
<Compile Include="Http\ConnectionTests.cs" />
<Compile Include="Http\RateLimitTests.cs" />
<Compile Include="Http\ReadOnlyPagedCollectionTests.cs" />
<Compile Include="Http\ResponseTests.cs" />
<Compile Include="Http\RequestTests.cs" />
<Compile Include="Models\DeploymentStatusTests.cs" />
Expand Down
1 change: 1 addition & 0 deletions Octokit.Tests/Octokit.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
<Compile Include="Http\ConnectionTests.cs" />
<Compile Include="Http\RateLimitTests.cs" />
<Compile Include="Http\RedirectHandlerTests.cs" />
<Compile Include="Http\ReadOnlyPagedCollectionTests.cs" />
<Compile Include="Http\ResponseTests.cs" />
<Compile Include="Http\RequestTests.cs" />
<Compile Include="Models\DeploymentStatusTests.cs" />
Expand Down
2 changes: 1 addition & 1 deletion Octokit/Http/ReadOnlyPagedCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class ReadOnlyPagedCollection<T> : ReadOnlyCollection<T>, IReadOnlyPagedC
readonly Func<Uri, Task<IApiResponse<List<T>>>> _nextPageFunc;

public ReadOnlyPagedCollection(IApiResponse<List<T>> response, Func<Uri, Task<IApiResponse<List<T>>>> nextPageFunc)
: base(response != null ? response.Body : new List<T>())
: base(response != null ? response.Body ?? new List<T>() : new List<T>())
{
Ensure.ArgumentNotNull(response, "response");
Ensure.ArgumentNotNull(nextPageFunc, "nextPageFunc");
Expand Down

0 comments on commit 5610478

Please sign in to comment.