< Summary

Class:JekyllBlogCommentsAzure.IServiceCollectionExtensions
Assembly:JekyllBlogCommentsAzure
File(s):C:\Users\Teknikaali\Source\Repos\jekyll-blog-comments\JekyllBlogCommentsAzure\IServiceCollectionExtensions.cs
Covered lines:22
Uncovered lines:0
Coverable lines:22
Total lines:42
Line coverage:100% (22 of 22)
Covered branches:0
Total branches:0

Coverage History

Metrics

MethodCyclomatic complexity NPath complexity Sequence coverage Branch coverage
AddPostCommentService(...)10100%100%

File(s)

C:\Users\Teknikaali\Source\Repos\jekyll-blog-comments\JekyllBlogCommentsAzure\IServiceCollectionExtensions.cs

#LineLine coverage
 1using ApplicationCore;
 2using ApplicationCore.Analytics;
 3using ApplicationCore.Model;
 4using Microsoft.Azure.WebJobs.Host.Bindings;
 5using Microsoft.Extensions.Configuration;
 6using Microsoft.Extensions.DependencyInjection;
 7using Microsoft.Extensions.Options;
 8
 9namespace JekyllBlogCommentsAzure
 10{
 11    public static class IServiceCollectionExtensions
 12    {
 13        public static IServiceCollection AddPostCommentService(this IServiceCollection services)
 214        {
 215            var executionContextOptions = services.BuildServiceProvider()
 216                    .GetService<IOptions<ExecutionContextOptions>>().Value;
 217            var currentDirectory = executionContextOptions.AppDirectory;
 18
 219            var configRoot = new ConfigurationBuilder()
 220                .SetBasePath(currentDirectory)
 221                .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
 222                .AddEnvironmentVariables()
 223                .Build();
 24
 225            var config = new WebConfiguration(configRoot, new ConfigProvider());
 26
 227            var commentFactory = new CommentFactory(
 228                new CommentFormFactory(),
 229                new TextAnalyzer(config.TextAnalytics, new TextAnalyticsClientFactory(new CredentialsFactory())));
 230            var pullRequestService = new PullRequestService(
 231                    config.GitHub,
 232                    config.Comment,
 233                    new SerializerFactory().BuildSerializer(),
 234                    new GitHubClientFactory(config.GitHub).CreateClient());
 35
 236            var postCommentService = new PostCommentService(config.Comment, commentFactory, pullRequestService);
 237            services.AddSingleton<IPostCommentService>(postCommentService);
 38
 239            return services;
 240        }
 41    }
 42}