示例#1
0
        public async Task Setup()
        {
            _consulSimulator.Reset();
            _testingKernel = new TestingKernel <ConsoleLog>(k =>
            {
                _environment = Substitute.For <IEnvironment>();
                _environment.ConsulAddress.Returns($"{CurrentApplicationInfo.HostName}:{ConsulPort}");
                _environment.Zone.Returns(Zone);
                k.Rebind <IEnvironment>().ToMethod(_ => _environment);
                k.Rebind <Func <ConsulConfig> >().ToMethod(_ => () => _consulConfig);
                k.Rebind <ConsulNodeSourceFactory>().ToSelf().InTransientScope();
            });
            _serviceName = $"MyService_{Guid.NewGuid().ToString().Substring(5)}";

            _deploymentIdentifier = new DeploymentIdentifier(_serviceName, "prod", Substitute.For <IEnvironment>());
            _consulConfig         = new ConsulConfig {
                ErrorRetryInterval = TimeSpan.FromMilliseconds(10)
            };
            _consulNodeSourceFactory = _testingKernel.Get <ConsulNodeSourceFactory>();
        }
 public override void Setup()
 {
     _consulSimulator.Reset();
     _deploymentIdentifier = new DeploymentIdentifier(ServiceName + "_" + Guid.NewGuid(), Env, _environment);
 }