public static IHttpClientFactory CreateWithResponse(HttpResponseMessage response) { var mock = Substitute.For <IHttpClientFactory>(); mock.CreateClient(Arg.Any <string>()).Returns(HttpClientStub.Create(response)); return(mock); }
public static IHttpClientFactory CreateWithException(Exception exception) { var mock = Substitute.For <IHttpClientFactory>(); mock.CreateClient(Arg.Any <string>()).Returns(HttpClientStub.Create(exception)); return(mock); }
public static IHttpClientFactory Create(Exception exception) { var handler = HttpMessageHandlerStub.Create(req => { throw exception; }); var factoryMock = new Mock <IHttpClientFactory>(); factoryMock.Setup(x => x.CreateClient(It.IsAny <string>())).Returns(HttpClientStub.Create(handler)); return(factoryMock.Object); }
public static IHttpClientFactory Create(HttpResponseMessage response) { var handler = HttpMessageHandlerStub.Create(req => { return(response); }); var factoryMock = new Mock <IHttpClientFactory>(); factoryMock.Setup(x => x.CreateClient(It.IsAny <string>())).Returns(HttpClientStub.Create(handler)); return(factoryMock.Object); }