mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-05 11:40:42 +00:00
All remarks were fixed
This commit is contained in:
@@ -31,6 +31,9 @@ namespace Octokit.Reactive.Clients
|
||||
/// <returns>All the <see cref="Deployment"/>s for the specified repository.</returns>
|
||||
public IObservable<Deployment> GetAll(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
return GetAll(owner, name, ApiOptions.None);
|
||||
}
|
||||
|
||||
|
||||
@@ -50,11 +50,11 @@ public class DeploymentsClientTests
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new DeploymentsClient(connection);
|
||||
var expectedUrl = ApiUrls.Deployments(owner, name);
|
||||
var expectedUrl = string.Format("repos/{0}/{1}/deployments", owner, name);
|
||||
|
||||
client.GetAll(owner, name);
|
||||
connection.Received(1)
|
||||
.GetAll<Deployment>(Arg.Is<Uri>(u => u == expectedUrl), Args.ApiOptions);
|
||||
.GetAll<Deployment>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), Args.ApiOptions);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -62,7 +62,7 @@ public class DeploymentsClientTests
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new DeploymentsClient(connection);
|
||||
var expectedUrl = ApiUrls.Deployments(owner, name);
|
||||
var expectedUrl = string.Format("repos/{0}/{1}/deployments", owner, name);
|
||||
|
||||
var options = new ApiOptions
|
||||
{
|
||||
@@ -73,21 +73,21 @@ public class DeploymentsClientTests
|
||||
|
||||
client.GetAll(owner, name, options);
|
||||
connection.Received(1)
|
||||
.GetAll<Deployment>(Arg.Is<Uri>(u => u == expectedUrl), options);
|
||||
.GetAll<Deployment>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), options);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheCreateMethod
|
||||
{
|
||||
private readonly NewDeployment _newDeployment = new NewDeployment("aRef");
|
||||
private readonly NewDeployment newDeployment = new NewDeployment("aRef");
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new DeploymentsClient(Substitute.For<IApiConnection>());
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(null, "name", _newDeployment));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", null, _newDeployment));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(null, "name", newDeployment));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", null, newDeployment));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", "name", null));
|
||||
}
|
||||
|
||||
@@ -96,8 +96,8 @@ public class DeploymentsClientTests
|
||||
{
|
||||
var client = new DeploymentsClient(Substitute.For<IApiConnection>());
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("", "name", _newDeployment));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", "", _newDeployment));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("", "name", newDeployment));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", "", newDeployment));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@@ -110,8 +110,8 @@ public class DeploymentsClientTests
|
||||
{
|
||||
var client = new DeploymentsClient(Substitute.For<IApiConnection>());
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Create(whitespace, "name", _newDeployment));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", whitespace, _newDeployment));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Create(whitespace, "name", newDeployment));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", whitespace, newDeployment));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -121,7 +121,7 @@ public class DeploymentsClientTests
|
||||
var client = new DeploymentsClient(connection);
|
||||
var expectedUrl = "repos/owner/name/deployments";
|
||||
|
||||
client.Create("owner", "name", _newDeployment);
|
||||
client.Create("owner", "name", newDeployment);
|
||||
|
||||
connection.Received(1).Post<Deployment>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
|
||||
Arg.Any<NewDeployment>());
|
||||
@@ -133,10 +133,10 @@ public class DeploymentsClientTests
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new DeploymentsClient(connection);
|
||||
|
||||
client.Create("owner", "name", _newDeployment);
|
||||
client.Create("owner", "name", newDeployment);
|
||||
|
||||
connection.Received(1).Post<Deployment>(Arg.Any<Uri>(),
|
||||
_newDeployment);
|
||||
newDeployment);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,21 +51,21 @@ namespace Octokit.Tests.Reactive
|
||||
[Fact]
|
||||
public void RequestsCorrectUrl()
|
||||
{
|
||||
var expectedUri = ApiUrls.Deployments(owner, name);
|
||||
var expectedUrl = string.Format("repos/{0}/{1}/deployments", owner, name);
|
||||
|
||||
_client.GetAll(owner, name);
|
||||
_githubClient.Connection
|
||||
.Received(1)
|
||||
.Get<List<Deployment>>(Arg.Is(expectedUri),
|
||||
Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 0), Arg.Any<string>());
|
||||
_githubClient.Connection.Received(1)
|
||||
.Get<List<Deployment>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
|
||||
Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 0),
|
||||
Arg.Any<string>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RequestsCorrectUrlWithApiOptions()
|
||||
{
|
||||
var expectedUri = ApiUrls.Deployments(owner, name);
|
||||
|
||||
// all properties are setted => only 2 options (StartPage, PageSize) in Dictionary
|
||||
var expectedUrl = string.Format("repos/{0}/{1}/deployments", owner, name);
|
||||
|
||||
// all properties are setted => only 2 options (StartPage, PageSize) in dictionary
|
||||
var options = new ApiOptions
|
||||
{
|
||||
StartPage = 1,
|
||||
@@ -74,34 +74,34 @@ namespace Octokit.Tests.Reactive
|
||||
};
|
||||
|
||||
_client.GetAll(owner, name, options);
|
||||
_githubClient.Connection
|
||||
.Received(1)
|
||||
.Get<List<Deployment>>(Arg.Is(expectedUri),
|
||||
Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 2), null);
|
||||
_githubClient.Connection.Received(1)
|
||||
.Get<List<Deployment>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
|
||||
Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 2),
|
||||
null);
|
||||
|
||||
// StartPage is setted => only 1 option (StartPage) in Dictionary
|
||||
// StartPage is setted => only 1 option (StartPage) in dictionary
|
||||
options = new ApiOptions
|
||||
{
|
||||
StartPage = 1
|
||||
};
|
||||
|
||||
_client.GetAll(owner, name, options);
|
||||
_githubClient.Connection
|
||||
.Received(1)
|
||||
.Get<List<Deployment>>(Arg.Is(expectedUri),
|
||||
Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 1), null);
|
||||
_githubClient.Connection.Received(1)
|
||||
.Get<List<Deployment>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
|
||||
Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 1),
|
||||
null);
|
||||
|
||||
// PageCount is setted => none of options in Dictionary
|
||||
// PageCount is setted => none of options in dictionary
|
||||
options = new ApiOptions
|
||||
{
|
||||
PageCount = 1
|
||||
};
|
||||
|
||||
_client.GetAll(owner, name, options);
|
||||
_githubClient.Connection
|
||||
.Received(1)
|
||||
.Get<List<Deployment>>(Arg.Is(expectedUri),
|
||||
Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 0), null);
|
||||
_githubClient.Connection.Received(1)
|
||||
.Get<List<Deployment>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
|
||||
Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 0),
|
||||
null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,9 +164,10 @@ namespace Octokit.Tests.Reactive
|
||||
|
||||
var newDeployment = new NewDeployment("ref");
|
||||
_client.Create("owner", "repo", newDeployment);
|
||||
|
||||
_githubClient.Repository.Deployment.Received(1).Create(Arg.Is("owner"),
|
||||
Arg.Is("repo"),
|
||||
Arg.Is(newDeployment));
|
||||
Arg.Is("repo"),
|
||||
Arg.Is(newDeployment));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,4 +180,4 @@ namespace Octokit.Tests.Reactive
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,9 @@ namespace Octokit
|
||||
/// <returns>All the <see cref="Deployment"/>s for the specified repository.</returns>
|
||||
public Task<IReadOnlyList<Deployment>> GetAll(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
return GetAll(owner, name, ApiOptions.None);
|
||||
}
|
||||
|
||||
@@ -50,7 +53,7 @@ namespace Octokit
|
||||
/// <returns>All the <see cref="Deployment"/>s for the specified repository.</returns>
|
||||
public Task<IReadOnlyList<Deployment>> GetAll(string owner, string name, ApiOptions options)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "login");
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
Ensure.ArgumentNotNull(options, "options");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user