Repository invitations changes (#1410)

* add invitations accept header

* create class RepositoryInvitation

* add repository invitations client

* add api urls for invitations

* [WIP]

* add methods to repository invitations client

* add invite method to repo collaborators client

need to add some new overload to post method in apiconnection

* some changes

* add observable client

* add dependings

* add missing observable client

* add missing xml params

* check client

* change repository invitation model

* [WIP] tests

* [WIP] tests; fix overloads for client

* change GetAllForCurrent; suppress message

* some more tests

* [WIP]

* [WIP]

* add collaborator request model

* change return types

change return types for invitation methods. add permission attribute for
repository collaborators invite method.

* add some more tests

* fix xml doc

* check for null arguments

* fix tests

* some fixes from @ryangribble

* add parameterless constructor for RepositoryInvitation

* change setter

* change constructor

* fix merge conflicts

* [WIP] RepositoryInvitationsClientTests

* fix api url xml

* change collaborator request constructor

* change unit tests for collaborator request

* change repocollaboratorsclient

change overloads for add in invite methods to set permissions

* [WIP] integration tests

* add methods for interface

* NotFoundExceptions

* add overload for invite method

* rename repo property

* gramar

* overloads for observable repo collaborators client

* change integration tests

* new integration tests

* add decline test

* add test for accept invitation
This commit is contained in:
Martin Scholz
2016-07-23 10:50:22 +02:00
committed by Ryan Gribble
parent e3fd99ea9d
commit 89500f4b8a
40 changed files with 1591 additions and 16 deletions
@@ -0,0 +1,113 @@
using NSubstitute;
using Octokit.Reactive;
using System;
using Xunit;
namespace Octokit.Tests.Reactive
{
public class ObservableRepositoryInvitationsClientTests
{
public class TheCtor
{
[Fact]
public void EnsuresNonNullArguments()
{
Assert.Throws<ArgumentNullException>(() => new ObservableRepositoryInvitationsClient(null));
}
}
public class TheGetAllForRepositoryMethod
{
[Fact]
public void RequestsCorrectUrl()
{
var gitHub = Substitute.For<IGitHubClient>();
var client = new ObservableRepositoryInvitationsClient(gitHub);
client.GetAllForRepository(42);
gitHub.Received().Repository.Invitation.GetAllForRepository(42);
}
}
public class TheGetAllForCurrentMethod
{
[Fact]
public void RequestsCorrectUrl()
{
var gitHub = Substitute.For<IGitHubClient>();
var client = new ObservableRepositoryInvitationsClient(gitHub);
client.GetAllForCurrent();
gitHub.Received().Repository.Invitation.GetAllForCurrent();
}
}
public class TheAcceptMethod
{
[Fact]
public void RequestsCorrectUrl()
{
var gitHub = Substitute.For<IGitHubClient>();
var client = new ObservableRepositoryInvitationsClient(gitHub);
client.Accept(42);
gitHub.Received().Repository.Invitation.Accept(42);
}
}
public class TheDeclineMethod
{
[Fact]
public void RequestsCorrectUrl()
{
var gitHub = Substitute.For<IGitHubClient>();
var client = new ObservableRepositoryInvitationsClient(gitHub);
client.Decline(42);
gitHub.Received().Repository.Invitation.Decline(42);
}
}
public class TheDeleteMethod
{
[Fact]
public void RequestsCorrectUrl()
{
var gitHub = Substitute.For<IGitHubClient>();
var client = new ObservableRepositoryInvitationsClient(gitHub);
client.Delete(42, 43);
gitHub.Received().Repository.Invitation.Delete(42, 43);
}
}
public class TheEditMethod
{
[Fact]
public void RequestsCorrectUrl()
{
var gitHub = Substitute.For<IGitHubClient>();
var client = new ObservableRepositoryInvitationsClient(gitHub);
var update = new InvitationUpdate(InvitationPermissionType.Write);
client.Edit(42, 43, update);
gitHub.Received().Repository.Invitation.Edit(42, 43, update);
}
[Fact]
public void EnsureNonNullArguments()
{
var gitHub = Substitute.For<IGitHubClient>();
var client = new ObservableRepositoryInvitationsClient(gitHub);
Assert.Throws<ArgumentNullException>(() => client.Edit(1, 2, null));
}
}
}
}