mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-20 14:15:12 +00:00
81 lines
2.5 KiB
C#
81 lines
2.5 KiB
C#
using Octokit;
|
|
using Octokit.Reactive;
|
|
using System;
|
|
using System.Reactive.Linq;
|
|
using System.Threading.Tasks;
|
|
using Octokit.Tests.Integration;
|
|
using Xunit;
|
|
|
|
public class ObservableIssuesClientTests : IDisposable
|
|
{
|
|
readonly ObservableIssuesClient _client;
|
|
readonly string _repoName;
|
|
readonly Repository _createdRepository;
|
|
|
|
public ObservableIssuesClientTests()
|
|
{
|
|
var github = Helper.GetAuthenticatedClient();
|
|
|
|
_client = new ObservableIssuesClient(github);
|
|
_repoName = Helper.MakeNameWithTimestamp("public-repo");
|
|
var result = github.Repository.Create(new NewRepository(_repoName)).Result;
|
|
_createdRepository = 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 ReturnsAllIssuesForARepository()
|
|
{
|
|
var issues = await _client.GetAllForRepository("libgit2", "libgit2sharp").ToList();
|
|
|
|
Assert.NotEmpty(issues);
|
|
}
|
|
|
|
[IntegrationTest]
|
|
public async Task ReturnsAllIssuesForCurrentUser()
|
|
{
|
|
var newIssue = new NewIssue("Integration test issue") { Assignee = _createdRepository.Owner.Login };
|
|
await _client.Create(_createdRepository.Owner.Login, _repoName, newIssue);
|
|
|
|
var issues = await _client.GetAllForCurrent().ToList();
|
|
|
|
Assert.NotEmpty(issues);
|
|
}
|
|
|
|
[IntegrationTest]
|
|
public async Task ReturnsAllIssuesForOwnedAndMemberRepositories()
|
|
{
|
|
var newIssue = new NewIssue("Integration test issue") { Assignee = _createdRepository.Owner.Login };
|
|
await _client.Create(_createdRepository.Owner.Login, _repoName, 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(_createdRepository.Owner.Login, _repoName, newIssue);
|
|
var updateResult = await _client.Update(_createdRepository.Owner.Login, _repoName, createResult.Number, new IssueUpdate { Title = "Modified integration test issue" });
|
|
|
|
Assert.Equal("Modified integration test issue", updateResult.Title);
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
Helper.DeleteRepo(_createdRepository);
|
|
}
|
|
}
|
|
|