コード例 #1
0
        public async Task TestMakeGetRequestThrowsContentfulExceptionOnErrorCode()
        {
            const string requestUri = "http://test.com";
            var cancellationToken = new CancellationToken();

            var mockHttpClient = new Mock<IHttpClientWrapper>();
            mockHttpClient.Setup(h => h.GetAsync(requestUri, cancellationToken))
                .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.BadRequest)
                {
                    Content = new StringContent("")
                });

            var client = new ContentfulClient("spaceId", mockHttpClient.Object);
            await client.MakeGetRequestAsync(requestUri, cancellationToken);
        }
コード例 #2
0
        public async Task TestMakeGetRequestThrowsContentfulExceptionOnErrorCode()
        {
            const string requestUri        = "http://test.com";
            var          cancellationToken = new CancellationToken();

            var mockHttpClient = new Mock <IHttpClientWrapper>();

            mockHttpClient.Setup(h => h.GetAsync(requestUri, cancellationToken))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.BadRequest)
            {
                Content = new StringContent("")
            });

            var client = new ContentfulClient("spaceId", mockHttpClient.Object);
            await client.MakeGetRequestAsync(requestUri, cancellationToken);
        }