Summary

Class:ProjectX.PublicApi.Extensions.StartupDataLayer
Assembly:ProjectX.PublicApi
File(s):C:\private\projects\projectx\backend\src\ProjectX.PublicApi\Startup\StartupDataLayer.cs
Covered lines:7
Uncovered lines:0
Coverable lines:7
Total lines:30
Line coverage:100%
Branch coverage:100%

History

Metrics

MethodCyclomatic complexity  NPath complexity  Sequence coverage  Branch coverage  
AddDataLayer(...)32100100

File(s)

C:\private\projects\projectx\backend\src\ProjectX.PublicApi\Startup\StartupDataLayer.cs

#LineLine coverage
 1using System.Linq;
 2using Microsoft.AspNetCore.Hosting;
 3using Microsoft.Extensions.Configuration;
 4using Microsoft.Extensions.DependencyInjection;
 5using ProjectX.Ef;
 6
 7namespace ProjectX.PublicApi.Extensions
 8{
 9    public static class StartupDataLayer
 10    {
 11        public static void AddDataLayer(
 12            this IServiceCollection services,
 13            IHostingEnvironment environment,
 14            IConfiguration config)
 15        {
 16            // Register MainDbContext only if not already one registered
 2417            var descriptor = services.FirstOrDefault(d =>
 50018                d.ServiceType == typeof(MainDbContext));
 19
 2420             if (descriptor == null)
 21            {
 322                services.AddEntityFrameworkNpgsql(
 323                    config.GetConnectionString("MainDbContext"));
 24            }
 25
 2426            services.AddEntityFrameworkWriteStores();
 27            // services.AddEntityFrameworkReadStores();
 2428        }
 29    }
 30}