Skip to content

Commit

Permalink
🎨 Refactor MockHttpClient out of ProjectTest, and use it
Browse files Browse the repository at this point in the history
  • Loading branch information
canterberry committed May 30, 2019
1 parent 34860bb commit ed930fa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
13 changes: 13 additions & 0 deletions Blockmason.Link.Tests/MockHttpClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Net.Http;
using System.Threading.Tasks;

namespace Blockmason.Link.Tests {
public class MockHttpClient : HttpClient {
public MockHttpClient() : base() {
}

public Task<HttpResponseMessage> SendAsync(HttpRequestMessage request) {
return new HttpResponseMessage();
}
}
}
15 changes: 3 additions & 12 deletions Blockmason.Link.Tests/ProjectTest.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
using Xunit;
using Blockmason.Link;
using Blockmason.Link.OAuth;
using System.Collections.Generic;
using Blockmason.Link.OAuth2;
using System.Net.Http;
using System.Threading.Tasks;

namespace Blockmason.Link.Tests {
public class ProjectTest {
internal class MockHttpClient : HttpClient {
public MockHttpClient() : base() {
}

public Task<HttpResponseMessage> SendAsync(HttpRequestMessage request) {
return new HttpResponseMessage();
}
}

[Fact]
public async void CanBeConstructed() {
Credential credential = new Credential();
HttpClient httpClient = new HttpClient();
HttpClient httpClient = new MockHttpClient();
string baseURL = "https://localhost:9000/not-a-live-server-dont-worry";
Session session = new Session(httpClient, credential, baseURL);
Project project = new Project(session);
Expand Down

0 comments on commit ed930fa

Please sign in to comment.