Пример #1
0
        private void CreateConsulMock(string serviceName)
        {
            var mock = new ConsulClientMock();

            mock.SetResult(new EndPointsResult
            {
                EndPoints = new EndPoint[] { new ConsulEndPoint {
                                                 HostName = "dumy", Version = ServiceVersion
                                             } },
                IsQueryDefined = true
            });

            _consulClient[serviceName] = mock;
        }
        public async Task Setup()
        {
            _configDic         = new Dictionary <string, string>();
            _unitTestingKernel = new TestingKernel <ConsoleLog>(k =>
            {
                k.Rebind <IDiscoverySourceLoader>().To <DiscoverySourceLoader>().InSingletonScope();
                k.Rebind <IEnvironment>().ToConstant(new HostEnvironment(new TestHostEnvironmentSource()));
                _consulClientMock = new ConsulClientMock();
                _consulClientMock.SetResult(new EndPointsResult {
                    EndPoints = new[] { new ConsulEndPoint {
                                            HostName = "dumy", Version = ServiceVersion
                                        } }, ActiveVersion = ServiceVersion, IsQueryDefined = true
                });
                k.Rebind <Func <string, IConsulClient> >().ToMethod(c => s => _consulClientMock);
            }, _configDic);

            _configRefresh    = _unitTestingKernel.Get <ManualConfigurationEvents>();
            _serviceDiscovery = _unitTestingKernel.Get <Func <string, ReachabilityChecker, ServiceDiscovery.ServiceDiscovery> >()("ServiceName", x => Task.FromResult(true));
        }