mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-05 11:40:42 +00:00
@@ -1,85 +1,84 @@
|
||||
using Octokit.Reactive;
|
||||
using Octokit;
|
||||
using Octokit.Reactive;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Reactive.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Octokit.Tests.Integration;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Integration
|
||||
public class ObservableIssuesClientTests : IDisposable
|
||||
{
|
||||
public class ObservableIssuesClientTests : IDisposable
|
||||
readonly ObservableIssuesClient _client;
|
||||
readonly string _repoName;
|
||||
readonly Repository _createdRepository;
|
||||
|
||||
public ObservableIssuesClientTests()
|
||||
{
|
||||
readonly ObservableIssuesClient client;
|
||||
readonly string repoName;
|
||||
readonly Repository createdRepository;
|
||||
|
||||
public ObservableIssuesClientTests()
|
||||
var github = new GitHubClient(new ProductHeaderValue("OctokitTests"))
|
||||
{
|
||||
var github = new GitHubClient(new ProductHeaderValue("OctokitTests"))
|
||||
{
|
||||
Credentials = Helper.Credentials
|
||||
};
|
||||
Credentials = Helper.Credentials
|
||||
};
|
||||
|
||||
client = new ObservableIssuesClient(github);
|
||||
repoName = Helper.MakeNameWithTimestamp("public-repo");
|
||||
var result = github.Repository.Create(new NewRepository { Name = repoName }).Result;
|
||||
createdRepository = result;
|
||||
}
|
||||
_client = new ObservableIssuesClient(github);
|
||||
_repoName = Helper.MakeNameWithTimestamp("public-repo");
|
||||
var result = github.Repository.Create(new NewRepository { Name = _repoName }).Result;
|
||||
_createdRepository = result;
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsSpecifiedIssue()
|
||||
{
|
||||
var observable = client.Get("libgit2", "libgit2sharp", 1);
|
||||
var issue = await observable;
|
||||
[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);
|
||||
}
|
||||
Assert.Equal(1, issue.Number);
|
||||
Assert.Equal("Change License ", issue.Title);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public void ReturnsAllIssuesForARepository()
|
||||
{
|
||||
var issues = client.GetForRepository("libgit2", "libgit2sharp").ToList().Wait();
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsAllIssuesForARepository()
|
||||
{
|
||||
var issues = await _client.GetForRepository("libgit2", "libgit2sharp").ToList();
|
||||
|
||||
Assert.NotEmpty(issues);
|
||||
}
|
||||
Assert.NotEmpty(issues);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async void ReturnsAllIssuesForCurrentUser()
|
||||
{
|
||||
var newIssue = new NewIssue("Integration test issue");
|
||||
var createResult = await client.Create(createdRepository.Owner.Name, repoName, newIssue);
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsAllIssuesForCurrentUser()
|
||||
{
|
||||
var newIssue = new NewIssue("Integration test issue");
|
||||
await _client.Create(_createdRepository.Owner.Name, _repoName, newIssue);
|
||||
|
||||
var issues = client.GetAllForCurrent().ToList().Wait();
|
||||
var issues = await _client.GetAllForCurrent().ToList();
|
||||
|
||||
Assert.NotEmpty(issues);
|
||||
}
|
||||
Assert.NotEmpty(issues);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async void ReturnsAllIssuesForOwnedAndMemberRepositories()
|
||||
{
|
||||
var newIssue = new NewIssue("Integration test issue");
|
||||
var createResult = await client.Create(createdRepository.Owner.Name, repoName, newIssue);
|
||||
var result = client.GetAllForOwnedAndMemberRepositories().ToList().Wait();
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsAllIssuesForOwnedAndMemberRepositories()
|
||||
{
|
||||
var newIssue = new NewIssue("Integration test issue");
|
||||
await _client.Create(_createdRepository.Owner.Name, _repoName, newIssue);
|
||||
var result = await _client.GetAllForOwnedAndMemberRepositories().ToList();
|
||||
|
||||
Assert.NotEmpty(result);
|
||||
}
|
||||
Assert.NotEmpty(result);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async void CanCreateAndUpdateIssues()
|
||||
{
|
||||
var newIssue = new NewIssue("Integration test issue");
|
||||
[IntegrationTest]
|
||||
public async Task CanCreateAndUpdateIssues()
|
||||
{
|
||||
var newIssue = new NewIssue("Integration test issue");
|
||||
|
||||
var createResult = await client.Create(createdRepository.Owner.Name, repoName, newIssue);
|
||||
var updateResult = await client.Update(createdRepository.Owner.Name, repoName, createResult.Number, new IssueUpdate { Title = "Modified integration test issue" });
|
||||
var createResult = await _client.Create(_createdRepository.Owner.Name, _repoName, newIssue);
|
||||
var updateResult = await _client.Update(_createdRepository.Owner.Name, _repoName, createResult.Number, new IssueUpdate { Title = "Modified integration test issue" });
|
||||
|
||||
Assert.Equal("Modified integration test issue", updateResult.Title);
|
||||
}
|
||||
Assert.Equal("Modified integration test issue", updateResult.Title);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Helper.DeleteRepo(createdRepository);
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
Helper.DeleteRepo(_createdRepository);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,14 +28,14 @@ namespace Octokit.Tests.Integration
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public void ReturnsAllMilestones()
|
||||
public async Task ReturnsAllMilestones()
|
||||
{
|
||||
var github = new GitHubClient(new ProductHeaderValue("OctokitTests"))
|
||||
{
|
||||
Credentials = Helper.Credentials
|
||||
};
|
||||
var client = new ObservableMilestonesClient(github);
|
||||
var milestones = client.GetForRepository("libgit2", "libgit2sharp", new MilestoneRequest { State = ItemState.Closed }).ToList().Wait();
|
||||
var milestones = await client.GetForRepository("libgit2", "libgit2sharp", new MilestoneRequest { State = ItemState.Closed }).ToList();
|
||||
|
||||
Assert.NotEmpty(milestones);
|
||||
Assert.True(milestones.All(m => m.State == ItemState.Closed));
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using NSubstitute;
|
||||
using Octokit;
|
||||
using Octokit.Internal;
|
||||
using Octokit.Reactive;
|
||||
using Octokit.Tests.Helpers;
|
||||
@@ -8,8 +9,6 @@ using System.Reactive.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Reactive
|
||||
{
|
||||
public class ObservableIssuesClientTests
|
||||
{
|
||||
public class TheGetMethod
|
||||
@@ -40,7 +39,7 @@ namespace Octokit.Tests.Reactive
|
||||
public class TheGetForRepositoryMethod
|
||||
{
|
||||
[Fact]
|
||||
public void ReturnsEveryPageOfIssues()
|
||||
public async Task ReturnsEveryPageOfIssues()
|
||||
{
|
||||
var firstPageUrl = new Uri("repos/fake/repo/issues", UriKind.Relative);
|
||||
var secondPageUrl = new Uri("https://example.com/page/2");
|
||||
@@ -89,7 +88,7 @@ namespace Octokit.Tests.Reactive
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<Issue>>>(() => lastPageResponse));
|
||||
var client = new ObservableIssuesClient(gitHubClient);
|
||||
|
||||
var results = client.GetForRepository("fake", "repo").ToArray().Wait();
|
||||
var results = await client.GetForRepository("fake", "repo").ToArray();
|
||||
|
||||
Assert.Equal(7, results.Length);
|
||||
Assert.Equal(firstPageResponse.BodyAsObject[0].Number, results[0].Number);
|
||||
@@ -101,7 +100,7 @@ namespace Octokit.Tests.Reactive
|
||||
public class TheGetAllForOwnedAndMemberRepositoriesMethod
|
||||
{
|
||||
[Fact]
|
||||
public void ReturnsEveryPageOfIssues()
|
||||
public async Task ReturnsEveryPageOfIssues()
|
||||
{
|
||||
var firstPageUrl = new Uri("user/issues", UriKind.Relative);
|
||||
var secondPageUrl = new Uri("https://example.com/page/2");
|
||||
@@ -150,7 +149,7 @@ namespace Octokit.Tests.Reactive
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<Issue>>>(() => lastPageResponse));
|
||||
var client = new ObservableIssuesClient(gitHubClient);
|
||||
|
||||
var results = client.GetAllForOwnedAndMemberRepositories().ToArray().Wait();
|
||||
var results = await client.GetAllForOwnedAndMemberRepositories().ToArray();
|
||||
|
||||
Assert.Equal(7, results.Length);
|
||||
Assert.Equal(firstPageResponse.BodyAsObject[0].Number, results[0].Number);
|
||||
@@ -162,7 +161,7 @@ namespace Octokit.Tests.Reactive
|
||||
public class TheGetAllForOrganizationMethod
|
||||
{
|
||||
[Fact]
|
||||
public void ReturnsEveryPageOfIssues()
|
||||
public async Task ReturnsEveryPageOfIssues()
|
||||
{
|
||||
var firstPageUrl = new Uri("orgs/test/issues", UriKind.Relative);
|
||||
var secondPageUrl = new Uri("https://example.com/page/2");
|
||||
@@ -211,7 +210,7 @@ namespace Octokit.Tests.Reactive
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<Issue>>>(() => lastPageResponse));
|
||||
var client = new ObservableIssuesClient(gitHubClient);
|
||||
|
||||
var results = client.GetAllForOrganization("test").ToArray().Wait();
|
||||
var results = await client.GetAllForOrganization("test").ToArray();
|
||||
|
||||
Assert.Equal(7, results.Length);
|
||||
Assert.Equal(firstPageResponse.BodyAsObject[0].Number, results[0].Number);
|
||||
@@ -223,7 +222,7 @@ namespace Octokit.Tests.Reactive
|
||||
public class TheGetAllForCurrentMethod
|
||||
{
|
||||
[Fact]
|
||||
public void ReturnsEveryPageOfIssues()
|
||||
public async Task ReturnsEveryPageOfIssues()
|
||||
{
|
||||
var firstPageUrl = new Uri("issues", UriKind.Relative);
|
||||
var secondPageUrl = new Uri("https://example.com/page/2");
|
||||
@@ -272,7 +271,7 @@ namespace Octokit.Tests.Reactive
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<Issue>>>(() => lastPageResponse));
|
||||
var client = new ObservableIssuesClient(gitHubClient);
|
||||
|
||||
var results = client.GetAllForCurrent().ToArray().Wait();
|
||||
var results = await client.GetAllForCurrent().ToArray();
|
||||
|
||||
Assert.Equal(7, results.Length);
|
||||
Assert.Equal(firstPageResponse.BodyAsObject[0].Number, results[0].Number);
|
||||
@@ -319,13 +318,13 @@ namespace Octokit.Tests.Reactive
|
||||
[Fact]
|
||||
public void UpdatesClientIssueIssue()
|
||||
{
|
||||
var IssueUpdate = new IssueUpdate();
|
||||
var issueUpdate = new IssueUpdate();
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableIssuesClient(gitHubClient);
|
||||
|
||||
client.Update("fake", "repo", 42, IssueUpdate);
|
||||
client.Update("fake", "repo", 42, issueUpdate);
|
||||
|
||||
gitHubClient.Issue.Received().Update("fake", "repo", 42, IssueUpdate);
|
||||
gitHubClient.Issue.Received().Update("fake", "repo", 42, issueUpdate);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -361,4 +360,3 @@ namespace Octokit.Tests.Reactive
|
||||
return new ApiInfo(links, new List<string>(), new List<string>(), "etag", new RateLimit(new Dictionary<string, string>()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Octokit.Tests.Reactive
|
||||
public class TheGetForRepositoryMethod
|
||||
{
|
||||
[Fact]
|
||||
public void ReturnsEveryPageOfMilestones()
|
||||
public async Task ReturnsEveryPageOfMilestones()
|
||||
{
|
||||
var firstPageUrl = new Uri("repos/fake/repo/milestones", UriKind.Relative);
|
||||
var secondPageUrl = new Uri("https://example.com/page/2");
|
||||
@@ -85,7 +85,7 @@ namespace Octokit.Tests.Reactive
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<Milestone>>>(() => lastPageResponse));
|
||||
var client = new ObservableMilestonesClient(gitHubClient);
|
||||
|
||||
var results = client.GetForRepository("fake", "repo").ToArray().Wait();
|
||||
var results = await client.GetForRepository("fake", "repo").ToArray();
|
||||
|
||||
Assert.Equal(7, results.Length);
|
||||
Assert.Equal(firstPageResponse.BodyAsObject[0].Number, results[0].Number);
|
||||
@@ -94,7 +94,7 @@ namespace Octokit.Tests.Reactive
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SendsAppropriateParameters()
|
||||
public async Task SendsAppropriateParameters()
|
||||
{
|
||||
var firstPageUrl = new Uri("repos/fake/repo/milestones", UriKind.Relative);
|
||||
var secondPageUrl = new Uri("https://example.com/page/2");
|
||||
@@ -142,7 +142,7 @@ namespace Octokit.Tests.Reactive
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<Milestone>>>(() => lastPageResponse));
|
||||
var client = new ObservableMilestonesClient(gitHubClient);
|
||||
|
||||
var results = client.GetForRepository("fake", "repo", new MilestoneRequest { SortDirection = SortDirection.Descending }).ToArray().Wait();
|
||||
var results = await client.GetForRepository("fake", "repo", new MilestoneRequest { SortDirection = SortDirection.Descending }).ToArray();
|
||||
|
||||
Assert.Equal(7, results.Length);
|
||||
Assert.Equal(firstPageResponse.BodyAsObject[0].Number, results[0].Number);
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace Octokit.Tests.Reactive
|
||||
public class TheGetAllForCurrentMethod
|
||||
{
|
||||
[Fact]
|
||||
public void ReturnsEveryPageOfRepositories()
|
||||
public async Task ReturnsEveryPageOfRepositories()
|
||||
{
|
||||
var firstPageUrl = new Uri("user/repos", UriKind.Relative);
|
||||
var secondPageUrl = new Uri("https://example.com/page/2");
|
||||
@@ -87,7 +87,7 @@ namespace Octokit.Tests.Reactive
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<Repository>>>(() => lastPageResponse));
|
||||
var repositoriesClient = new ObservableRepositoriesClient(gitHubClient);
|
||||
|
||||
var results = repositoriesClient.GetAllForCurrent().ToArray().Wait();
|
||||
var results = await repositoriesClient.GetAllForCurrent().ToArray();
|
||||
|
||||
Assert.Equal(7, results.Length);
|
||||
gitHubClient.Connection.Received(1).GetAsync<List<Repository>>(firstPageUrl, null, null);
|
||||
@@ -96,7 +96,7 @@ namespace Octokit.Tests.Reactive
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void StopsMakingNewRequestsWhenTakeIsFulfilled()
|
||||
public async Task StopsMakingNewRequestsWhenTakeIsFulfilled()
|
||||
{
|
||||
var firstPageUrl = new Uri("user/repos", UriKind.Relative);
|
||||
var secondPageUrl = new Uri("https://example.com/page/2");
|
||||
@@ -152,7 +152,7 @@ namespace Octokit.Tests.Reactive
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<Repository>>>(() => lastPageResponse));
|
||||
var repositoriesClient = new ObservableRepositoriesClient(gitHubClient);
|
||||
|
||||
var results = repositoriesClient.GetAllForCurrent().Take(4).ToArray().Wait();
|
||||
var results = await repositoriesClient.GetAllForCurrent().Take(4).ToArray();
|
||||
|
||||
Assert.Equal(4, results.Length);
|
||||
gitHubClient.Connection.Received(1).GetAsync<List<Repository>>(firstPageUrl, null, null);
|
||||
|
||||
@@ -86,3 +86,16 @@ for more details.
|
||||
Copyright 2013 GitHub, Inc.
|
||||
|
||||
Licensed under the [MIT License](https://github.com/octokit/octokit.net/blob/master/LICENSE.txt)
|
||||
|
||||
## Deploying a new release
|
||||
|
||||
When we're ready to deploy a new release, we need to do the following steps.
|
||||
|
||||
1. Create a branch named `release`.
|
||||
2. Update [`ReleaseNotes.md`](ReleaseNotes.md). Note that the format is important as we parse the version out and use that for the NuGet packages.
|
||||
3. Push the branch to GitHub and create a pull request. This will kick off the MyGet build of the NuGet package with this new version.
|
||||
4. Test!
|
||||
5. When you're satisfied with this release, push the package [from MyGet](https://www.myget.org/feed/Packages/octokit) to NuGet.
|
||||
6. Create a tag `git tag v#.#.#`. For example, to create a tag for 1.0.0 `git tag v1.0.0`
|
||||
7. Accept the pull request.
|
||||
8. Create a [new release](https://github.com/octokit/octokit.net/releases/new) using the tag you just created and pasting in the release notes you just wrote up
|
||||
|
||||
+8
-1
@@ -6,4 +6,11 @@
|
||||
|
||||
### New in 0.1.2 (Released 2013/10/31)
|
||||
* New default constructors in Octokit.Reactive
|
||||
* New IObservableAssigneesClient in Octokit.Reactive
|
||||
* New IObservableAssigneesClient in Octokit.Reactive
|
||||
|
||||
### New in 0.1.3 (Released 2013/11/5)
|
||||
* New Xamarin Component store versions of Octokit.net
|
||||
* New clients for managing assignees, milestones, and tags
|
||||
* New clients for managing issues, issue events, and issue comments
|
||||
* New client for managing organization members
|
||||
* Fixed bug in applying query parameters that could cause paging to continually request the same page
|
||||
|
||||
+3
-3
@@ -3,11 +3,11 @@ using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyProductAttribute("Octokit")]
|
||||
[assembly: AssemblyVersionAttribute("0.1.2")]
|
||||
[assembly: AssemblyFileVersionAttribute("0.1.2")]
|
||||
[assembly: AssemblyVersionAttribute("0.1.3")]
|
||||
[assembly: AssemblyFileVersionAttribute("0.1.3")]
|
||||
[assembly: ComVisibleAttribute(false)]
|
||||
namespace System {
|
||||
internal static class AssemblyVersionInformation {
|
||||
internal const string Version = "0.1.2";
|
||||
internal const string Version = "0.1.3";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user