예제 #1
0
        public void Setup()
        {
            _provider         = TestUtility.InitDI();
            _settingsService  = Substitute.For <SettingsService>((IServiceProvider)null);
            _stateService     = Substitute.For <StateService>(_provider, null);
            _goodCheckService = Substitute.For <ICheckService>();
            _badCheckService1 = Substitute.For <ICheckService>();
            _badCheckService2 = Substitute.For <ICheckService>();

            _service = new EndpointProcessService(_settingsService, _stateService, new List <ICheckService> {
                _badCheckService1, _goodCheckService, _badCheckService2
            }, _provider);

            _goodCheckService.CanHandle(Arg.Any <Endpoint>()).Returns(true);
            _badCheckService1.CanHandle(Arg.Any <Endpoint>()).Returns(false);
            _badCheckService2.CanHandle(Arg.Any <Endpoint>()).Returns(false);

            _validEndpoint             = TestUtility.CreateHttpEndpoint("A", true, 0, "http://asdf");
            _validEndpoint.LastUpdated = DateTimeOffset.UtcNow;
            using (var scope = _provider.CreateScope())
                using (var dbContext = scope.ServiceProvider.GetRequiredService <ApplicationDbContext>())
                {
                    dbContext.Endpoints.Add(_validEndpoint);
                    dbContext.SaveChanges();
                }
        }
예제 #2
0
        public void Setup()
        {
            _provider       = TestUtility.InitDI();
            _scope          = _provider.CreateScope();
            _testDbContext  = new ApplicationDbContext(_scope.ServiceProvider.GetRequiredService <DbContextOptions <ApplicationDbContext> >());
            _processService = Substitute.For <EndpointProcessService>(null, null, null, null);
            _service        = new MonitorJob(_provider, _processService);

            SeedEndpoints();
        }