You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.3 KiB
C#
57 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace HttpClientStudy.UnitTest
|
|
{
|
|
public class HttpErrorTest : IDisposable
|
|
{
|
|
private readonly ITestOutputHelper _logger;
|
|
private readonly HttpError _httpError = new HttpError();
|
|
|
|
public HttpErrorTest(ITestOutputHelper outputHelper)
|
|
{
|
|
_logger = outputHelper;
|
|
}
|
|
|
|
[Fact]
|
|
public async Task UnknownHost_Test()
|
|
{
|
|
Func<Task> func = _httpError.UnknownHostAsync;
|
|
|
|
await Assert.ThrowsAsync<HttpRequestException>(func);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task NoService_Test()
|
|
{
|
|
Func<Task> func = _httpError.NoServiceAsync;
|
|
|
|
await Assert.ThrowsAsync<HttpRequestException>(func);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Http404_Test()
|
|
{
|
|
var code = await _httpError.Http404Async();
|
|
|
|
Assert.Equal(HttpStatusCode.NotFound, code);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Http500_Test()
|
|
{
|
|
var code = await _httpError.Http500Async();
|
|
|
|
Assert.Equal(HttpStatusCode.InternalServerError, code);
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|