< Summary

Class:Microsoft.Azure.ApplicationInsights.Query.ApiKeyClientCredentials
Assembly:Microsoft.Azure.ApplicationInsights.Query
File(s):C:\Git\azure-sdk-for-net\sdk\applicationinsights\Microsoft.Azure.ApplicationInsights.Query\src\Customized\ApiKeyClientCredentials.cs
Covered lines:6
Uncovered lines:1
Coverable lines:7
Total lines:29
Line coverage:85.7% (6 of 7)
Covered branches:1
Total branches:2
Branch coverage:50% (1 of 2)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-80%50%
ProcessHttpRequestAsync(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\applicationinsights\Microsoft.Azure.ApplicationInsights.Query\src\Customized\ApiKeyClientCredentials.cs

#LineLine coverage
 1using Microsoft.Rest;
 2using System;
 3using System.Net.Http;
 4using System.Threading;
 5using System.Threading.Tasks;
 6
 7namespace Microsoft.Azure.ApplicationInsights.Query
 8{
 9    public class ApiKeyClientCredentials : ServiceClientCredentials
 10    {
 11        private string token;
 12
 2013        public ApiKeyClientCredentials(string token)
 14        {
 2015            if (string.IsNullOrEmpty(token))
 16            {
 017                throw new ArgumentException($"{nameof(token)} must not be null or empty");
 18            }
 19
 2020            this.token = token;
 2021        }
 22
 23        public override Task ProcessHttpRequestAsync(HttpRequestMessage request, CancellationToken cancellationToken)
 24        {
 4025            request.Headers.Add("x-api-key", token);
 4026            return Task.FromResult(true);
 27        }
 28    }
 29}