public async Task ShortenUrlAsync_UxnuUrlTest()
{
var handler = new HttpMessageHandlerMock();
using (var http = new HttpClient(handler))
{
var shortUrl = new ShortUrl(http);
handler.Enqueue(x =>
{
Assert.Equal(HttpMethod.Get, x.Method);
Assert.Equal("https://ux.nu/api/short?format=plain&url=http:%2F%2Fexample.com%2Fhogehoge",
x.RequestUri.AbsoluteUri);
return(new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new ByteArrayContent(Encoding.UTF8.GetBytes("https://ux.nu/hoge")),
});
});
Assert.Equal(new Uri("https://ux.nu/hoge"),
await shortUrl.ShortenUrlAsync(MyCommon.UrlConverter.Uxnu, new Uri("http://example.com/hogehoge")));
Assert.Equal(0, handler.QueueCount);
}
}