< Summary

Class:KeyVault.TestFramework.TestHttpMessageHandler
Assembly:Microsoft.Azure.KeyVault.TestFramework
File(s):C:\Git\azure-sdk-for-net\sdk\keyvault\Microsoft.Azure.KeyVault\tests\TestFramework\TestHttpMessageHandler.cs
Covered lines:9
Uncovered lines:4
Coverable lines:13
Total lines:40
Line coverage:69.2% (9 of 13)
Covered branches:1
Total branches:2
Branch coverage:50% (1 of 2)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
SendAsync(...)-69.23%50%

File(s)

C:\Git\azure-sdk-for-net\sdk\keyvault\Microsoft.Azure.KeyVault\tests\TestFramework\TestHttpMessageHandler.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License. See License.txt in the project root for license information.
 3
 4using System;
 5using System.Threading.Tasks;
 6using  System.Net.Http;
 7using System.Threading;
 8
 9namespace KeyVault.TestFramework
 10{
 11    public class TestHttpMessageHandler : DelegatingHandler
 12    {
 13        protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request,
 14            CancellationToken cancellationToken)
 15        {
 416            var requestUri = request.RequestUri;
 417            var authority = string.Empty;
 418            var targetUri = requestUri;
 19
 20            // NOTE: The KmsNetworkUrl setting is purely for development testing on the
 21            //       Microsoft Azure Development Fabric and should not be used outside that environment.
 422            string networkUrl = TestConfigurationManager.TryGetEnvironmentOrAppSetting("KmsNetworkUrl");
 23
 424            if (!string.IsNullOrEmpty(networkUrl))
 25            {
 026                authority = targetUri.Authority;
 027                targetUri = new Uri(new Uri(networkUrl), targetUri.PathAndQuery);
 28
 029                request.Headers.Add("Host", authority);
 030                request.RequestUri = targetUri;
 31            }
 32
 433            return base.SendAsync(request, cancellationToken).ContinueWith<HttpResponseMessage>(response =>
 434            {
 835                return response.Result;
 436            });
 37        }
 38
 39    }
 40}

Methods/Properties

SendAsync(...)