mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-05-30 09:49:04 +00:00
Add unit test for ReadOnlyPagedCollection
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using NSubstitute;
|
||||
using Octokit.Internal;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Models
|
||||
{
|
||||
public class ReadOnlyPagedCollectionTests
|
||||
{
|
||||
public class TheGetNextPageMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task ReturnsTheNextPage()
|
||||
{
|
||||
var nextPageUrl = new Uri("https://example.com/page/2");
|
||||
var nextPageResponse = Task.Factory.StartNew<IResponse<List<object>>>(() =>
|
||||
new ApiResponse<List<object>> {BodyAsObject = new List<object> {new object(), new object()}});
|
||||
var links = new Dictionary<string, Uri> {{"next", nextPageUrl}};
|
||||
var scopes = new List<string>();
|
||||
|
||||
var response = new ApiResponse<List<object>>
|
||||
{
|
||||
BodyAsObject = new List<object>(),
|
||||
ApiInfo = new ApiInfo(links, scopes, scopes, "etag", 100, 100)
|
||||
};
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.GetAsync<List<object>>(nextPageUrl, null, null).Returns(nextPageResponse);
|
||||
var pagedCollection = new ReadOnlyPagedCollection<object>(response, connection);
|
||||
|
||||
var nextPage = await pagedCollection.GetNextPage();
|
||||
|
||||
Assert.NotNull(nextPage);
|
||||
Assert.Equal(2, nextPage.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,6 +84,7 @@
|
||||
<Compile Include="Http\ResponseTests.cs" />
|
||||
<Compile Include="Http\RequestTests.cs" />
|
||||
<Compile Include="Models\ModelExtensionsTests.cs" />
|
||||
<Compile Include="Models\ReadOnlyPagedCollectionTests.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Helpers\StringExtensionsTests.cs" />
|
||||
<Compile Include="Clients\RepositoriesClientTests.cs" />
|
||||
|
||||
Reference in New Issue
Block a user