forked from anthonyreilly/NetCoreForce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMockHandlerTests.cs
29 lines (25 loc) · 901 Bytes
/
MockHandlerTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System;
using System.Net;
using System.Net.Http;
using System.Collections.Generic;
using System.Threading.Tasks;
using NetCoreForce.Client;
using Xunit;
using NetCoreForce.Models;
namespace NetCoreForce.Client.Tests
{
public class MockHandlerTests
{
[Fact]
public async void MockHandlerTest()
{
var mockHandler = new MockHttpClientHandler();
mockHandler.AddMockResponse(new Uri("http://example.org/test"), new HttpResponseMessage(HttpStatusCode.OK));
var httpClient = new HttpClient(mockHandler);
var response1 = await httpClient.GetAsync("http://example.org/notthere");
var response2 = await httpClient.GetAsync("http://example.org/test");
Assert.Equal(HttpStatusCode.NotFound, response1.StatusCode);
Assert.Equal(HttpStatusCode.OK, response2.StatusCode);
}
}
}