public void Setup()
        {
            Metric.ShutdownContext("Workload");
            Metric.ShutdownContext("Silo");
            _serviceArguments = new ServiceArguments();
            _dateTimeFake     = new DateTimeFake {
                UtcNow = DateTime.UtcNow
            };

            _kernel = new TestingKernel <ConsoleLog>(k =>
            {
                k.Rebind <IHealthMonitor>().To <HealthMonitor>();
                k.Rebind <ServiceArguments>().ToMethod(c => _serviceArguments);
                k.Rebind <IDateTime>().ToMethod(c => _dateTimeFake);
            });

            _kernel.Get <Ninject.SystemInitializer.SystemInitializer>().Init();
            _config = _kernel.Get <Func <WorkloadMetricsConfig> >()();
            _config.ReadPerformanceCounters = true;
            _config.MinUnhealthyDuration    = MinUnhealthyDuration;

            SetupOrleansQueueLength();

            _workloadMetrics = _kernel.Get <IWorkloadMetrics>();
        }
예제 #2
0
 public void Setup()
 {
     _consulSimulator.Reset();
     _serviceName  = ServiceName + "_" + Guid.NewGuid();
     _dateTimeFake = new DateTimeFake(false);
     _consulConfig = new ConsulConfig();
 }
예제 #3
0
 public void Setup()
 {
     _consulSimulator.Reset();
     _serviceName  = ServiceName + "_" + Guid.NewGuid();
     _dateTimeFake = new DateTimeFake(false);
     _consulConfig = _testingKernel.Get <Func <ConsulConfig> >()();
 }
        private IMemoizer CreateMemoizer()
        {
            var metadataProvider = new MetadataProvider();

            TimeFake = new DateTimeFake {
                UtcNow = DateTime.UtcNow
            };
            return(new AsyncMemoizer(new AsyncCache(new ConsoleLog(), Metric.Context("AsyncCache"), TimeFake), metadataProvider, Metric.Context("Tests")));
        }
예제 #5
0
        public override void Setup()
        {
            base.Setup();
            _dateTimeFake = new DateTimeFake();

            _createdNodeSources = new List <Type>();
            SetupConsulNodeSource();
            SetupSlowNodeSource();

            _discovery            = _unitTestingKernel.Get <IDiscovery>();
            _deploymentIdentifier = new DeploymentIdentifier(ServiceName, Env, Substitute.For <IEnvironment>());
        }
예제 #6
0
        public void Setup()
        {
            _dateTimeFake = new DateTimeFake();

            healthMonitor = Substitute.For <IHealthMonitor>();
            healthMonitor.SetHealthFunction(Arg.Any <string>(), Arg.Any <Func <HealthCheckResult> >(), Arg.Any <Func <Dictionary <string, string> > >())
            .Returns(c =>
            {
                _getHealthResult = c.Arg <Func <HealthCheckResult> >();
                return(new ComponentHealthMonitor(c.Arg <string>(), _getHealthResult));
            });
        }
예제 #7
0
        public void Setup()
        {
            _dateTimeFake = new DateTimeFake();

            _createdNodeSources = new List <Type>();
            SetupConsulNodeSource();
            SetupSlowNodeSource();

            _discoveryConfig          = new DiscoveryConfig();
            _discoveryConfig.Services = new ServiceDiscoveryCollection(new Dictionary <string, ServiceDiscoveryConfig>(), new ServiceDiscoveryConfig(), new PortAllocationConfig());

            _discovery            = _kernel.Get <IDiscovery>();
            _deploymentIdentifier = new DeploymentIdentifier(ServiceName, Env, Substitute.For <IEnvironment>());
        }
        public void Setup()
        {
            _unitTestingKernel = new TestingKernel <ConsoleLog>();

            _dateTimeFake = new DateTimeFake {
                UtcNow = new DateTime(2016, 11, 11)
            };
            Kernel.Rebind <IDateTime>().ToConstant(_dateTimeFake);

            var environmentVarialbesMock = Substitute.For <IEnvironmentVariableProvider>();

            environmentVarialbesMock.DeploymentEnvironment.Returns(ENV);
            Kernel.Rebind <IEnvironmentVariableProvider>().ToConstant(environmentVarialbesMock);

            SetupConsulClientAdapter();
        }
예제 #9
0
 private void SetupDateTimeFake()
 {
     _dateTimeFake = new DateTimeFake(manualDelay: true);
     Kernel.Rebind <IDateTime>().ToConstant(_dateTimeFake);
 }