Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
 public static HttpClient Create(Exception ex) => new HttpClientStub(HttpMessageHandlerStub.Create(x => { throw ex; }));
Exemple #4
0
 public static HttpClient Create(HttpResponseMessage response) => new HttpClientStub(HttpMessageHandlerStub.Create(x => response));