Add NotFoundException for 404 status

This commit is contained in:
Haacked
2013-10-22 17:12:53 -07:00
parent ad210cecc7
commit 70b94187b3
5 changed files with 62 additions and 0 deletions
+22
View File
@@ -231,6 +231,28 @@ namespace Octokit.Tests.Http
Assert.Equal("http://developer.github.com/v3", exception.ApiError.DocumentationUrl);
}
[Fact]
public async Task ThrowsNotFoundExceptionForFileNotFoundResponse()
{
var httpClient = Substitute.For<IHttpClient>();
IResponse<string> response = new ApiResponse<string>
{
StatusCode = HttpStatusCode.NotFound,
Body = "GONE BYE BYE!"
};
httpClient.Send<string>(Args.Request).Returns(Task.FromResult(response));
var connection = new Connection("Test Runner User Agent",
ExampleUri,
Substitute.For<ICredentialStore>(),
httpClient,
Substitute.For<IJsonSerializer>());
var exception = await AssertEx.Throws<NotFoundException>(
async () => await connection.GetAsync<string>(new Uri("/endpoint", UriKind.Relative)));
Assert.Equal("GONE BYE BYE!", exception.Message);
}
[Fact]
public async Task ThrowsForbiddenExceptionForUnknownForbiddenResponse()
{