Files
octokit.net/Octokit.Tests.Integration/Reactive/ObservableIssuesClientTests.cs
Haacked a94051d6b0 Repository name is required when creating a repo
I was trying to create a repository and I wasn't sure which parameters
were required. Following our philosophy of exposing required parameters
in the constructor, I change the `NewRepository` object to take in a
repository name and to make that property readonly.
2015-03-19 16:25:03 -07:00

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.GetForRepository("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);
}
}