tests for clients for Gists, IssueComments, IssueClient use Assert.ThrowsAsync

This commit is contained in:
Mordechai Zuber
2015-05-11 17:51:23 +03:00
parent fd86a951b1
commit 0ee2f35dad
3 changed files with 29 additions and 29 deletions
+1 -1
View File
@@ -259,7 +259,7 @@ public class GistsClientTests
var client = new GistsClient(apiConnection);
await AssertEx.Throws<ApiException>(async () => await client.IsStarred("1"));
await Assert.ThrowsAsync<ApiException>(() => client.IsStarred("1"));
}
}
@@ -29,10 +29,10 @@ public class IssueCommentsClientTests
{
var client = new IssueCommentsClient(Substitute.For<IApiConnection>());
await AssertEx.Throws<ArgumentNullException>(async () => await client.Get(null, "name", 1));
await AssertEx.Throws<ArgumentException>(async () => await client.Get("", "name", 1));
await AssertEx.Throws<ArgumentNullException>(async () => await client.Get("owner", null, 1));
await AssertEx.Throws<ArgumentException>(async () => await client.Get("owner", "", 1));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get(null, "name", 1));
await Assert.ThrowsAsync<ArgumentException>(() => client.Get("", "name", 1));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("owner", null, 1));
await Assert.ThrowsAsync<ArgumentException>(() => client.Get("owner", "", 1));
}
}
@@ -56,10 +56,10 @@ public class IssueCommentsClientTests
var connection = Substitute.For<IApiConnection>();
var client = new IssueCommentsClient(connection);
await AssertEx.Throws<ArgumentNullException>(async () => await client.GetAllForRepository(null, "name"));
await AssertEx.Throws<ArgumentException>(async () => await client.GetAllForRepository("", "name"));
await AssertEx.Throws<ArgumentNullException>(async () => await client.GetAllForRepository("owner", null));
await AssertEx.Throws<ArgumentException>(async () => await client.GetAllForRepository("owner", ""));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name"));
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name"));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null));
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", ""));
}
}
@@ -82,10 +82,10 @@ public class IssueCommentsClientTests
var connection = Substitute.For<IApiConnection>();
var client = new IssueCommentsClient(connection);
await AssertEx.Throws<ArgumentNullException>(async () => await client.GetAllForIssue(null, "name", 1));
await AssertEx.Throws<ArgumentException>(async () => await client.GetAllForIssue("", "name", 1));
await AssertEx.Throws<ArgumentNullException>(async () => await client.GetAllForIssue("owner", null, 1));
await AssertEx.Throws<ArgumentException>(async () => await client.GetAllForIssue("owner", "", 1));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForIssue(null, "name", 1));
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForIssue("", "name", 1));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForIssue("owner", null, 1));
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForIssue("owner", "", 1));
}
}
@@ -109,11 +109,11 @@ public class IssueCommentsClientTests
var connection = Substitute.For<IApiConnection>();
var client = new IssueCommentsClient(connection);
await AssertEx.Throws<ArgumentNullException>(async () => await client.Create(null, "name", 1, "title"));
await AssertEx.Throws<ArgumentException>(async () => await client.Create("", "name", 1, "x"));
await AssertEx.Throws<ArgumentNullException>(async () => await client.Create("owner", null, 1, "x"));
await AssertEx.Throws<ArgumentException>(async () => await client.Create("owner", "", 1, "x"));
await AssertEx.Throws<ArgumentNullException>(async () => await client.Create("owner", "name", 1, null));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(null, "name", 1, "title"));
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("", "name", 1, "x"));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", null, 1, "x"));
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", "", 1, "x"));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", "name", 1, null));
}
}
@@ -137,11 +137,11 @@ public class IssueCommentsClientTests
var connection = Substitute.For<IApiConnection>();
var client = new IssueCommentsClient(connection);
await AssertEx.Throws<ArgumentNullException>(async () => await client.Update(null, "name", 42, "title"));
await AssertEx.Throws<ArgumentException>(async () => await client.Update("", "name", 42, "x"));
await AssertEx.Throws<ArgumentNullException>(async () => await client.Update("owner", null, 42, "x"));
await AssertEx.Throws<ArgumentException>(async () => await client.Update("owner", "", 42, "x"));
await AssertEx.Throws<ArgumentNullException>(async () => await client.Update("owner", "name", 42, null));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update(null, "name", 42, "title"));
await Assert.ThrowsAsync<ArgumentException>(() => client.Update("", "name", 42, "x"));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update("owner", null, 42, "x"));
await Assert.ThrowsAsync<ArgumentException>(() => client.Update("owner", "", 42, "x"));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update("owner", "name", 42, null));
}
}
@@ -164,10 +164,10 @@ public class IssueCommentsClientTests
var connection = Substitute.For<IApiConnection>();
var client = new IssueCommentsClient(connection);
await AssertEx.Throws<ArgumentNullException>(async () => await client.Delete(null, "name", 42));
await AssertEx.Throws<ArgumentException>(async () => await client.Delete("", "name", 42));
await AssertEx.Throws<ArgumentNullException>(async () => await client.Delete("owner", null, 42));
await AssertEx.Throws<ArgumentException>(async () => await client.Delete("owner", "", 42));
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("owner", "", 42));
}
}
+2 -2
View File
@@ -30,8 +30,8 @@ namespace Octokit.Tests.Clients
{
var client = new IssuesClient(Substitute.For<IApiConnection>());
await AssertEx.Throws<ArgumentNullException>(async () => await client.Get(null, "name", 1));
await AssertEx.Throws<ArgumentNullException>(async () => await client.Get("owner", null, 1));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get(null, "name", 1));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("owner", null, 1));
}
}