From 4580e0f2a3ce9734810c957bfee97ac91ca0848c Mon Sep 17 00:00:00 2001 From: Adam Ralph Date: Tue, 15 Sep 2015 12:04:19 +0200 Subject: [PATCH 1/2] red: added ReadOnlyPagedCollectionTests.TheConstructor.AcceptsAResponseWithANullBody --- .../Http/ReadOnlyPagedCollectionTests.cs | 26 +++++++++++++++++++ Octokit.Tests/OctoKit.Tests-NetCore45.csproj | 1 + Octokit.Tests/Octokit.Tests-Portable.csproj | 1 + Octokit.Tests/Octokit.Tests.csproj | 1 + 4 files changed, 29 insertions(+) create mode 100644 Octokit.Tests/Http/ReadOnlyPagedCollectionTests.cs diff --git a/Octokit.Tests/Http/ReadOnlyPagedCollectionTests.cs b/Octokit.Tests/Http/ReadOnlyPagedCollectionTests.cs new file mode 100644 index 0000000000..c040202340 --- /dev/null +++ b/Octokit.Tests/Http/ReadOnlyPagedCollectionTests.cs @@ -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>>(); + response.Body.Returns((List)null); + + var exception = Record.Exception(() => + new ReadOnlyPagedCollection(response, uri => Task.FromResult(response))); + + Assert.Null(exception); + } + } + } +} diff --git a/Octokit.Tests/OctoKit.Tests-NetCore45.csproj b/Octokit.Tests/OctoKit.Tests-NetCore45.csproj index 3050eb69c5..b44ea034f3 100644 --- a/Octokit.Tests/OctoKit.Tests-NetCore45.csproj +++ b/Octokit.Tests/OctoKit.Tests-NetCore45.csproj @@ -128,6 +128,7 @@ + diff --git a/Octokit.Tests/Octokit.Tests-Portable.csproj b/Octokit.Tests/Octokit.Tests-Portable.csproj index e64b0f2796..7a6a0efa66 100644 --- a/Octokit.Tests/Octokit.Tests-Portable.csproj +++ b/Octokit.Tests/Octokit.Tests-Portable.csproj @@ -126,6 +126,7 @@ + diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index ca3daabc08..9c00502159 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -145,6 +145,7 @@ + From afc8c2e4506cc6c8da393b8312cdd217048f51d9 Mon Sep 17 00:00:00 2001 From: Adam Ralph Date: Thu, 17 Sep 2015 13:56:38 +0200 Subject: [PATCH 2/2] green: implemented ReadOnlyPagedCollectionTests.TheConstructor.AcceptsAResponseWithANullBody --- Octokit/Http/ReadOnlyPagedCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit/Http/ReadOnlyPagedCollection.cs b/Octokit/Http/ReadOnlyPagedCollection.cs index 18e6f07416..9e6428242e 100644 --- a/Octokit/Http/ReadOnlyPagedCollection.cs +++ b/Octokit/Http/ReadOnlyPagedCollection.cs @@ -11,7 +11,7 @@ public class ReadOnlyPagedCollection : ReadOnlyCollection, IReadOnlyPagedC readonly Func>>> _nextPageFunc; public ReadOnlyPagedCollection(IApiResponse> response, Func>>> nextPageFunc) - : base(response != null ? response.Body : new List()) + : base(response != null ? response.Body ?? new List() : new List()) { Ensure.ArgumentNotNull(response, "response"); Ensure.ArgumentNotNull(nextPageFunc, "nextPageFunc");