public async Task ObjectValuesChangedAfterUpdate() { var infraKernel = new TestingKernel <ConsoleLog>(mockConfig: new Dictionary <string, string> { { "BusSettings.TopicName", "OldValue" }, { "BusSettings.MessageFormatNullable", "Json" }, { "BusSettings.RequestTimeoutInMs", "30000" }, { "BusSettings.RequestTimeoutInMsNullable", "30000" }, { "BusSettings.MessageFormat", "Json" }, { "BusSettings.Date", "2016/11/08" }, { "BusSettings.DateTime", "2016-11-08 15:57:20" }, }); var extractor = infraKernel.Get <Func <BusSettings> >(); var configItems = infraKernel.Get <OverridableConfigItems>(); var eventSource = infraKernel.Get <ManualConfigurationEvents>(); var busSettings = extractor(); busSettings.TopicName.ShouldBe("OldValue"); configItems.SetValue("BusSettings.TopicName", "NewValue"); eventSource.RaiseChangeEvent(); await Task.Delay(100); busSettings = extractor(); busSettings.TopicName.ShouldBe("NewValue"); infraKernel.Dispose(); }
public async Task ChangeToBrokenConfiguration() { var infraKernel = new TestingKernel <ConsoleLog>(mockConfig: new Dictionary <string, string> { { "BusSettings.TopicName", "OldValue" }, { "BusSettings.RequestTimeoutInMs", "30000" }, }); var extractor = infraKernel.Get <Func <BusSettings> >(); var configItems = infraKernel.Get <IConfigItemsSource>() as OverridableConfigItems; var eventSource = infraKernel.Get <IConfigurationDataWatcher>() as ManualConfigurationEvents; //Make sure a good configuration have been parsed. var busSettings = extractor(); busSettings.RequestTimeoutInMs.ShouldBe(30000); configItems.SetValue("BusSettings.RequestTimeoutInMs", "NotNumber"); eventSource.RaiseChangeEvent(); await Task.Delay(100); //Make sure last good configuration is returned. busSettings = extractor(); busSettings.RequestTimeoutInMs.ShouldBe(30000); const string healthComponentName = "Configuration"; var healthMonitor = (FakeHealthMonitor)infraKernel.Get <IHealthMonitor>(); healthMonitor.Monitors.ShouldContainKey(healthComponentName); healthMonitor.Monitors[healthComponentName]().IsHealthy.ShouldBe(false); infraKernel.Dispose(); }
public void Setup() { _consulSimulator.Reset(); _serviceName = ServiceName + "_" + Guid.NewGuid(); _dateTimeFake = new DateTimeFake(false); _consulConfig = _testingKernel.Get <Func <ConsulConfig> >()(); }
public async Task ConfigObjectValuesChangedAfterUpdate() { var infraKernel = new TestingKernel <ConsoleLog>(mockConfig: new Dictionary <string, string> { { "BusSettings.TopicName", "OldValue" }, }); var manualConfigurationEvents = infraKernel.Get <ManualConfigurationEvents>(); var configItems = infraKernel.Get <OverridableConfigItems>(); var configFactory = infraKernel.Get <IConfiguration>(); var busSettings = configFactory.GetObject <BusSettings>(); busSettings.TopicName.ShouldBe("OldValue"); configItems.SetValue("BusSettings.TopicName", "NewValue"); busSettings = await manualConfigurationEvents.ApplyChanges <BusSettings>(); busSettings.TopicName.ShouldBe("NewValue"); busSettings = configFactory.GetObject <BusSettings>(); busSettings.TopicName.ShouldBe("NewValue"); infraKernel.Dispose(); }
public void SetUp() { _unitTestingKernel?.Dispose(); _serviceName = $"ServiceName{++id}"; _environmentVariableProvider = Substitute.For <IEnvironmentVariableProvider>(); _environmentVariableProvider.DataCenter.Returns("il3"); _environmentVariableProvider.DeploymentEnvironment.Returns(ORIGINATING_ENVIRONMENT); _configDic = new Dictionary <string, string> { { "Discovery.EnvironmentFallbackEnabled", "true" } }; _unitTestingKernel = new TestingKernel <ConsoleLog>(k => { k.Rebind <IEnvironmentVariableProvider>().ToConstant(_environmentVariableProvider); k.Rebind <IDiscoverySourceLoader>().To <DiscoverySourceLoader>().InSingletonScope(); SetupConsulClientMocks(); k.Rebind <Func <string, IConsulClient> >().ToMethod(_ => (s => _consulClients[s])); _dateTimeMock = Substitute.For <IDateTime>(); _dateTimeMock.Delay(Arg.Any <TimeSpan>()).Returns(c => Task.Delay(TimeSpan.FromMilliseconds(100))); k.Rebind <IDateTime>().ToConstant(_dateTimeMock); }, _configDic); _configRefresh = _unitTestingKernel.Get <ManualConfigurationEvents>(); var environmentVariableProvider = _unitTestingKernel.Get <IEnvironmentVariableProvider>(); Assert.AreEqual(_environmentVariableProvider, environmentVariableProvider); }
public async Task ScopeZoneShouldUseServiceNameAsConsoleQuery() { _unitTestingKernel.Get <Func <DiscoveryConfig> >()().Services[_serviceName].Scope = ServiceScope.Zone; SetMockToReturnHost(_serviceName); var nextHost = GetServiceDiscovey().GetNextHost(); (await nextHost).HostName.ShouldBe(_serviceName); }
public void Setup() { _log = (LogSpy)_kernel.Get <ILog>(); _discovery = Substitute.For <IDiscovery>(); _discovery.GetNodes(Arg.Any <DeploymentIdentifier>()).Returns(_ => Task.FromResult(_getSourceNodes())); _reachabilityCheck = (n, c) => throw new EnvironmentException("node is unreachable"); _environment = Substitute.For <IEnvironment>(); }
protected async Task <T> ChangeConfig <T>(IEnumerable <KeyValuePair <string, string> > keyValue) where T : IConfigObject { foreach (KeyValuePair <string, string> keyValuePair in keyValue) { _configDic[keyValuePair.Key] = keyValuePair.Value; } return(await _unitTestingKernel.Get <ManualConfigurationEvents>().ApplyChanges <T>()); }
public virtual void SetUp() { _insecureClient = _kernel.Get <IDemoService>(); _exceptionSerializer = _kernel.Get <JsonExceptionSerializer>(); Metric.ShutdownContext("Service"); TracingContext.SetUpStorage(); TracingContext.SetRequestID("1"); _testinghost = new TestingHost <IDemoService>(); _stopTask = _testinghost.RunAsync(new ServiceArguments(ServiceStartupMode.CommandLineNonInteractive)); }
public virtual void SetUp() { var kernel = new TestingKernel<ConsoleLog>(); _insecureClient = kernel.Get<IDemoService>(); _exceptionSerializer = kernel.Get<JsonExceptionSerializer>(); Metric.ShutdownContext("Service"); TracingContext.SetUpStorage(); TracingContext.SetRequestID("1"); _testinghost = new TestingHost<IDemoService>(); _stopTask = _testinghost.RunAsync(); }
public void NoConfigurationDontThrowException() { using (var infraKernel = new TestingKernel <ConsoleLog>()) { infraKernel.Get <FirstLevel>(); } }
public async Task Setup() { IDiscovery discovery = Substitute.For <IDiscovery>(); _discoveryConfig = new DiscoveryConfig { Services = new ServiceDiscoveryCollection(new Dictionary <string, ServiceDiscoveryConfig>(), new ServiceDiscoveryConfig(), new PortAllocationConfig()) }; Dictionary <string, string> configDic = new Dictionary <string, string>(); _currentEnvironment = Prod; var environment = Substitute.For <IEnvironment>(); environment.DeploymentEnvironment.Returns(_ => _currentEnvironment); _unitTestingKernel = new TestingKernel <ConsoleLog>(mockConfig: configDic); _unitTestingKernel.Rebind <IEnvironment>().ToConstant(environment); _unitTestingKernel.Rebind <IDiscovery>().ToConstant(discovery); _unitTestingKernel.Rebind <Func <DiscoveryConfig> >().ToMethod(_ => () => _discoveryConfig); _loadBalancerByEnvironment = new Dictionary <string, ILoadBalancer>(); _loadBalancerByEnvironment.Add(Prod, new MasterLoadBalancer()); _loadBalancerByEnvironment.Add(Staging, new StagingLoadBalancer()); _loadBalancerByEnvironment.Add(Canary, new PreferredEnvironmentLoadBalancer()); discovery.CreateLoadBalancer(Arg.Any <DeploymentIdentifier>(), Arg.Any <ReachabilityCheck>(), TrafficRoutingStrategy.RandomByRequestID) .ReturnsForAnyArgs(c => _loadBalancerByEnvironment[c.Arg <DeploymentIdentifier>().DeploymentEnvironment]); _serviceDiscovery = _unitTestingKernel.Get <Func <string, ReachabilityCheck, IMultiEnvironmentServiceDiscovery> >()(ServiceName, (x, y) => new Task(null)); TracingContext.SetPreferredEnvironment(null); }
public void Setup() { var environment = Substitute.For <IEnvironment>(); var deployment = new DeploymentIdentifier(ServiceName, "prod", environment); _configNodeSource = _kernel.Get <Func <DeploymentIdentifier, ConfigNodeSource> >()(deployment); }
public void Setup() { _serviceInterfaceMapper = Substitute.For <IServiceInterfaceMapper>(); _serviceInterfaceMapper.ServiceInterfaceTypes.Returns(_ => _typesToValidate); _unitTesting = new TestingKernel <ConsoleLog>(kernel => kernel.Rebind <IServiceInterfaceMapper>().ToConstant(_serviceInterfaceMapper)); _serviceValidator = _unitTesting.Get <SensitivityAttributesValidator>(); }
public async Task RequestContextShouldOverrideHostOnly() { const string serviceName = "DemoService"; int defaultPort = DisposablePort.GetPort().Port; var dict = new Dictionary <string, string> { { $"Discovery.Services.{serviceName}.Source", "Config" }, { $"Discovery.Services.{serviceName}.Hosts", "host1" }, { $"Discovery.Services.{serviceName}.DefaultPort", defaultPort.ToString() } }; var kernel = new TestingKernel <ConsoleLog>(k => k.Rebind <IDiscovery>().To <ServiceDiscovery.Rewrite.Discovery>().InSingletonScope(), dict); var providerFactory = kernel.Get <Func <string, ServiceProxyProvider> >(); var serviceProxy = providerFactory(serviceName); var messageHandler = new MockHttpMessageHandler(); messageHandler .When("*") .Respond(req => HttpResponseFactory.GetResponse(content: $"'{req.RequestUri.Host}:{req.RequestUri.Port}'")); string overrideHost = "override-host"; serviceProxy.HttpMessageHandler = messageHandler; TracingContext.SetHostOverride(serviceName, overrideHost); var request = new HttpServiceRequest("testMethod", null, new Dictionary <string, object>()); for (int i = 0; i < 50; i++) { var host = (string)await serviceProxy.Invoke(request, typeof(string)); host.ShouldBe($"{overrideHost}:{defaultPort}"); } }
public void AllPropertiesExceptNullableShouldBeSet() { var infraKernel = new TestingKernel <ConsoleLog>(mockConfig: new Dictionary <string, string> { { "BusSettings.TopicName", "il3-_env_func-infraTest" }, { "BusSettings.RequestTimeoutInMs", "30000" }, { "BusSettings.MessageFormat", "Json" }, { "BusSettings.DateTime", "2016-11-08 15:57:20" }, { "BusSettings.Date", "2016/11/08" }, { "BusSettings.TimeSpan", "00:00:01" }, { "BusSettings.Regex", "/ab+c/" }, { "BusSettings.Uri", "http://data.com" }, }); var extractor = infraKernel.Get <Func <BusSettings> >(); var busSettings = extractor(); busSettings.TopicName.ShouldBe("il3-_env_func-infraTest"); busSettings.MessageFormatNullable.ShouldBeNull(); busSettings.MessageFormat.ShouldBe(MessageFormat.Json); busSettings.RequestTimeoutInMs.ShouldBe(30000); busSettings.RequestTimeoutInMsNullable.ShouldBeNull(); busSettings.Date.ShouldBe(dateTime.Date); busSettings.DateTime.ShouldBe(dateTime); busSettings.TimeSpan.ShouldBe(TimeSpan.FromSeconds(1)); busSettings.Regex.ShouldNotBeNull(); busSettings.Uri.ShouldBe(new Uri("http://data.com")); infraKernel.Dispose(); }
private IServiceDiscovery GetServiceDiscovey() { var discovery = _unitTestingKernel.Get <Func <string, ReachabilityChecker, IServiceDiscovery> >()(_serviceName, _reachabilityChecker); Task.Delay(200).GetAwaiter().GetResult(); // let ConsulClient return the expected result before getting the dicovery object return(discovery); }
public async Task ServiceProxyRpcMessageShouldRemainSame() { const string serviceName = "DemoService"; int defaultPort = DisposablePort.GetPort().Port; var dict = new Dictionary <string, string> { { $"Discovery.Services.{serviceName}.Source", "Config" }, { $"Discovery.Services.{serviceName}.Hosts", "host1" }, { $"Discovery.Services.{serviceName}.DefaultPort", defaultPort.ToString() } }; Uri uri = null; string requestMessage = null; Func <HttpClientConfiguration, HttpMessageHandler> messageHandlerFactory = _ => { var messageHandler = new MockHttpMessageHandler(); messageHandler .When("*").Respond(async req => { requestMessage = await req.Content.ReadAsStringAsync(); uri = req.RequestUri; return(HttpResponseFactory.GetResponse(HttpStatusCode.Accepted)); }); return(messageHandler); }; using (var kernel = new TestingKernel <ConsoleLog>(k => { k.Rebind <IDiscovery>().To <ServiceDiscovery.Rewrite.Discovery>().InSingletonScope(); k.Rebind <Func <HttpClientConfiguration, HttpMessageHandler> >().ToMethod(c => messageHandlerFactory); }, dict)) { var providerFactory = kernel.Get <Func <string, ServiceProxyProvider> >(); TracingContext.SetRequestID("g"); var serviceProxy = providerFactory(serviceName); string expectedHost = "override-host"; int expectedPort = DisposablePort.GetPort().Port; TracingContext.SetHostOverride(serviceName, expectedHost, expectedPort); var request = new HttpServiceRequest("testMethod", null, new Dictionary <string, object>()); using (TracingContext.Tags.SetUnencryptedTag("test", 1)) await serviceProxy.Invoke(request, typeof(string)); var body = requestMessage; Console.WriteLine($"error: {body}"); JsonConvert.DeserializeObject <GigyaRequestProtocol>(body, new JsonSerializerSettings() { MissingMemberHandling = MissingMemberHandling.Error }); uri.Host.ShouldBe(expectedHost); uri.Port.ShouldBe(expectedPort); } }
private async Task <HttpRequestMessage> GetRequestFor <T>(Func <T, Task> action) { HttpRequestMessage request = null; string requestContent = null; var mockHandler = new MockHttpMessageHandler(); mockHandler.When("*").Respond(async r => { request = r; requestContent = await r.Content.ReadAsStringAsync(); return(HttpResponseFactory.GetResponse(content: "''")); }); var kernel = new TestingKernel <ConsoleLog>(); var client = kernel .Get <ServiceProxyProviderSpy <T> >(new ConstructorArgument("httpMessageHandler", mockHandler)) .Client; await action(client); var contentClone = new StringContent(requestContent, Encoding.UTF8, "application/json"); foreach (KeyValuePair <string, IEnumerable <string> > header in request.Content.Headers.Where(h => h.Key.StartsWith("X"))) { contentClone.Headers.Add(header.Key, header.Value); } kernel.Dispose(); return(new HttpRequestMessage(request.Method, request.RequestUri) { Content = contentClone }); }
public async Task OneHostHasNetworkErrorShouldMoveToNextHost() { var port = DisposablePort.GetPort().Port; var dict = new Dictionary <string, string> { { "Discovery.Services.DemoService.Source", "Config" }, { "Discovery.Services.DemoService.Hosts", "host1,host2" }, { "Discovery.Services.DemoService.DefaultPort", port.ToString() } }; int counter = 0; Func <HttpClientConfiguration, HttpMessageHandler> messageHandlerFactory = _ => { var messageHandler = new MockHttpMessageHandler(); messageHandler .When("*") .Respond(req => { if (req.Method == HttpMethod.Get && req.RequestUri.Scheme == "https") { throw new HttpRequestException(); } counter++; if (req.RequestUri.Host == "host1") { throw new HttpRequestException(); } return(HttpResponseFactory.GetResponse(content: $"'{req.RequestUri.Host}'")); }); return(messageHandler); }; using (var kernel = new TestingKernel <ConsoleLog>( k => { k.Rebind <IDiscovery>().To <ServiceDiscovery.Rewrite.Discovery>().InSingletonScope(); k.Rebind <Func <HttpClientConfiguration, HttpMessageHandler> >().ToMethod(c => messageHandlerFactory); }, dict) ) { var providerFactory = kernel.Get <Func <string, ServiceProxyProvider> >(); var serviceProxy = providerFactory("DemoService"); serviceProxy.DefaultPort = port; TracingContext.SetRequestID("1"); var request = new HttpServiceRequest("testMethod", null, new Dictionary <string, object>()); for (int i = 0; i < 3; i++) { var server = await serviceProxy.Invoke(request, typeof(string)); server.ShouldBe("host2"); } counter.ShouldBe(3); } }
public void Setup() { _configDic = new Dictionary <string, string>(); _unitTestingKernel = new TestingKernel <ConsoleLog>(_ => { }, _configDic); _settingsFactory = name => _unitTestingKernel.Get <Func <DiscoveryConfig> >()().Services[name]; }
public void SetUp() { _unitTestingKernel?.Dispose(); _serviceName = $"ServiceName{++id}"; _environment = Substitute.For <IEnvironment>(); _environment.Zone.Returns("il3"); _environment.DeploymentEnvironment.Returns(ORIGINATING_ENVIRONMENT); _environment.ConsulAddress.Returns((string)null); _configDic = new Dictionary <string, string> { { "Discovery.EnvironmentFallbackEnabled", "true" } }; _unitTestingKernel = new TestingKernel <ConsoleLog>(k => { k.Rebind <IEnvironment>().ToConstant(_environment); k.Rebind <IDiscovery>().To <ServiceDiscovery.Rewrite.Discovery>().InSingletonScope(); SetupConsulMocks(k); _dateTimeMock = Substitute.For <IDateTime>(); _dateTimeMock.Delay(Arg.Any <TimeSpan>()).Returns(c => Task.Delay(TimeSpan.FromMilliseconds(100))); k.Rebind <IDateTime>().ToConstant(_dateTimeMock); }, _configDic); var environment = _unitTestingKernel.Get <IEnvironment>(); Assert.AreEqual(_environment, environment); }
private IMultiEnvironmentServiceDiscovery GetServiceDiscovery() { var discovery = _unitTestingKernel.Get <Func <string, ReachabilityCheck, IMultiEnvironmentServiceDiscovery> >()(_serviceName, (n, c) => Task.FromResult(true)); return(discovery); }
public async Task OneHostHasNetworkErrorShouldMoveToNextHost() { var dict = new Dictionary <string, string> { { "Discovery.Services.DemoService.Source", "Config" }, { "Discovery.Services.DemoService.Hosts", "host1,host2" }, { "Discovery.Services.DemoService.DefaultPort", "5555" } }; using (var kernel = new TestingKernel <ConsoleLog>( k => { k.Rebind <IDiscovery>().To <ServiceDiscovery.Rewrite.Discovery>().InSingletonScope(); }, dict) ) { var providerFactory = kernel.Get <Func <string, ServiceProxyProvider> >(); var serviceProxy = providerFactory("DemoService"); //Disable TracingContext.SetRequestID("1"); CallContext.FreeNamedDataSlot("#ORL_RC"); int counter = 0; var messageHandler = new MockHttpMessageHandler(); messageHandler .When("*") .Respond(req => { bool disableReachabilityChecker = req.Content == null; if (disableReachabilityChecker) { throw new HttpRequestException(); } counter++; if (req.RequestUri.Host == "host1") { throw new HttpRequestException(); } return(HttpResponseFactory.GetResponse(content: $"'{req.RequestUri.Host}'")); }); serviceProxy.HttpMessageHandler = messageHandler; var request = new HttpServiceRequest("testMethod", null, new Dictionary <string, object>()); for (int i = 0; i < 3; i++) { var server = await serviceProxy.Invoke(request, typeof(string)); server.ShouldBe("host2"); } counter.ShouldBe(4); } }
public async Task FailedHostShouldBeRemovedFromHostList() { var port = DisposablePort.GetPort().Port; var dict = new Dictionary <string, string> { { "Discovery.Services.DemoService.Source", "local" }, { "Discovery.Services.DemoService.DefaultPort", port.ToString() } }; int counter = 0; Func <HttpClientConfiguration, HttpMessageHandler> messageHandlerFactory = _ => { var messageHandler = new MockHttpMessageHandler(); messageHandler .When("*") .Respond(req => { bool disableReachabilityChecker = req.Content == null; if (disableReachabilityChecker) { throw new HttpRequestException(); } counter++; throw new HttpRequestException(); }); return(messageHandler); }; using (var kernel = new TestingKernel <ConsoleLog>( k => { k.Rebind <IDiscovery>().To <ServiceDiscovery.Rewrite.Discovery>().InSingletonScope(); k.Rebind <Func <HttpClientConfiguration, HttpMessageHandler> >().ToMethod(c => messageHandlerFactory); }, dict) ) { var providerFactory = kernel.Get <Func <string, ServiceProxyProvider> >(); var serviceProxy = providerFactory("DemoService"); serviceProxy.DefaultPort = port; //Disable TracingContext.SetRequestID("1"); CallContext.FreeNamedDataSlot("#ORL_RC"); var request = new HttpServiceRequest("testMethod", null, new Dictionary <string, object>()); for (int i = 0; i < 10; i++) { Func <Task> act = () => serviceProxy.Invoke(request, typeof(string)); await act.ShouldThrowAsync <ServiceUnreachableException>(); } counter.ShouldBe(1); } }
public async Task ServiceInZoneScope() { _configDic[$"Discovery.Services.{SERVICE_NAME}.Scope"] = "Zone"; await _unitTestingKernel.Get <ManualConfigurationEvents>().ApplyChanges <DiscoveryConfig>(); await GetFirstResult().ConfigureAwait(false); Assert.AreEqual($"{SERVICE_NAME}", _requestedConsulServiceName); }
public void ShouldCallConfigObjectCacheWhileScanningAssembliesForIConfigObjects() { IConfigObjectsCache configCacheMock = Substitute.For <IConfigObjectsCache>(); TestingKernel <ConsoleLog> kernel = new TestingKernel <ConsoleLog>(k => k.Rebind <IConfigObjectsCache>().ToConstant(configCacheMock)); IAssemblyProvider aProvider = kernel.Get <IAssemblyProvider>(); int typesCount = aProvider.GetAllTypes().Where(ConfigObjectCreator.IsConfigObject).Count(); configCacheMock.Received(typesCount).RegisterConfigObjectCreator(Arg.Any <IConfigObjectCreator>()); }
public virtual void SetUp() { TracingContext.SetUpStorage(); unitTesting = new TestingKernel <ConsoleLog>(mockConfig: MockConfig); Metric.ShutdownContext(ServiceProxyProvider.METRICS_CONTEXT_NAME); TracingContext.SetRequestID("1"); ExceptionSerializer = unitTesting.Get <JsonExceptionSerializer>(); }
public void ServicePointManagerIsUpdated() { TestingKernel <ConsoleLog> kernel = new TestingKernel <ConsoleLog>(); ServicePointManagerDefaultConfig config = kernel.Get <Func <ServicePointManagerDefaultConfig> >()(); Assert.AreEqual(ServicePointManager.DefaultConnectionLimit, config.DefaultConnectionLimit); Assert.AreEqual(ServicePointManager.UseNagleAlgorithm, config.UseNagleAlgorithm); Assert.AreEqual(ServicePointManager.Expect100Continue, config.Expect100Continue); }
public async Task Setup() { _configDic = new Dictionary <string, string>(); _unitTestingKernel = new TestingKernel <ConsoleLog>(k => { k.Rebind <IDiscoverySourceLoader>().To <DiscoverySourceLoader>().InSingletonScope(); k.Rebind <IEnvironmentVariableProvider>().To <EnvironmentVariableProvider>(); _consulAdapterMock = Substitute.For <IConsulClient>(); _consulAdapterMock.GetEndPoints(Arg.Any <string>()).Returns(Task.FromResult(new EndPointsResult { EndPoints = new[] { new ConsulEndPoint { HostName = "dumy" } } })); k.Rebind <IConsulClient>().ToConstant(_consulAdapterMock); }, _configDic); _configRefresh = _unitTestingKernel.Get <ManualConfigurationEvents>(); _serviceDiscovery = _unitTestingKernel.Get <Func <string, ReachabilityChecker, ServiceDiscovery.ServiceDiscovery> >()("ServiceName", x => Task.FromResult(true)); }