< Summary

Class:ApplicationCore.Analytics.CredentialsFactory
Assembly:ApplicationCore
File(s):C:\Users\Teknikaali\Source\Repos\jekyll-blog-comments\ApplicationCore\Analytics\CredentialsFactory.cs
Covered lines:11
Uncovered lines:0
Coverable lines:11
Total lines:31
Line coverage:100% (11 of 11)
Covered branches:0
Total branches:0

Coverage History

Metrics

MethodCyclomatic complexity NPath complexity Sequence coverage Branch coverage
CreateApiKeyServiceCredentials(...)10100%100%
.ctor(...)10100%100%
ProcessHttpRequestAsync(...)10100%100%

File(s)

C:\Users\Teknikaali\Source\Repos\jekyll-blog-comments\ApplicationCore\Analytics\CredentialsFactory.cs

#LineLine coverage
 1using System.Net.Http;
 2using System.Threading;
 3using System.Threading.Tasks;
 4using Microsoft.Rest;
 5
 6namespace ApplicationCore.Analytics
 7{
 8    public class CredentialsFactory : ICredentialsFactory
 9    {
 10        public ServiceClientCredentials CreateApiKeyServiceCredentials(string subscriptionKey)
 111        {
 112            return new ApiKeyServiceClientCredentials(subscriptionKey);
 113        }
 14
 15        private class ApiKeyServiceClientCredentials : ServiceClientCredentials
 16        {
 17            private readonly string _subscriptionKey;
 18
 119            public ApiKeyServiceClientCredentials(string subscriptionKey)
 120            {
 121                _subscriptionKey = subscriptionKey;
 122            }
 23
 24            public override Task ProcessHttpRequestAsync(HttpRequestMessage request, CancellationToken ct)
 125            {
 126                request.Headers.Add("Ocp-Apim-Subscription-Key", _subscriptionKey);
 127                return base.ProcessHttpRequestAsync(request, ct);
 128            }
 29        }
 30    }
 31}