-
-
Save barrett777/3798bfd2b5f22e6c9419fb2c6591c185 to your computer and use it in GitHub Desktop.
Revisions
-
Jaecen created this gist
Feb 22, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ using System.Net; using System.Net.Http; using System.Threading; using System.Threading.Tasks; namespace DotUpgrade.Test { class AlwaysReturns : HttpMessageHandler { readonly HttpStatusCode StatusCode; public AlwaysReturns(HttpStatusCode statusCode) { StatusCode = statusCode; } protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) => Task.FromResult(new HttpResponseMessage(StatusCode)); } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ using System.Net; using System.Net.Http; using Xunit; namespace DotUpgrade.Test { public class SampleTests { [Fact] public void Should_Return_Indicated_Code() { var httpClient = new HttpClient(new AlwaysReturns(HttpStatusCode.Conflict)); var response = httpClient.GetAsync("http://www.google.com").Result; Assert.Equal(HttpStatusCode.Conflict, response.StatusCode); } } }