mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-03 03:01:31 +00:00
Add NotFoundException for 404 status
This commit is contained in:
@@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user