< Summary

Class:Microsoft.Extensions.DependencyInjection.UseAkkaTestKitExtensions
Assembly:SeungYongShim.Akka.DependencyInjection.XUnit2
File(s):/home/runner/work/SeungYongShim.Akka/SeungYongShim.Akka/src/SeungYongShim.Akka.DependencyInjection.XUnit2/UseAkkaExtensions.cs
Covered lines:11
Uncovered lines:0
Coverable lines:11
Total lines:38
Line coverage:100% (11 of 11)
Covered branches:0
Total branches:0
Tag:81_945672945

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
UseAkkaWithXUnit2(...)0%110100%
UseAkkaWithXUnit2(...)0%110100%
AddAkkaTestKit(...)0%440100%

File(s)

/home/runner/work/SeungYongShim.Akka/SeungYongShim.Akka/src/SeungYongShim.Akka.DependencyInjection.XUnit2/UseAkkaExtensions.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Linq;
 4using Akka.Actor;
 5using Akka.Actor.Setup;
 6using Akka.TestKit.Xunit2;
 7using Akka.Util.Internal;
 8using Microsoft.Extensions.Hosting;
 9using SeungYongShim.Akka.DependencyInjection;
 10using SeungYongShim.Akka.DependencyInjection.Abstractions;
 11
 12namespace Microsoft.Extensions.DependencyInjection
 13{
 14    public delegate IActorRef GetTestActor();
 15
 16    public static class UseAkkaTestKitExtensions
 17    {
 18        public static IHostBuilder UseAkkaWithXUnit2(this IHostBuilder host) =>
 619            host.UseAkkaWithXUnit2(default);
 20
 21        public static IHostBuilder UseAkkaWithXUnit2(this IHostBuilder host,
 22                                                     params Type [] mockType) =>
 723            host.ConfigureServices((context, services) =>
 1424                services.AddAkkaTestKit(mockType ?? Enumerable.Empty<Type>()));
 25
 26        private static IServiceCollection AddAkkaTestKit(this IServiceCollection services, IEnumerable<Type> mocks)
 727        {
 1428            services.AddSingleton(sp => new TestKit(sp.GetService<ActorSystemSetup>()))
 1929                    .AddSingleton<GetTestActor>(sp => () => sp.GetService<TestKit>().TestActor)
 1430                    .AddSingleton(sp => sp.GetService<TestKit>().Sys);
 31
 832            mocks.ForEach(x => services.AddSingleton(typeof(IPropsFactory<>).MakeGenericType(x),
 833                                                     typeof(FakePropsFactory<>).MakeGenericType(x)));
 34
 735            return services;
 736        }
 37    }
 38}