added new unit tests

This commit is contained in:
aedampir@gmail.com
2016-06-16 17:02:04 +07:00
parent 7ce724cf6d
commit a2df9a781b
2 changed files with 298 additions and 50 deletions

View File

@@ -21,6 +21,17 @@ namespace Octokit.Tests.Clients
connection.Received().Get<Milestone>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/milestones/42"));
}
[Fact]
public void RequestsCorrectUrlWithRepositoryId()
{
var connection = Substitute.For<IApiConnection>();
var client = new MilestonesClient(connection);
client.Get(1, 42);
connection.Received().Get<Milestone>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/milestones/42"));
}
[Fact]
public async Task EnsuresNonNullArguments()
{
@@ -28,8 +39,9 @@ namespace Octokit.Tests.Clients
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get(null, "name", 1));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("owner", null, 1));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get(null, "", 1));
await Assert.ThrowsAsync<ArgumentException>(() => client.Get("", null, 1));
await Assert.ThrowsAsync<ArgumentException>(() => client.Get("", "name", 1));
await Assert.ThrowsAsync<ArgumentException>(() => client.Get("owner", "", 1));
}
}
@@ -47,6 +59,18 @@ namespace Octokit.Tests.Clients
Arg.Any<Dictionary<string, string>>(), Args.ApiOptions);
}
[Fact]
public async Task RequestsCorrectUrlWithRepositoryId()
{
var connection = Substitute.For<IApiConnection>();
var client = new MilestonesClient(connection);
await client.GetAllForRepository(1);
connection.Received().GetAll<Milestone>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/milestones"),
Arg.Any<Dictionary<string, string>>(), Args.ApiOptions);
}
[Fact]
public async Task RequestsCorrectUrlWithApiOptions()
{
@@ -66,6 +90,25 @@ namespace Octokit.Tests.Clients
Arg.Any<Dictionary<string, string>>(), options);
}
[Fact]
public async Task RequestsCorrectUrlWithApiOptionsWithRepositoryId()
{
var connection = Substitute.For<IApiConnection>();
var client = new MilestonesClient(connection);
var options = new ApiOptions
{
PageCount = 1,
PageSize = 1,
StartPage = 1
};
await client.GetAllForRepository(1, options);
connection.Received().GetAll<Milestone>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/milestones"),
Arg.Any<Dictionary<string, string>>(), options);
}
[Fact]
public void SendsAppropriateParameters()
{
@@ -81,6 +124,21 @@ namespace Octokit.Tests.Clients
&& d["sort"] == "due_date"), Args.ApiOptions);
}
[Fact]
public void SendsAppropriateParametersWithRepositoryId()
{
var connection = Substitute.For<IApiConnection>();
var client = new MilestonesClient(connection);
client.GetAllForRepository(1, new MilestoneRequest { SortDirection = SortDirection.Descending });
connection.Received().GetAll<Milestone>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/milestones"),
Arg.Is<Dictionary<string, string>>(d => d.Count == 3
&& d["direction"] == "desc"
&& d["state"] == "open"
&& d["sort"] == "due_date"), Args.ApiOptions);
}
[Fact]
public void SendsAppropriateParametersWithApiOptions()
{
@@ -103,6 +161,28 @@ namespace Octokit.Tests.Clients
&& d["sort"] == "due_date"), options);
}
[Fact]
public void SendsAppropriateParametersWithApiOptionsWithRepositoryId()
{
var connection = Substitute.For<IApiConnection>();
var client = new MilestonesClient(connection);
var options = new ApiOptions
{
PageCount = 1,
PageSize = 1,
StartPage = 1
};
client.GetAllForRepository(1, new MilestoneRequest { SortDirection = SortDirection.Descending }, options);
connection.Received().GetAll<Milestone>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/milestones"),
Arg.Is<Dictionary<string, string>>(d => d.Count == 3
&& d["direction"] == "desc"
&& d["state"] == "open"
&& d["sort"] == "due_date"), options);
}
[Fact]
public async Task EnsuresNonNullArguments()
{
@@ -111,30 +191,35 @@ namespace Octokit.Tests.Clients
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name"));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (ApiOptions)null));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null, ApiOptions.None));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name", ApiOptions.None));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null, ApiOptions.None));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (ApiOptions)null));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (MilestoneRequest)null));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null, new MilestoneRequest()));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name", new MilestoneRequest()));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null, new MilestoneRequest()));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (MilestoneRequest)null));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", new MilestoneRequest(), null));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", null, ApiOptions.None));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null, new MilestoneRequest(), ApiOptions.None));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name", new MilestoneRequest(), ApiOptions.None));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null, new MilestoneRequest(), ApiOptions.None));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", null, ApiOptions.None));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", new MilestoneRequest(), null));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(1, (ApiOptions)null));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(1, (MilestoneRequest)null));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(1, null, ApiOptions.None));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(1, new MilestoneRequest(), null));
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", ""));
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name"));
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", ""));
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", ApiOptions.None));
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name", ApiOptions.None));
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", ApiOptions.None));
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", new MilestoneRequest()));
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name", new MilestoneRequest()));
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", new MilestoneRequest()));
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", new MilestoneRequest(), ApiOptions.None));
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name", new MilestoneRequest(), ApiOptions.None));
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", new MilestoneRequest(), ApiOptions.None));
}
}
@@ -154,16 +239,32 @@ namespace Octokit.Tests.Clients
}
[Fact]
public async Task EnsuresArgumentsNotNull()
public void PostsToCorrectUrlWithRepositoryId()
{
var newMilestone = new NewMilestone("some title");
var connection = Substitute.For<IApiConnection>();
var client = new MilestonesClient(connection);
client.Create(1, newMilestone);
connection.Received().Post<Milestone>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/milestones"),
newMilestone);
}
[Fact]
public async Task EnsuresNonNullArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new MilestonesClient(connection);
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(null, "name", new NewMilestone("title")));
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("", "name", new NewMilestone("x")));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(null, "name", new NewMilestone("x")));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", null, new NewMilestone("x")));
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", "", new NewMilestone("x")));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", "name", null));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(1, null));
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("", "name", new NewMilestone("x")));
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", "", new NewMilestone("x")));
}
}
@@ -183,16 +284,32 @@ namespace Octokit.Tests.Clients
}
[Fact]
public async Task EnsuresArgumentsNotNull()
public void PostsToCorrectUrlWithRepositoryId()
{
var milestoneUpdate = new MilestoneUpdate();
var connection = Substitute.For<IApiConnection>();
var client = new MilestonesClient(connection);
client.Update(1, 42, milestoneUpdate);
connection.Received().Patch<Milestone>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/milestones/42"),
milestoneUpdate);
}
[Fact]
public async Task EnsuresNonNullArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new MilestonesClient(connection);
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(null, "name", new NewMilestone("title")));
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("", "name", new NewMilestone("x")));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", null, new NewMilestone("x")));
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", "", new NewMilestone("x")));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", "name", null));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(1, null));
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("", "name", new NewMilestone("x")));
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", "", new NewMilestone("x")));
}
}
@@ -210,14 +327,26 @@ namespace Octokit.Tests.Clients
}
[Fact]
public async Task EnsuresArgumentsNotNull()
public void PostsToCorrectUrlWithRepositoryId()
{
var connection = Substitute.For<IApiConnection>();
var client = new MilestonesClient(connection);
client.Delete(1, 42);
connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "repositories/1/milestones/42"));
}
[Fact]
public async Task EnsuresNonNullArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new MilestonesClient(connection);
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Delete(null, "name", 42));
await Assert.ThrowsAsync<ArgumentException>(() => client.Delete("", "name", 42));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Delete("owner", null, 42));
await Assert.ThrowsAsync<ArgumentException>(() => client.Delete("", "name", 42));
await Assert.ThrowsAsync<ArgumentException>(() => client.Delete("owner", "", 42));
}
}

