mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-05 19:46:07 +00:00
Merge branch 'master' into shiftkey-repository-pages-api-options
This commit is contained in:
@@ -159,6 +159,82 @@ namespace Octokit.Tests.Integration.Reactive
|
||||
|
||||
}
|
||||
|
||||
public class TheGetAllIssuesForRepositoryMethod
|
||||
{
|
||||
readonly ObservableEventsClient _eventsClient;
|
||||
const string owner = "octokit";
|
||||
const string name = "octokit.net";
|
||||
|
||||
public TheGetAllIssuesForRepositoryMethod()
|
||||
{
|
||||
_eventsClient = new ObservableEventsClient(Helper.GetAuthenticatedClient());
|
||||
}
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsRepositoryEvents()
|
||||
{
|
||||
var repositoryEvents = await _eventsClient.GetAllIssuesForRepository(owner, name).ToList();
|
||||
|
||||
Assert.NotEmpty(repositoryEvents);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfRepositoryEventsWithoutStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 5,
|
||||
PageCount = 1
|
||||
};
|
||||
|
||||
var repositoryEvents = await _eventsClient.GetAllIssuesForRepository(owner, name, options).ToList();
|
||||
|
||||
Assert.Equal(5, repositoryEvents.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfRepositoryEventsWithStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 5,
|
||||
PageCount = 1,
|
||||
StartPage = 2
|
||||
};
|
||||
|
||||
var repositoryEvents = await _eventsClient.GetAllIssuesForRepository(owner, name, options).ToList();
|
||||
|
||||
Assert.Equal(5, repositoryEvents.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsDistinctRepositoryEventsBasedOnStartPage()
|
||||
{
|
||||
var startOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 5,
|
||||
PageCount = 1
|
||||
};
|
||||
|
||||
var firstRepositoryEventsPage = await _eventsClient.GetAllIssuesForRepository(owner, name, startOptions).ToList();
|
||||
|
||||
var skipStartOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 5,
|
||||
PageCount = 1,
|
||||
StartPage = 2
|
||||
};
|
||||
|
||||
var secondRepositoryEventsPage = await _eventsClient.GetAllIssuesForRepository(owner, name, skipStartOptions).ToList();
|
||||
|
||||
Assert.NotEqual(firstRepositoryEventsPage[0].Id, secondRepositoryEventsPage[0].Id);
|
||||
Assert.NotEqual(firstRepositoryEventsPage[1].Id, secondRepositoryEventsPage[1].Id);
|
||||
Assert.NotEqual(firstRepositoryEventsPage[2].Id, secondRepositoryEventsPage[2].Id);
|
||||
Assert.NotEqual(firstRepositoryEventsPage[3].Id, secondRepositoryEventsPage[3].Id);
|
||||
Assert.NotEqual(firstRepositoryEventsPage[4].Id, secondRepositoryEventsPage[4].Id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class TheGetAllForRepositoryNetworkMethod
|
||||
{
|
||||
readonly ObservableEventsClient _eventsClient;
|
||||
|
||||
@@ -0,0 +1,305 @@
|
||||
using System.Reactive.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Octokit.Reactive;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Integration.Reactive
|
||||
{
|
||||
public class ObservableFollowersClientTests
|
||||
{
|
||||
public class TheGetAllForCurrentMethod
|
||||
{
|
||||
readonly ObservableFollowersClient _followersClient;
|
||||
|
||||
public TheGetAllForCurrentMethod()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
|
||||
_followersClient = new ObservableFollowersClient(github);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsFollowers()
|
||||
{
|
||||
var followers = await _followersClient.GetAllForCurrent().ToList();
|
||||
|
||||
Assert.NotEmpty(followers);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfFollowersWithoutStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 1,
|
||||
PageCount = 1
|
||||
};
|
||||
|
||||
var followers = await _followersClient.GetAllForCurrent(options).ToList();
|
||||
|
||||
Assert.Equal(1, followers.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfFollowersWithStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 1,
|
||||
PageCount = 1,
|
||||
StartPage = 1
|
||||
};
|
||||
|
||||
var followers = await _followersClient.GetAllForCurrent(options).ToList();
|
||||
|
||||
Assert.Equal(1, followers.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsDistinctResultsBasedOnStartPage()
|
||||
{
|
||||
var startOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 1,
|
||||
PageCount = 1
|
||||
};
|
||||
|
||||
var firstFollowersPage = await _followersClient.GetAllForCurrent(startOptions).ToList();
|
||||
|
||||
var skipStartOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 1,
|
||||
PageCount = 1,
|
||||
StartPage = 2
|
||||
};
|
||||
|
||||
var secondFollowersPage = await _followersClient.GetAllForCurrent(skipStartOptions).ToList();
|
||||
|
||||
Assert.NotEqual(firstFollowersPage[0].Id, secondFollowersPage[0].Id);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetAllMethod
|
||||
{
|
||||
readonly ObservableFollowersClient _followersClient;
|
||||
const string login = "samthedev";
|
||||
|
||||
public TheGetAllMethod()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
|
||||
_followersClient = new ObservableFollowersClient(github);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsFollowers()
|
||||
{
|
||||
var followers = await _followersClient.GetAll(login).ToList();
|
||||
|
||||
Assert.NotEmpty(followers);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfFollowersWithoutStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 3,
|
||||
PageCount = 1
|
||||
};
|
||||
|
||||
var followers = await _followersClient.GetAll(login, options).ToList();
|
||||
|
||||
Assert.Equal(3, followers.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfFollowersWithStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 2,
|
||||
PageCount = 1,
|
||||
StartPage = 1
|
||||
};
|
||||
|
||||
var followers = await _followersClient.GetAll(login, options).ToList();
|
||||
|
||||
Assert.Equal(2, followers.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsDistinctResultsBasedOnStartPage()
|
||||
{
|
||||
var startOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 2,
|
||||
PageCount = 1
|
||||
};
|
||||
|
||||
var firstFollowersPage = await _followersClient.GetAll(login, startOptions).ToList();
|
||||
|
||||
var skipStartOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 2,
|
||||
PageCount = 1,
|
||||
StartPage = 2
|
||||
};
|
||||
|
||||
var secondFollowersPage = await _followersClient.GetAll(login, skipStartOptions).ToList();
|
||||
|
||||
Assert.NotEqual(firstFollowersPage[0].Id, secondFollowersPage[0].Id);
|
||||
Assert.NotEqual(firstFollowersPage[1].Id, secondFollowersPage[1].Id);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetAllFollowingForCurrentMethod
|
||||
{
|
||||
readonly ObservableFollowersClient _followersClient;
|
||||
|
||||
public TheGetAllFollowingForCurrentMethod()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
|
||||
_followersClient = new ObservableFollowersClient(github);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsFollowing()
|
||||
{
|
||||
var following = await _followersClient.GetAllFollowingForCurrent().ToList();
|
||||
|
||||
Assert.NotEmpty(following);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfFollowingWithoutStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 1,
|
||||
PageCount = 1
|
||||
};
|
||||
|
||||
var following = await _followersClient.GetAllFollowingForCurrent(options).ToList();
|
||||
|
||||
Assert.Equal(1, following.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfFollowingWithStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 1,
|
||||
PageCount = 1,
|
||||
StartPage = 1
|
||||
};
|
||||
|
||||
var following = await _followersClient.GetAllFollowingForCurrent(options).ToList();
|
||||
|
||||
Assert.Equal(1, following.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsDistinctResultsBasedOnStartPage()
|
||||
{
|
||||
var startOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 1,
|
||||
PageCount = 1
|
||||
};
|
||||
|
||||
var firstFollowingPage = await _followersClient.GetAllFollowingForCurrent(startOptions).ToList();
|
||||
|
||||
var skipStartOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 1,
|
||||
PageCount = 1,
|
||||
StartPage = 2
|
||||
};
|
||||
|
||||
var secondFollowingPage = await _followersClient.GetAllFollowingForCurrent(skipStartOptions).ToList();
|
||||
|
||||
Assert.NotEqual(firstFollowingPage[0].Id, secondFollowingPage[0].Id);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetAllFollowingMethod
|
||||
{
|
||||
readonly ObservableFollowersClient _followersClient;
|
||||
const string login = "samthedev";
|
||||
|
||||
public TheGetAllFollowingMethod()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
|
||||
_followersClient = new ObservableFollowersClient(github);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsFollowing()
|
||||
{
|
||||
var following = await _followersClient.GetAllFollowing(login).ToList();
|
||||
|
||||
Assert.NotEmpty(following);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfFollowingWithoutStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 5,
|
||||
PageCount = 1
|
||||
};
|
||||
|
||||
var following = await _followersClient.GetAllFollowing(login, options).ToList();
|
||||
|
||||
Assert.Equal(5, following.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfFollowingWithStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 5,
|
||||
PageCount = 1,
|
||||
StartPage = 1
|
||||
};
|
||||
|
||||
var following = await _followersClient.GetAllFollowing(login, options).ToList();
|
||||
|
||||
Assert.Equal(5, following.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsDistinctResultsBasedOnStartPage()
|
||||
{
|
||||
var startOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 5,
|
||||
PageCount = 1
|
||||
};
|
||||
|
||||
var firstFollowingPage = await _followersClient.GetAllFollowing(login, startOptions).ToList();
|
||||
|
||||
var skipStartOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 5,
|
||||
PageCount = 1,
|
||||
StartPage = 2
|
||||
};
|
||||
|
||||
var secondFollowingPage = await _followersClient.GetAllFollowing(login, skipStartOptions).ToList();
|
||||
|
||||
Assert.NotEqual(firstFollowingPage[0].Id, secondFollowingPage[0].Id);
|
||||
Assert.NotEqual(firstFollowingPage[1].Id, secondFollowingPage[1].Id);
|
||||
Assert.NotEqual(firstFollowingPage[2].Id, secondFollowingPage[2].Id);
|
||||
Assert.NotEqual(firstFollowingPage[3].Id, secondFollowingPage[3].Id);
|
||||
Assert.NotEqual(firstFollowingPage[4].Id, secondFollowingPage[4].Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,720 @@
|
||||
using System;
|
||||
using System.Reactive.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Octokit;
|
||||
using Octokit.Reactive;
|
||||
using Octokit.Tests.Integration;
|
||||
using Xunit;
|
||||
|
||||
public class ObservableGistClientTests
|
||||
{
|
||||
public class TheGetAllMethod
|
||||
{
|
||||
readonly ObservableGistsClient _gistsClient;
|
||||
|
||||
public TheGetAllMethod()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
|
||||
_gistsClient = new ObservableGistsClient(github);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsGists()
|
||||
{
|
||||
var gists = await _gistsClient.GetAll().ToList();
|
||||
|
||||
Assert.NotEmpty(gists);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfGistsWithoutStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 5,
|
||||
PageCount = 1
|
||||
};
|
||||
|
||||
var gists = await _gistsClient.GetAll(options).ToList();
|
||||
|
||||
Assert.Equal(5, gists.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfGistsWithStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 4,
|
||||
PageCount = 1,
|
||||
StartPage = 2
|
||||
};
|
||||
|
||||
var gists = await _gistsClient.GetAll(options).ToList();
|
||||
|
||||
Assert.Equal(4, gists.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsDistinctResultsBasedOnStartPage()
|
||||
{
|
||||
var startOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 4,
|
||||
PageCount = 1
|
||||
};
|
||||
|
||||
var firstGistsPage = await _gistsClient.GetAll(startOptions).ToList();
|
||||
|
||||
var skipStartOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 4,
|
||||
PageCount = 1,
|
||||
StartPage = 2
|
||||
};
|
||||
|
||||
var secondGistsPage = await _gistsClient.GetAll(skipStartOptions).ToList();
|
||||
|
||||
Assert.NotEqual(firstGistsPage[0].Id, secondGistsPage[0].Id);
|
||||
Assert.NotEqual(firstGistsPage[1].Id, secondGistsPage[1].Id);
|
||||
Assert.NotEqual(firstGistsPage[2].Id, secondGistsPage[2].Id);
|
||||
Assert.NotEqual(firstGistsPage[3].Id, secondGistsPage[3].Id);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsGistsSince()
|
||||
{
|
||||
var since = new DateTimeOffset(new DateTime(2016, 1, 1));
|
||||
var gists = await _gistsClient.GetAll(since).ToList();
|
||||
|
||||
Assert.NotEmpty(gists);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfGistsSinceWithoutStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 5,
|
||||
PageCount = 1
|
||||
};
|
||||
var since = new DateTimeOffset(new DateTime(2016, 1, 1));
|
||||
var gists = await _gistsClient.GetAll(since, options).ToList();
|
||||
|
||||
Assert.Equal(5, gists.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfGistsSinceWithStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 4,
|
||||
PageCount = 1,
|
||||
StartPage = 2
|
||||
};
|
||||
var since = new DateTimeOffset(new DateTime(2016, 1, 1));
|
||||
var gists = await _gistsClient.GetAll(since, options).ToList();
|
||||
|
||||
Assert.Equal(4, gists.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsDistinctGistsSinceBasedOnStartPage()
|
||||
{
|
||||
var startOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 4,
|
||||
PageCount = 1
|
||||
};
|
||||
var since = new DateTimeOffset(new DateTime(2016, 1, 1));
|
||||
var firstGistsPage = await _gistsClient.GetAll(since, startOptions).ToList();
|
||||
|
||||
var skipStartOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 4,
|
||||
PageCount = 1,
|
||||
StartPage = 2
|
||||
};
|
||||
|
||||
var secondGistsPage = await _gistsClient.GetAll(since, skipStartOptions).ToList();
|
||||
|
||||
Assert.NotEqual(firstGistsPage[0].Id, secondGistsPage[0].Id);
|
||||
Assert.NotEqual(firstGistsPage[1].Id, secondGistsPage[1].Id);
|
||||
Assert.NotEqual(firstGistsPage[2].Id, secondGistsPage[2].Id);
|
||||
Assert.NotEqual(firstGistsPage[3].Id, secondGistsPage[3].Id);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetAllPublicMethod
|
||||
{
|
||||
readonly ObservableGistsClient _gistsClient;
|
||||
|
||||
public TheGetAllPublicMethod()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
|
||||
_gistsClient = new ObservableGistsClient(github);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsPublicGists()
|
||||
{
|
||||
var gists = await _gistsClient.GetAllPublic().ToList();
|
||||
|
||||
Assert.NotEmpty(gists);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfPublicGistsWithoutStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 5,
|
||||
PageCount = 1
|
||||
};
|
||||
|
||||
var gists = await _gistsClient.GetAllPublic(options).ToList();
|
||||
|
||||
Assert.Equal(5, gists.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfPublicGistsWithStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 4,
|
||||
PageCount = 1,
|
||||
StartPage = 2
|
||||
};
|
||||
|
||||
var gists = await _gistsClient.GetAllPublic(options).ToList();
|
||||
|
||||
Assert.Equal(4, gists.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsDistinctResultsBasedOnStartPage()
|
||||
{
|
||||
var startOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 4,
|
||||
PageCount = 1
|
||||
};
|
||||
|
||||
var firstPublicGistsPage = await _gistsClient.GetAllPublic(startOptions).ToList();
|
||||
|
||||
var skipStartOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 4,
|
||||
PageCount = 1,
|
||||
StartPage = 2
|
||||
};
|
||||
|
||||
var secondPublicGistsPage = await _gistsClient.GetAllPublic(skipStartOptions).ToList();
|
||||
|
||||
Assert.NotEqual(firstPublicGistsPage[0].Id, secondPublicGistsPage[0].Id);
|
||||
Assert.NotEqual(firstPublicGistsPage[1].Id, secondPublicGistsPage[1].Id);
|
||||
Assert.NotEqual(firstPublicGistsPage[2].Id, secondPublicGistsPage[2].Id);
|
||||
Assert.NotEqual(firstPublicGistsPage[3].Id, secondPublicGistsPage[3].Id);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsPublicGistsSince()
|
||||
{
|
||||
var since = new DateTimeOffset(new DateTime(2016, 1, 1));
|
||||
var gists = await _gistsClient.GetAllPublic(since).ToList();
|
||||
|
||||
Assert.NotEmpty(gists);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfPublicGistsSinceWithoutStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 5,
|
||||
PageCount = 1
|
||||
};
|
||||
var since = new DateTimeOffset(new DateTime(2016, 1, 1));
|
||||
var gists = await _gistsClient.GetAllPublic(since, options).ToList();
|
||||
|
||||
Assert.Equal(5, gists.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfPublicGistsSinceWithStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 4,
|
||||
PageCount = 1,
|
||||
StartPage = 2
|
||||
};
|
||||
var since = new DateTimeOffset(new DateTime(2016, 1, 1));
|
||||
var gists = await _gistsClient.GetAllPublic(since, options).ToList();
|
||||
|
||||
Assert.Equal(4, gists.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsDistinctPublicGistsSinceBasedOnStartPage()
|
||||
{
|
||||
var startOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 4,
|
||||
PageCount = 1
|
||||
};
|
||||
var since = new DateTimeOffset(new DateTime(2016, 1, 1));
|
||||
var firstPublicGistsPage = await _gistsClient.GetAllPublic(since, startOptions).ToList();
|
||||
|
||||
var skipStartOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 4,
|
||||
PageCount = 1,
|
||||
StartPage = 2
|
||||
};
|
||||
|
||||
var secondPublicGistsPage = await _gistsClient.GetAllPublic(since, skipStartOptions).ToList();
|
||||
|
||||
Assert.NotEqual(firstPublicGistsPage[0].Id, secondPublicGistsPage[0].Id);
|
||||
Assert.NotEqual(firstPublicGistsPage[1].Id, secondPublicGistsPage[1].Id);
|
||||
Assert.NotEqual(firstPublicGistsPage[2].Id, secondPublicGistsPage[2].Id);
|
||||
Assert.NotEqual(firstPublicGistsPage[3].Id, secondPublicGistsPage[3].Id);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetAllStarredMethod
|
||||
{
|
||||
readonly ObservableGistsClient _gistsClient;
|
||||
|
||||
public TheGetAllStarredMethod()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
|
||||
_gistsClient = new ObservableGistsClient(github);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsStartedGists()
|
||||
{
|
||||
var gists = await _gistsClient.GetAllStarred().ToList();
|
||||
|
||||
Assert.NotEmpty(gists);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfStartedGistsWithoutStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 5,
|
||||
PageCount = 1
|
||||
};
|
||||
|
||||
var gists = await _gistsClient.GetAllStarred(options).ToList();
|
||||
|
||||
Assert.Equal(5, gists.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfStartedGistsWithStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 5,
|
||||
PageCount = 1,
|
||||
StartPage = 2
|
||||
};
|
||||
|
||||
var gists = await _gistsClient.GetAllStarred(options).ToList();
|
||||
|
||||
Assert.Equal(5, gists.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsDistinctResultsBasedOnStartPage()
|
||||
{
|
||||
var startOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 5,
|
||||
PageCount = 1
|
||||
};
|
||||
|
||||
var firstStartedGistsPage = await _gistsClient.GetAllStarred(startOptions).ToList();
|
||||
|
||||
var skipStartOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 5,
|
||||
PageCount = 1,
|
||||
StartPage = 2
|
||||
};
|
||||
|
||||
var secondStartedGistsPage = await _gistsClient.GetAllStarred(skipStartOptions).ToList();
|
||||
|
||||
Assert.NotEqual(firstStartedGistsPage[0].Id, secondStartedGistsPage[0].Id);
|
||||
Assert.NotEqual(firstStartedGistsPage[1].Id, secondStartedGistsPage[1].Id);
|
||||
Assert.NotEqual(firstStartedGistsPage[2].Id, secondStartedGistsPage[2].Id);
|
||||
Assert.NotEqual(firstStartedGistsPage[3].Id, secondStartedGistsPage[3].Id);
|
||||
Assert.NotEqual(firstStartedGistsPage[4].Id, secondStartedGistsPage[4].Id);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsStartedGistsSince()
|
||||
{
|
||||
var since = new DateTimeOffset(new DateTime(2016, 1, 1));
|
||||
var gists = await _gistsClient.GetAllStarred(since).ToList();
|
||||
|
||||
Assert.NotEmpty(gists);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfStartedGistsSinceWithoutStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 5,
|
||||
PageCount = 1
|
||||
};
|
||||
var since = new DateTimeOffset(new DateTime(2016, 1, 1));
|
||||
var gists = await _gistsClient.GetAllStarred(since, options).ToList();
|
||||
|
||||
Assert.Equal(5, gists.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfStartedGistsSinceWithStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 5,
|
||||
PageCount = 1,
|
||||
StartPage = 2
|
||||
};
|
||||
var since = new DateTimeOffset(new DateTime(2016, 1, 1));
|
||||
var gists = await _gistsClient.GetAllStarred(since, options).ToList();
|
||||
|
||||
Assert.Equal(5, gists.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsDistinctStartedGistsSinceBasedOnStartPage()
|
||||
{
|
||||
var startOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 5,
|
||||
PageCount = 1
|
||||
};
|
||||
var since = new DateTimeOffset(new DateTime(2016, 1, 1));
|
||||
var firstStartedGistsPage = await _gistsClient.GetAllStarred(since, startOptions).ToList();
|
||||
|
||||
var skipStartOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 5,
|
||||
PageCount = 1,
|
||||
StartPage = 2
|
||||
};
|
||||
|
||||
var secondStartedGistsPage = await _gistsClient.GetAllStarred(since, skipStartOptions).ToList();
|
||||
|
||||
Assert.NotEqual(firstStartedGistsPage[0].Id, secondStartedGistsPage[0].Id);
|
||||
Assert.NotEqual(firstStartedGistsPage[1].Id, secondStartedGistsPage[1].Id);
|
||||
Assert.NotEqual(firstStartedGistsPage[2].Id, secondStartedGistsPage[2].Id);
|
||||
Assert.NotEqual(firstStartedGistsPage[3].Id, secondStartedGistsPage[3].Id);
|
||||
Assert.NotEqual(firstStartedGistsPage[4].Id, secondStartedGistsPage[4].Id);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetAllForUserMethod
|
||||
{
|
||||
readonly ObservableGistsClient _gistsClient;
|
||||
const string user = "shiftkey";
|
||||
|
||||
public TheGetAllForUserMethod()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
|
||||
_gistsClient = new ObservableGistsClient(github);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsUserGists()
|
||||
{
|
||||
var gists = await _gistsClient.GetAllForUser(user).ToList();
|
||||
|
||||
Assert.NotEmpty(gists);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfUserGistsWithoutStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 3,
|
||||
PageCount = 1
|
||||
};
|
||||
|
||||
var gists = await _gistsClient.GetAllForUser(user, options).ToList();
|
||||
|
||||
Assert.Equal(3, gists.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfUserGistsWithStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 3,
|
||||
PageCount = 1,
|
||||
StartPage = 2
|
||||
};
|
||||
|
||||
var gists = await _gistsClient.GetAllForUser(user, options).ToList();
|
||||
|
||||
Assert.Equal(3, gists.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsDistinctResultsBasedOnStartPage()
|
||||
{
|
||||
var startOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 3,
|
||||
PageCount = 1
|
||||
};
|
||||
|
||||
var firstUsersGistsPage = await _gistsClient.GetAllForUser(user, startOptions).ToList();
|
||||
|
||||
var skipStartOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 3,
|
||||
PageCount = 1,
|
||||
StartPage = 2
|
||||
};
|
||||
|
||||
var secondUsersGistsPage = await _gistsClient.GetAllForUser(user, skipStartOptions).ToList();
|
||||
|
||||
Assert.NotEqual(firstUsersGistsPage[0].Id, secondUsersGistsPage[0].Id);
|
||||
Assert.NotEqual(firstUsersGistsPage[1].Id, secondUsersGistsPage[1].Id);
|
||||
Assert.NotEqual(firstUsersGistsPage[2].Id, secondUsersGistsPage[2].Id);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsUserGistsSince()
|
||||
{
|
||||
var since = new DateTimeOffset(new DateTime(2016, 1, 1));
|
||||
var gists = await _gistsClient.GetAllForUser(user, since).ToList();
|
||||
|
||||
Assert.NotEmpty(gists);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfUserGistsSinceWithoutStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 3,
|
||||
PageCount = 1
|
||||
};
|
||||
var since = new DateTimeOffset(new DateTime(2016, 1, 1));
|
||||
var gists = await _gistsClient.GetAllForUser(user, since, options).ToList();
|
||||
|
||||
Assert.Equal(3, gists.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfUserGistsSinceWithStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 3,
|
||||
PageCount = 1,
|
||||
StartPage = 2
|
||||
};
|
||||
var since = new DateTimeOffset(new DateTime(2016, 1, 1));
|
||||
var gists = await _gistsClient.GetAllForUser(user, since, options).ToList();
|
||||
|
||||
Assert.Equal(3, gists.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsDistinctUserGistsSinceBasedOnStartPage()
|
||||
{
|
||||
var startOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 3,
|
||||
PageCount = 1
|
||||
};
|
||||
var since = new DateTimeOffset(new DateTime(2016, 1, 1));
|
||||
var firstUserGistsPage = await _gistsClient.GetAllForUser(user, since, startOptions).ToList();
|
||||
|
||||
var skipStartOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 3,
|
||||
PageCount = 1,
|
||||
StartPage = 2
|
||||
};
|
||||
|
||||
var secondUserGistsPage = await _gistsClient.GetAllForUser(user, since, skipStartOptions).ToList();
|
||||
|
||||
Assert.NotEqual(firstUserGistsPage[0].Id, secondUserGistsPage[0].Id);
|
||||
Assert.NotEqual(firstUserGistsPage[1].Id, secondUserGistsPage[1].Id);
|
||||
Assert.NotEqual(firstUserGistsPage[2].Id, secondUserGistsPage[2].Id);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetAllCommitsMethod
|
||||
{
|
||||
readonly ObservableGistsClient _gistsClient;
|
||||
const string gistId = "670c22f3966e662d2f83";
|
||||
|
||||
public TheGetAllCommitsMethod()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
|
||||
_gistsClient = new ObservableGistsClient(github);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsGistCommits()
|
||||
{
|
||||
var gistCommits = await _gistsClient.GetAllCommits(gistId).ToList();
|
||||
|
||||
Assert.NotEmpty(gistCommits);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfGistCommisWithoutStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 3,
|
||||
PageCount = 1
|
||||
};
|
||||
|
||||
var gistCommits = await _gistsClient.GetAllCommits(gistId, options).ToList();
|
||||
|
||||
Assert.Equal(3, gistCommits.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountGistCommitsWithStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 3,
|
||||
PageCount = 1,
|
||||
StartPage = 2
|
||||
};
|
||||
|
||||
var gistCommits = await _gistsClient.GetAllCommits(gistId, options).ToList();
|
||||
|
||||
Assert.Equal(3, gistCommits.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsDistinctResultsBasedOnStartPage()
|
||||
{
|
||||
var startOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 3,
|
||||
PageCount = 1
|
||||
};
|
||||
|
||||
var firstGistCommitsPage = await _gistsClient.GetAllCommits(gistId, startOptions).ToList();
|
||||
|
||||
var skipStartOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 3,
|
||||
PageCount = 1,
|
||||
StartPage = 2
|
||||
};
|
||||
|
||||
var secondGistCommitsPage = await _gistsClient.GetAllCommits(gistId, skipStartOptions).ToList();
|
||||
|
||||
Assert.NotEqual(firstGistCommitsPage[0].Url, secondGistCommitsPage[0].Url);
|
||||
Assert.NotEqual(firstGistCommitsPage[1].Url, secondGistCommitsPage[1].Url);
|
||||
Assert.NotEqual(firstGistCommitsPage[2].Url, secondGistCommitsPage[2].Url);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetAllForksMethod
|
||||
{
|
||||
readonly ObservableGistsClient _gistsClient;
|
||||
const string gistId = "670c22f3966e662d2f83";
|
||||
|
||||
public TheGetAllForksMethod()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
|
||||
_gistsClient = new ObservableGistsClient(github);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsGistCommits()
|
||||
{
|
||||
var gistForks = await _gistsClient.GetAllForks(gistId).ToList();
|
||||
|
||||
Assert.NotEmpty(gistForks);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfGistForksWithoutStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 5,
|
||||
PageCount = 1
|
||||
};
|
||||
|
||||
var gistForks = await _gistsClient.GetAllForks(gistId, options).ToList();
|
||||
|
||||
Assert.Equal(5, gistForks.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountGistForksWithStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 5,
|
||||
PageCount = 1,
|
||||
StartPage = 2
|
||||
};
|
||||
|
||||
var gistForks = await _gistsClient.GetAllForks(gistId, options).ToList();
|
||||
|
||||
Assert.Equal(5, gistForks.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsDistinctResultsBasedOnStartPage()
|
||||
{
|
||||
var startOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 5,
|
||||
PageCount = 1
|
||||
};
|
||||
|
||||
var firstGistForksPage = await _gistsClient.GetAllForks(gistId, startOptions).ToList();
|
||||
|
||||
var skipStartOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 5,
|
||||
PageCount = 1,
|
||||
StartPage = 2
|
||||
};
|
||||
|
||||
var secondGistForksPage = await _gistsClient.GetAllForks(gistId, skipStartOptions).ToList();
|
||||
|
||||
Assert.NotEqual(firstGistForksPage[0].Url, secondGistForksPage[0].Url);
|
||||
Assert.NotEqual(firstGistForksPage[1].Url, secondGistForksPage[1].Url);
|
||||
Assert.NotEqual(firstGistForksPage[2].Url, secondGistForksPage[2].Url);
|
||||
Assert.NotEqual(firstGistForksPage[3].Url, secondGistForksPage[3].Url);
|
||||
Assert.NotEqual(firstGistForksPage[4].Url, secondGistForksPage[4].Url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reactive.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Octokit.Reactive;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Integration.Reactive
|
||||
{
|
||||
public class ObservableIssueCommentsClientTests
|
||||
{
|
||||
public class TheGetAllForRepositoryMethod
|
||||
{
|
||||
readonly ObservableIssueCommentsClient _issueCommentsClient;
|
||||
const string owner = "octokit";
|
||||
const string name = "octokit.net";
|
||||
|
||||
public TheGetAllForRepositoryMethod()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
|
||||
_issueCommentsClient = new ObservableIssueCommentsClient(github);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsIssueComments()
|
||||
{
|
||||
var issueComments = await _issueCommentsClient.GetAllForRepository(owner, name).ToList();
|
||||
|
||||
Assert.NotEmpty(issueComments);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfIssueCommentsWithoutStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 5,
|
||||
PageCount = 1
|
||||
};
|
||||
|
||||
var issueComments = await _issueCommentsClient.GetAllForRepository(owner, name, options).ToList();
|
||||
|
||||
Assert.Equal(5, issueComments.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfIssueCommentsWithStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 5,
|
||||
PageCount = 1,
|
||||
StartPage = 2
|
||||
};
|
||||
|
||||
var issueComments = await _issueCommentsClient.GetAllForRepository(owner, name, options).ToList();
|
||||
|
||||
Assert.Equal(5, issueComments.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsDistinctResultsBasedOnStartPage()
|
||||
{
|
||||
var startOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 5,
|
||||
PageCount = 1
|
||||
};
|
||||
|
||||
var firstPageIssueComments = await _issueCommentsClient.GetAllForRepository(owner, name, startOptions).ToList();
|
||||
|
||||
var skipStartOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 5,
|
||||
PageCount = 1,
|
||||
StartPage = 2
|
||||
};
|
||||
|
||||
var secondPageIssueComments = await _issueCommentsClient.GetAllForRepository(owner, name, skipStartOptions).ToList();
|
||||
|
||||
Assert.NotEqual(firstPageIssueComments[0].Id, secondPageIssueComments[0].Id);
|
||||
Assert.NotEqual(firstPageIssueComments[1].Id, secondPageIssueComments[1].Id);
|
||||
Assert.NotEqual(firstPageIssueComments[2].Id, secondPageIssueComments[2].Id);
|
||||
Assert.NotEqual(firstPageIssueComments[3].Id, secondPageIssueComments[3].Id);
|
||||
Assert.NotEqual(firstPageIssueComments[4].Id, secondPageIssueComments[4].Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
using System.Reactive.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Octokit;
|
||||
using Octokit.Reactive;
|
||||
using Octokit.Tests.Integration;
|
||||
using Xunit;
|
||||
using Octokit.Tests.Integration.Helpers;
|
||||
|
||||
public class ObservableRepositoryCollaboratorClientTests
|
||||
{
|
||||
public class TheGetAllMethod
|
||||
{
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsAllCollaborators()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var repoName = Helper.MakeNameWithTimestamp("public-repo");
|
||||
|
||||
using (var context = await github.CreateRepositoryContext(new NewRepository(repoName)))
|
||||
{
|
||||
var fixture = new ObservableRepoCollaboratorsClient(github);
|
||||
|
||||
// add a collaborator
|
||||
await fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests");
|
||||
|
||||
var collaborators = await fixture.GetAll(context.RepositoryOwner, context.RepositoryName).ToList();
|
||||
Assert.NotNull(collaborators);
|
||||
Assert.Equal(2, collaborators.Count);
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfCollaboratorsWithoutStart()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var repoName = Helper.MakeNameWithTimestamp("public-repo");
|
||||
|
||||
using (var context = await github.CreateRepositoryContext(new NewRepository(repoName)))
|
||||
{
|
||||
var fixture = new ObservableRepoCollaboratorsClient(github);
|
||||
|
||||
// add some collaborators
|
||||
await fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests");
|
||||
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 1,
|
||||
PageCount = 1
|
||||
};
|
||||
|
||||
var collaborators = await fixture.GetAll(context.RepositoryOwner, context.RepositoryName, options).ToList();
|
||||
Assert.NotNull(collaborators);
|
||||
Assert.Equal(1, collaborators.Count);
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfCollaboratorsWithStart()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var repoName = Helper.MakeNameWithTimestamp("public-repo");
|
||||
|
||||
using (var context = await github.CreateRepositoryContext(new NewRepository(repoName)))
|
||||
{
|
||||
var fixture = new ObservableRepoCollaboratorsClient(github);
|
||||
|
||||
// add some collaborators
|
||||
await fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests");
|
||||
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 1,
|
||||
PageCount = 1,
|
||||
StartPage = 2
|
||||
};
|
||||
|
||||
var collaborators = await fixture.GetAll(context.RepositoryOwner, context.RepositoryName, options).ToList();
|
||||
Assert.NotNull(collaborators);
|
||||
Assert.Equal(1, collaborators.Count);
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsDistinctResultsBasedOnStartPage()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var repoName = Helper.MakeNameWithTimestamp("public-repo");
|
||||
|
||||
using (var context = await github.CreateRepositoryContext(new NewRepository(repoName)))
|
||||
{
|
||||
var fixture = new ObservableRepoCollaboratorsClient(github);
|
||||
|
||||
// add some collaborators
|
||||
await fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests");
|
||||
|
||||
var startOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 1,
|
||||
PageCount = 1
|
||||
};
|
||||
|
||||
var firstPage = await fixture.GetAll(context.RepositoryOwner, context.RepositoryName, startOptions).ToList();
|
||||
|
||||
var skipStartOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 1,
|
||||
PageCount = 1,
|
||||
StartPage = 2
|
||||
};
|
||||
|
||||
var secondPage = await fixture.GetAll(context.RepositoryOwner, context.RepositoryName, skipStartOptions).ToList();
|
||||
|
||||
Assert.NotEqual(firstPage[0].Id, secondPage[0].Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class TheIsCollaboratorMethod
|
||||
{
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsTrueIfUserIsCollaborator()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var repoName = Helper.MakeNameWithTimestamp("public-repo");
|
||||
|
||||
using (var context = await github.CreateRepositoryContext(new NewRepository(repoName)))
|
||||
{
|
||||
var fixture = new ObservableRepoCollaboratorsClient(github);
|
||||
|
||||
// add a collaborator
|
||||
fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests");
|
||||
|
||||
var isCollab = await fixture.IsCollaborator(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests");
|
||||
|
||||
Assert.True(isCollab);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ namespace Octokit.Tests.Integration.Reactive
|
||||
var startOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 5,
|
||||
PageCount = 1,
|
||||
PageCount = 1
|
||||
};
|
||||
|
||||
var skipStartOptions = new ApiOptions
|
||||
|
||||
@@ -28,7 +28,7 @@ public class ObservableRespositoryDeployKeysClientTests : IDisposable
|
||||
[IntegrationTest(Skip = "see https://github.com/octokit/octokit.net/issues/533 for investigating this failing test")]
|
||||
public async Task CanCreateADeployKey()
|
||||
{
|
||||
var deployKey = new NewDeployKey()
|
||||
var deployKey = new NewDeployKey
|
||||
{
|
||||
Key = _key,
|
||||
Title = _keyTitle
|
||||
@@ -48,7 +48,7 @@ public class ObservableRespositoryDeployKeysClientTests : IDisposable
|
||||
var deployKeys = await _client.GetAll(_owner, _repository.Name).ToList();
|
||||
Assert.Empty(deployKeys);
|
||||
|
||||
var deployKey = new NewDeployKey()
|
||||
var deployKey = new NewDeployKey
|
||||
{
|
||||
Key = _key,
|
||||
Title = _keyTitle
|
||||
@@ -64,7 +64,7 @@ public class ObservableRespositoryDeployKeysClientTests : IDisposable
|
||||
[IntegrationTest(Skip = "see https://github.com/octokit/octokit.net/issues/533 for investigating this failing test")]
|
||||
public async Task CanRetrieveADeployKey()
|
||||
{
|
||||
var newDeployKey = new NewDeployKey()
|
||||
var newDeployKey = new NewDeployKey
|
||||
{
|
||||
Key = _key,
|
||||
Title = _keyTitle
|
||||
@@ -82,7 +82,7 @@ public class ObservableRespositoryDeployKeysClientTests : IDisposable
|
||||
[IntegrationTest(Skip = "see https://github.com/octokit/octokit.net/issues/533 for investigating this failing test")]
|
||||
public async Task CanRemoveADeployKey()
|
||||
{
|
||||
var newDeployKey = new NewDeployKey()
|
||||
var newDeployKey = new NewDeployKey
|
||||
{
|
||||
Key = _key,
|
||||
Title = _keyTitle
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
using System.Reactive.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Octokit.Reactive;
|
||||
using Octokit.Tests.Integration.fixtures;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Integration.Reactive
|
||||
{
|
||||
public class ObservableRepositoryHooksClientTests
|
||||
{
|
||||
[Collection(RepositoriesHooksCollection.Name)]
|
||||
public class TheGetAllMethod
|
||||
{
|
||||
readonly RepositoriesHooksFixture _fixture;
|
||||
|
||||
public TheGetAllMethod(RepositoriesHooksFixture fixture)
|
||||
{
|
||||
_fixture = fixture;
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsAllHooksFromRepository()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
|
||||
var client = new ObservableRepositoryHooksClient(github);
|
||||
|
||||
var hooks = await client.GetAll(_fixture.RepositoryOwner, _fixture.RepositoryName).ToList();
|
||||
|
||||
Assert.Equal(_fixture.ExpectedHooks.Count, hooks.Count);
|
||||
|
||||
var actualHook = hooks[0];
|
||||
AssertHook(_fixture.ExpectedHook, actualHook);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfHooksWithoutStart()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
|
||||
var client = new ObservableRepositoryHooksClient(github);
|
||||
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 5,
|
||||
PageCount = 1
|
||||
};
|
||||
|
||||
var hooks = await client.GetAll(_fixture.RepositoryOwner, _fixture.RepositoryName, options).ToList();
|
||||
|
||||
Assert.Equal(_fixture.ExpectedHooks.Count, hooks.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfHooksWithStart()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
|
||||
var client = new ObservableRepositoryHooksClient(github);
|
||||
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 2,
|
||||
PageCount = 1,
|
||||
StartPage = 3
|
||||
};
|
||||
|
||||
var hooks = await client.GetAll(_fixture.RepositoryOwner, _fixture.RepositoryName, options).ToList();
|
||||
|
||||
Assert.Equal(1, hooks.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsDistinctResultsBasedOnStartPage()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
|
||||
var client = new ObservableRepositoryHooksClient(github);
|
||||
|
||||
var startOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 2,
|
||||
PageCount = 1
|
||||
};
|
||||
|
||||
var firstPage = await client.GetAll(_fixture.RepositoryOwner, _fixture.RepositoryName, startOptions).ToList();
|
||||
|
||||
var skipStartOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 2,
|
||||
PageCount = 1,
|
||||
StartPage = 2
|
||||
};
|
||||
|
||||
var secondPage = await client.GetAll(_fixture.RepositoryOwner, _fixture.RepositoryName, skipStartOptions).ToList();
|
||||
|
||||
Assert.NotEqual(firstPage[0].Id, secondPage[0].Id);
|
||||
Assert.NotEqual(firstPage[1].Id, secondPage[1].Id);
|
||||
}
|
||||
|
||||
static void AssertHook(RepositoryHook expectedHook, RepositoryHook actualHook)
|
||||
{
|
||||
Assert.Equal(expectedHook.Id, actualHook.Id);
|
||||
Assert.Equal(expectedHook.Active, actualHook.Active);
|
||||
Assert.Equal(expectedHook.Config, actualHook.Config);
|
||||
Assert.Equal(expectedHook.CreatedAt, actualHook.CreatedAt);
|
||||
Assert.Equal(expectedHook.Name, actualHook.Name);
|
||||
Assert.Equal(expectedHook.PingUrl, actualHook.PingUrl);
|
||||
Assert.Equal(expectedHook.TestUrl, actualHook.TestUrl);
|
||||
Assert.Equal(expectedHook.UpdatedAt, actualHook.UpdatedAt);
|
||||
Assert.Equal(expectedHook.Url, actualHook.Url);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -94,7 +94,7 @@ namespace Octokit.Tests.Integration.Clients
|
||||
// Create Impersonation token
|
||||
var observable = _github.User.Administration.CreateImpersonationToken(
|
||||
context.UserLogin,
|
||||
new NewImpersonationToken(new string[] { "public_repo" }));
|
||||
new NewImpersonationToken(new[] { "public_repo" }));
|
||||
var token = await observable;
|
||||
|
||||
Assert.NotNull(token);
|
||||
@@ -174,7 +174,7 @@ namespace Octokit.Tests.Integration.Clients
|
||||
|
||||
// Get public keys
|
||||
var observable = _github.User.Administration.ListAllPublicKeys();
|
||||
var keys = await (observable.ToList());
|
||||
var keys = await observable.ToList();
|
||||
|
||||
Assert.NotNull(keys);
|
||||
Assert.True(keys.Count > 0);
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Octokit.Tests.Integration.Clients
|
||||
using (var context = await _github.CreatePublicKeyContext())
|
||||
{
|
||||
var observable = _github.User.Keys.GetAllForCurrent();
|
||||
var keys = await (observable.ToList());
|
||||
var keys = await observable.ToList();
|
||||
|
||||
Assert.NotEmpty(keys);
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Octokit.Tests.Integration.Clients
|
||||
public async Task CanGetAllForGivenUser()
|
||||
{
|
||||
var observable = _github.User.Keys.GetAll("shiftkey");
|
||||
var keys = await (observable.ToList());
|
||||
var keys = await observable.ToList();
|
||||
|
||||
Assert.NotEmpty(keys);
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace Octokit.Tests.Integration.Clients
|
||||
await _github.User.Keys.Delete(key.Id);
|
||||
|
||||
// Verify key no longer exists
|
||||
var keys = await (_github.User.Keys.GetAllForCurrent().ToList());
|
||||
var keys = await _github.User.Keys.GetAllForCurrent().ToList();
|
||||
Assert.False(keys.Any(k => k.Title == keyTitle && k.Key == keyData));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user