Files
octokit.net/Octokit.Tests.Integration/Reactive/ObservableIssuesClientTests.cs
Ryan Gribble 3c818934b8 Release v0.24 - A Sight For Sore Eyes (#1539)
* Add release notes and bump version to 0.24

* run "build FormatCode" to fix up whitespace/formatting issues

* Fix failing Ssh key tests due to "validation exception".  This key must be in use on github (under another user, most likely from these tests failing).  Changed to a new SSH key and tweaked tests to reduce chance of a key being created and not destroyed

* Assignee and Assignees cant both be specified on NewIssue.  We missed this one in the PR.  Marked Assignee as [Obsolete] and fixed tests to use Assignees

* Fix a couple of Reactions tests that were calling the wrong client methods

* Fix timeline tests - looks like the response class has changed shape a bit, it now has an Issue object in the payload and Id field isnt present (leaving Id field there in case other timeline events do use it)

* Fix some following tests that require the test user to follow more than 1 other user

* Unskip these Event tests now because apparently they work!

* add breaking changes notes

* Update ApiErrorMessageSafe to return null for empty and whitespace strings (#1540)

* return null if ApiError.Message is empty or whitespace

* Uncomment test, which now passes

* update release notes to include PR1540

* Add "Bot" AccountType, was causing a deserialization exception when running the integration test "SearchForExcludedLanguage" (#1541)

* Update to include PR1541

* add bullets to make release notes easier to read

* markup additional code mentions in notes

* Fix grammar

fields => field
2017-01-17 18:56:55 +10:00

136 lines
4.4 KiB
C#

using Octokit;
using Octokit.Reactive;
using System;
using System.Reactive.Linq;
using System.Threading.Tasks;
using Octokit.Tests.Integration;
using Xunit;
using Octokit.Tests.Integration.Helpers;
public class ObservableIssuesClientTests : IDisposable
{
private readonly RepositoryContext _context;
private readonly ObservableIssuesClient _client;
public ObservableIssuesClientTests()
{
var github = Helper.GetAuthenticatedClient();
_client = new ObservableIssuesClient(github);
var repoName = Helper.MakeNameWithTimestamp("public-repo");
_context = github.CreateRepositoryContext(new NewRepository(repoName)).Result;
}
[IntegrationTest]
public async Task ReturnsSpecifiedIssue()
{
var observable = _client.Get("libgit2", "libgit2sharp", 1);
var issue = await observable;
Assert.Equal(1, issue.Number);
Assert.Equal("Change License ", issue.Title);
}
[IntegrationTest]
public async Task ReturnsPageOfIssuesForARepository()
{
var options = new ApiOptions
{
PageSize = 5,
PageCount = 1
};
var issues = await _client.GetAllForRepository("libgit2", "libgit2sharp", options).ToList();
Assert.Equal(5, issues.Count);
}
[IntegrationTest]
public async Task ReturnsPageOfIssuesFromStartForARepository()
{
var first = new ApiOptions
{
PageSize = 5,
PageCount = 1
};
var firstPage = await _client.GetAllForRepository("libgit2", "libgit2sharp", first).ToList();
var second = new ApiOptions
{
PageSize = 5,
PageCount = 1,
StartPage = 2
};
var secondPage = await _client.GetAllForRepository("libgit2", "libgit2sharp", second).ToList();
Assert.Equal(5, firstPage.Count);
Assert.Equal(5, secondPage.Count);
Assert.NotEqual(firstPage[0].Id, secondPage[0].Id);
Assert.NotEqual(firstPage[1].Id, secondPage[1].Id);
Assert.NotEqual(firstPage[2].Id, secondPage[2].Id);
Assert.NotEqual(firstPage[3].Id, secondPage[3].Id);
Assert.NotEqual(firstPage[4].Id, secondPage[4].Id);
}
[IntegrationTest]
public async Task ReturnsAllIssuesForCurrentUser()
{
var newIssue = new NewIssue("Integration test issue");
newIssue.Assignees.Add(_context.RepositoryOwner);
await _client.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue);
var issues = await _client.GetAllForCurrent().ToList();
Assert.NotEmpty(issues);
}
[IntegrationTest]
public async Task ReturnsAllIssuesForOwnedAndMemberRepositories()
{
var newIssue = new NewIssue("Integration test issue");
newIssue.Assignees.Add(_context.RepositoryOwner);
await _client.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue);
var result = await _client.GetAllForOwnedAndMemberRepositories().ToList();
Assert.NotEmpty(result);
}
[IntegrationTest]
public async Task CanCreateAndUpdateIssues()
{
var newIssue = new NewIssue("Integration test issue");
var createResult = await _client.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue);
var updateResult = await _client.Update(_context.RepositoryOwner, _context.RepositoryName, createResult.Number, new IssueUpdate { Title = "Modified integration test issue" });
Assert.Equal("Modified integration test issue", updateResult.Title);
}
[IntegrationTest]
public async Task CanLockAndUnlockIssues()
{
var newIssue = new NewIssue("Integration Test Issue");
var createResult = await _client.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue);
Assert.False(createResult.Locked);
await _client.Lock(_context.RepositoryOwner, _context.RepositoryName, createResult.Number);
var lockResult = await _client.Get(_context.RepositoryOwner, _context.RepositoryName, createResult.Number);
Assert.True(lockResult.Locked);
await _client.Unlock(_context.RepositoryOwner, _context.RepositoryName, createResult.Number);
var unlockIssueResult = await _client.Get(_context.RepositoryOwner, _context.RepositoryName, createResult.Number);
Assert.False(unlockIssueResult.Locked);
}
public void Dispose()
{
_context.Dispose();
}
}