Example #1
0
        public static IHttpClientFactory CreateWithResponse(HttpResponseMessage response)
        {
            var mock = Substitute.For <IHttpClientFactory>();

            mock.CreateClient(Arg.Any <string>()).Returns(HttpClientStub.Create(response));

            return(mock);
        }
Example #2
0
        public static IHttpClientFactory CreateWithException(Exception exception)
        {
            var mock = Substitute.For <IHttpClientFactory>();

            mock.CreateClient(Arg.Any <string>()).Returns(HttpClientStub.Create(exception));

            return(mock);
        }
Example #3
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);
        }
Example #4
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);
        }