private async Task RunCoreAsync(ServiceTransportType serviceTransportType, Func <ServiceHubContext, Task> testAction, Action <ConcurrentDictionary <HubServiceEndpoint, List <MessageVerifiableConnection> > > assertAction)
        {
            using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
            {
                var connectionFactory = new TestServiceConnectionFactory();
                var hubContext        = await new ServiceHubContextBuilder()
                                        .WithOptions(o =>
                {
                    o.ServiceTransportType = serviceTransportType;
                    o.ServiceEndpoints     = ServiceEndpoints;
                })
                                        .WithLoggerFactory(loggerFactory)
                                        .ConfigureServices(services => services.AddSingleton <IServiceConnectionFactory>(connectionFactory))
                                        .CreateAsync(Hub, default);

                await testAction.Invoke(hubContext);

                var createdConnections = connectionFactory.CreatedConnections;
                assertAction.Invoke(createdConnections);
            }
        }
        private async Task MockConnectionTestAsync(ServiceTransportType serviceTransportType, Func <ServiceHubContext, Task> testAction, Action <Dictionary <HubServiceEndpoint, List <TestServiceConnection> > > assertAction)
        {
            using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
            {
                var connectionFactory = new TestServiceConnectionFactory();
                var hubContext        = await new ServiceHubContextBuilder()
                                        .WithOptions(o =>
                {
                    o.ServiceTransportType = serviceTransportType;
                    o.ServiceEndpoints     = ServiceEndpoints;
                })
                                        .WithLoggerFactory(loggerFactory)
                                        .ConfigureServices(services => services.AddSingleton <IServiceConnectionFactory>(connectionFactory))
                                        .CreateAsync(Hub, default);

                await testAction.Invoke(hubContext);

                var createdConnections = connectionFactory.CreatedConnections.ToDictionary(p => p.Key, p => p.Value.Select(conn => conn as TestServiceConnection).ToList());
                assertAction.Invoke(createdConnections);
            }
        }