コード例 #1
0
        private async Task <GetAbracadabraResult> MockHandle(GetAbracadabraQuery request, CancellationToken cancellationToken)
        {
            var mockHttpClient = new MockHttpClient();

            try
            {
                var httpClient = mockHttpClient.GetMockClient();

                var response = await httpClient.GetAsync("http://test.com/mockio");

                return(new GetAbracadabraResult(true, await response.Content.ReadAsStringAsync()));
            }
            catch (HttpRequestException)
            {
                return(new GetAbracadabraResult(false, "External service is unavailable."));
            }
        }