Summary

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

History

Metrics

MethodCyclomatic complexity  NPath complexity  Sequence coverage  Branch coverage  
AddMvc(...)10100100

File(s)

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

#LineLine coverage
 1using System.Buffers;
 2using Microsoft.AspNetCore.Hosting;
 3using Microsoft.AspNetCore.Mvc.Formatters;
 4using Microsoft.Extensions.DependencyInjection;
 5using Microsoft.Extensions.Logging;
 6using Newtonsoft.Json;
 7using Newtonsoft.Json.Converters;
 8using Newtonsoft.Json.Serialization;
 9using ProjectX.PublicApi.Extensions;
 10using ProjectX.PublicApi.Filters;
 11
 12namespace ProjectX.PublicApi.Extensions
 13{
 14    public static class StartupMvc
 15    {
 16        public static void AddMvc(
 17            this IServiceCollection services,
 18            IHostingEnvironment environment,
 19            ILogger logger)
 20        {
 2421            services.AddMvc(mvcOptions =>
 2422            {
 4823                mvcOptions.OutputFormatters.Clear();
 2424
 4825                var jsonSettings = new JsonSerializerSettings
 4826                {
 4827                    ContractResolver =
 4828                        new CamelCasePropertyNamesContractResolver(),
 4829                    NullValueHandling = NullValueHandling.Ignore,
 4830                    Formatting = Formatting.None,
 4831                    ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
 4832                    StringEscapeHandling = StringEscapeHandling.EscapeHtml,
 4833                };
 4834                jsonSettings.Converters.Add(
 4835                    new StringEnumConverter { CamelCaseText = true });
 2436
 4837                mvcOptions.OutputFormatters.Add(new JsonOutputFormatter(
 4838                    jsonSettings,
 4839                    ArrayPool<char>.Shared));
 2440
 4841                mvcOptions.Filters.Add(
 4842                    new GlobalExceptionFilter(environment, logger));
 4843            });
 2444        }
 45    }
 46}