View File

@@ -25,6 +25,17 @@ namespace Octokit.Tests.Reactive
gitHubClient.Issue.Milestone.Received().Get("fake", "repo", 42);
}
[Fact]
public void GetsFromClientIssueMilestoneWithRepositoryId()
{
var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservableMilestonesClient(gitHubClient);
client.Get(1, 42);
gitHubClient.Issue.Milestone.Received().Get(1, 42);
}
[Fact]
public async Task EnsuresNonNullArguments()
{
@@ -32,6 +43,7 @@ namespace Octokit.Tests.Reactive
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get(null, "name", 1).ToTask());
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("owner", null, 1).ToTask());
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get(null, "", 1).ToTask());
await Assert.ThrowsAsync<ArgumentException>(() => client.Get("", null, 1).ToTask());
}
@@ -50,6 +62,17 @@ namespace Octokit.Tests.Reactive
gitHubClient.Received().Issue.Milestone.GetAllForRepository("fake", "repo");
}
[Fact]
public void RequestsCorrectUrlWithRepositoryId()
{
var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservableMilestonesClient(gitHubClient);
client.GetAllForRepository(1);
gitHubClient.Received().Issue.Milestone.GetAllForRepository(1);
}
[Fact]
public void RequestsCorrectUrlWithApiOptions()
{
@@ -68,6 +91,24 @@ namespace Octokit.Tests.Reactive
gitHubClient.Received().Issue.Milestone.GetAllForRepository("fake", "repo", options);
}
[Fact]
public void RequestsCorrectUrlWithApiOptionsWithRepositoryId()
{
var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservableMilestonesClient(gitHubClient);
var options = new ApiOptions
{
PageCount = 1,
PageSize = 1,
StartPage = 1
};
client.GetAllForRepository(1, options);
gitHubClient.Received().Issue.Milestone.GetAllForRepository(1, options);
}
[Fact]
public void SendsAppropriateParameters()
{
@@ -80,6 +121,18 @@ namespace Octokit.Tests.Reactive
gitHubClient.Received().Issue.Milestone.GetAllForRepository("fake", "repo", milestoneRequest, Args.ApiOptions);
}
[Fact]
public void SendsAppropriateParametersWithRepositoryId()
{
var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservableMilestonesClient(gitHubClient);
var milestoneRequest = new MilestoneRequest { SortDirection = SortDirection.Descending };
client.GetAllForRepository(1, milestoneRequest);
gitHubClient.Received().Issue.Milestone.GetAllForRepository(1, milestoneRequest, Args.ApiOptions);
}
[Fact]
public void SendsAppropriateParametersWithApiOptions()
{
@@ -99,38 +152,62 @@ namespace Octokit.Tests.Reactive
gitHubClient.Received().Issue.Milestone.GetAllForRepository("fake", "repo", milestoneRequest, options);
}
[Fact]
public void SendsAppropriateParametersWithApiOptionsWithRepositoryId()
{
var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservableMilestonesClient(gitHubClient);
var options = new ApiOptions
{
PageCount = 1,
PageSize = 1,
StartPage = 1
};
var milestoneRequest = new MilestoneRequest { SortDirection = SortDirection.Descending };
client.GetAllForRepository(1, milestoneRequest, options);
gitHubClient.Received().Issue.Milestone.GetAllForRepository(1, milestoneRequest, options);
}
[Fact]
public void EnsuresNonNullArguments()
{
var client = new ObservableMilestonesClient(Substitute.For<IGitHubClient>());
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", null));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(null, "name"));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", null));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (ApiOptions)null));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", null, ApiOptions.None));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(null, "name", ApiOptions.None));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", null, ApiOptions.None));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (ApiOptions)null));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (MilestoneRequest)null));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", null, new MilestoneRequest()));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(null, "name", new MilestoneRequest()));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", new MilestoneRequest(), null));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", null, ApiOptions.None));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", null, new MilestoneRequest(), ApiOptions.None));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", null, new MilestoneRequest()));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (MilestoneRequest)null));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(null, "name", new MilestoneRequest(), ApiOptions.None));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", null, new MilestoneRequest(), ApiOptions.None));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", null, ApiOptions.None));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", new MilestoneRequest(), null));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(1, (ApiOptions)null));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(1, (MilestoneRequest)null));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(1, null, ApiOptions.None));
Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(1, new MilestoneRequest(), null));
Assert.Throws<ArgumentException>(() => client.GetAllForRepository("owner", ""));
Assert.Throws<ArgumentException>(() => client.GetAllForRepository("", "name"));
Assert.Throws<ArgumentException>(() => client.GetAllForRepository("owner", ""));
Assert.Throws<ArgumentException>(() => client.GetAllForRepository("owner", "", ApiOptions.None));
Assert.Throws<ArgumentException>(() => client.GetAllForRepository("", "name", ApiOptions.None));
Assert.Throws<ArgumentException>(() => client.GetAllForRepository("owner", "", ApiOptions.None));
Assert.Throws<ArgumentException>(() => client.GetAllForRepository("owner", "", new MilestoneRequest()));
Assert.Throws<ArgumentException>(() => client.GetAllForRepository("", "name", new MilestoneRequest()));
Assert.Throws<ArgumentException>(() => client.GetAllForRepository("owner", "", new MilestoneRequest()));
Assert.Throws<ArgumentException>(() => client.GetAllForRepository("owner", "", new MilestoneRequest(), ApiOptions.None));
Assert.Throws<ArgumentException>(() => client.GetAllForRepository("", "name", new MilestoneRequest(), ApiOptions.None));
Assert.Throws<ArgumentException>(() => client.GetAllForRepository("owner", "", new MilestoneRequest(), ApiOptions.None));
}
[Fact]
@@ -168,7 +245,7 @@ namespace Octokit.Tests.Reactive
{
new Milestone(7)
}
);
);
var gitHubClient = Substitute.For<IGitHubClient>();
gitHubClient.Connection.Get<List<Milestone>>(firstPageUrl, Args.EmptyDictionary, null)
.Returns(Task.Factory.StartNew<IApiResponse<List<Milestone>>>(() => firstPageResponse));
@@ -224,10 +301,10 @@ namespace Octokit.Tests.Reactive
);
var gitHubClient = Substitute.For<IGitHubClient>();
gitHubClient.Connection.Get<List<Milestone>>(Arg.Is(firstPageUrl),
Arg.Is<Dictionary<string, string>>(d => d.Count == 3
&& d["direction"] == "desc"
&& d["state"] == "open"
&& d["sort"] == "due_date"), null)
Arg.Is<Dictionary<string, string>>(d => d.Count == 3
&& d["direction"] == "desc"
&& d["state"] == "open"
&& d["sort"] == "due_date"), null)
.Returns(Task.Factory.StartNew<IApiResponse<List<Milestone>>>(() => firstPageResponse));
gitHubClient.Connection.Get<List<Milestone>>(secondPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 3
&& d["direction"] == "desc"
@@ -239,7 +316,7 @@ namespace Octokit.Tests.Reactive
&& d["state"] == "open"
&& d["sort"] == "due_date"), null)
.Returns(Task.Factory.StartNew<IApiResponse<List<Milestone>>>(() => lastPageResponse));
var client = new ObservableMilestonesClient(gitHubClient);
var results = await client.GetAllForRepository("fake", "repo", new MilestoneRequest { SortDirection = SortDirection.Descending }).ToArray();
@@ -266,16 +343,31 @@ namespace Octokit.Tests.Reactive
}
[Fact]
public void EnsuresArgumentsNotNull()
public void CreatesFromClientIssueMilestoneWithRepositoryId()
{
var newMilestone = new NewMilestone("some title");
var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservableMilestonesClient(gitHubClient);
client.Create(1, newMilestone);
gitHubClient.Issue.Milestone.Received().Create(1, newMilestone);
}
[Fact]
public void EnsuresNonNullArguments()
{
var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservableMilestonesClient(gitHubClient);
Assert.Throws<ArgumentNullException>(() => client.Create(null, "name", new NewMilestone("title")));
Assert.Throws<ArgumentException>(() => client.Create("", "name", new NewMilestone("x")));
Assert.Throws<ArgumentNullException>(() => client.Create(null, "name", new NewMilestone("x")));
Assert.Throws<ArgumentNullException>(() => client.Create("owner", null, new NewMilestone("x")));
Assert.Throws<ArgumentException>(() => client.Create("owner", "", new NewMilestone("x")));
Assert.Throws<ArgumentNullException>(() => client.Create("owner", "name", null));
Assert.Throws<ArgumentNullException>(() => client.Create(1, null));
Assert.Throws<ArgumentException>(() => client.Create("", "name", new NewMilestone("x")));
Assert.Throws<ArgumentException>(() => client.Create("owner", "", new NewMilestone("x")));
}
}
@@ -294,16 +386,31 @@ namespace Octokit.Tests.Reactive
}
[Fact]
public void EnsuresArgumentsNotNull()
public void UpdatesClientIssueMilestoneWithRepositoryId()
{
var milestoneUpdate = new MilestoneUpdate();
var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservableMilestonesClient(gitHubClient);
client.Update(1, 42, milestoneUpdate);
gitHubClient.Issue.Milestone.Received().Update(1, 42, milestoneUpdate);
}
[Fact]
public void EnsuresNonNullArguments()
{
var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservableMilestonesClient(gitHubClient);
Assert.Throws<ArgumentNullException>(() => client.Update(null, "name", 42, new MilestoneUpdate()));
Assert.Throws<ArgumentException>(() => client.Update("", "name", 42, new MilestoneUpdate()));
Assert.Throws<ArgumentNullException>(() => client.Update("owner", null, 42, new MilestoneUpdate()));
Assert.Throws<ArgumentException>(() => client.Update("owner", "", 42, new MilestoneUpdate()));
Assert.Throws<ArgumentNullException>(() => client.Update("owner", "name", 42, null));
Assert.Throws<ArgumentNullException>(() => client.Update(1, 42, null));
Assert.Throws<ArgumentException>(() => client.Update("", "name", 42, new MilestoneUpdate()));
Assert.Throws<ArgumentException>(() => client.Update("owner", "", 42, new MilestoneUpdate()));
}
}
@@ -321,14 +428,26 @@ namespace Octokit.Tests.Reactive
}
[Fact]
public void EnsuresArgumentsNotNull()
public void DeletesFromClientIssueMilestoneWithRepositoryId()
{
var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservableMilestonesClient(gitHubClient);
client.Delete(1, 42);
gitHubClient.Issue.Milestone.Received().Delete(1, 42);
}
[Fact]
public void EnsuresNonNullArguments()
{
var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservableMilestonesClient(gitHubClient);
Assert.Throws<ArgumentNullException>(() => client.Delete(null, "name", 42));
Assert.Throws<ArgumentException>(() => client.Delete("", "name", 42));
Assert.Throws<ArgumentNullException>(() => client.Delete("owner", null, 42));
Assert.Throws<ArgumentException>(() => client.Delete("", "name", 42));
Assert.Throws<ArgumentException>(() => client.Delete("owner", "", 42));
}
}