Files
octokit.net/Octokit.Tests.Integration/HttpClientAdapterTests.cs
Haacked 49f95d40f1 Remove Type parameter for IHttpClient send method
This keeps the IHttpClient interface simpler and ensures the
deserialization responsibility lies outside of that class. It only
needed the Type parameter for a special case that could be handled in a
better way.
2015-01-04 18:22:05 -08:00

37 lines
1.1 KiB
C#

using System;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Octokit.Internal;
using Octokit.Tests.Integration;
using Xunit;
public class HttpClientAdapterTests
{
public class TheSendAsyncMethod
{
[IntegrationTest]
public async Task CanDownloadImage()
{
var httpClient = new HttpClientAdapter();
var request = new Request
{
BaseAddress = new Uri("https://github.global.ssl.fastly.net/", UriKind.Absolute),
Endpoint = new Uri("/images/icons/emoji/poop.png?v=5", UriKind.RelativeOrAbsolute),
AllowAutoRedirect = true,
Method = HttpMethod.Get
};
var response = await httpClient.Send(request, CancellationToken.None);
// Spot check some of dem bytes.
var imageBytes = (byte[])response.BodyAsObject;
Assert.Equal(137, imageBytes[0]);
Assert.Equal(80, imageBytes[1]);
Assert.Equal(78, imageBytes[2]);
Assert.Equal(130, imageBytes.Last());
}
}
}