Esempio n. 1
0
        public void Throws_exception_if_response_not_OK()
        {
            var response = new HttpResponseMessage(HttpStatusCode.BadRequest);
            var httpClient = new HttpClient(new FakeHandler
            {
                Response = response,
                InnerHandler = new HttpClientHandler()
            });

            var client = new GuidHttpClient(httpClient);
            Assert.Throws<Exception>(() => client.Execute());
        }
Esempio n. 2
0
        public void Returns_content_if_response_is_OK()
        {
            string content = Guid.NewGuid().ToString();
            var response = new HttpResponseMessage(HttpStatusCode.OK);
            response.Content = new StringContent(content);

            var httpClient = new HttpClient(new FakeHandler
            {
                Response = response,
                InnerHandler = new HttpClientHandler()
            });

            var client = new GuidHttpClient(httpClient);
            string result = client.Execute();
            Assert.AreEqual(content, result);
        }