public void ShouldSendFailureIfNoMatchingCheckServices() { _goodCheckService.CanHandle(Arg.Any <Endpoint>()).Returns(false); _service.ProcessEndpoint(_validEndpoint, 0); _stateService.Received().AddEndpointCheckResult(_validEndpoint.Id, Arg.Is <EndpointCheckResult>(r => r.Error.Message == "There is no registered handler for this kind of endpoint."), true); }
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(); } }