Files
octokit.net/Octokit.Tests/Clients/RespositoryCommitsClientTests.cs
Prayank Mathur 43f6cfe28b Added ApiOption overloads to methods on IRepositoryCommitsClient (#1247)
* Added ApiOptions overloads for RepositoryCommitClient methods

* Added overloads to Reactive clients

* Integration tests in progress

* Integration test addition in progress

* More integration tests added

* Added Ensure things

* Minor changes

* Minor changes

* Few changes

* Tried to fix errors

* Tried to fix errors

* Fixed a few things

* Fixed integration tests

* Tidying up

* Added public keyword

* Added unit tests for GetAll() in normal and reactive methods

* Minor changes

* Changed the class name

* Fixed the unit test
2016-04-10 17:28:01 -04:00

51 lines
2.0 KiB
C#

using NSubstitute;
using System;
using System.Collections.Generic;
using Xunit;
namespace Octokit.Tests.Clients
{
public class RespositoryCommitsClientTests
{
public class TheGetAllMethod
{
[Fact]
public void EnsuresNonEmptyArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new RepositoryCommitsClient(connection);
var options = new ApiOptions();
var request = new CommitRequest();
Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("", "name", request, options));
Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("owner", "", request, options));
}
[Fact]
public void EnsuresNonNullArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new RepositoryCommitsClient(connection);
var options = new ApiOptions();
var request = new CommitRequest();
Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null, "name", request, options));
Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", null, request, options));
Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", "name", null, options));
Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", "name", request, null));
}
[Fact]
public void GetsCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new RepositoryCommitsClient(connection);
client.GetAll("fake", "repo", new CommitRequest(), new ApiOptions());
connection.Received().GetAll<GitHubCommit>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/commits"), Args.EmptyDictionary, Args.ApiOptions);
}
}
}
}