public AlertHandler(ILogger <AlertHandler> logger, INotificationService notificationService, INoticationDataProvider notificationDataProvider, IOptions <DataBrokerConfiguration> dataBrokerConfig) { _notificationService = notificationService; _noticationDataProvider = notificationDataProvider; _logger = logger; _config = dataBrokerConfig.Value; }
public DataBrokerService(ILogger <DataBrokerService> logger, IOptions <DataBrokerConfiguration> dataBrokerConfig, IManagedMqttClient mqttClient, IDataBroker dataBroker) { _logger = logger; _config = dataBrokerConfig.Value; _mqttClient = mqttClient; _dataBroker = dataBroker; }
public DataBroker(ILogger <DataBroker> logger, IOptions <DataBrokerConfiguration> dataBrokerConfig, IDataProvider dataProvider, IHistoryDataProvider historyDataProvider, IAlertHandler alertHandler) { _logger = logger; _config = dataBrokerConfig.Value; _dataProvider = dataProvider; _historyDataProvider = historyDataProvider; _alertHandler = alertHandler; }
public async Task ExecuteAsync_RepeatingError_StopService() { //Arrange var config = new DataBrokerConfiguration { AlertConfiguration = new AlertConfiguration() { Enabled = false }, CloudPublishConfiguration = new CloudPublishConfiguration() { Enabled = true, UpdateIntervalMinutes = 1, HistoryUpdateIntervalMinutes = 1 }, DataBrokerEnabled = true, MqttServerAddress = "1.1.1.1" }; _mqttClientMock.Setup(m => m.IsConnected).Returns(true); _configMock.Setup(c => c.Value).Returns(config); _dataBrokerMock.Setup(d => d.PublishCurrentData()).Throws(new Exception()); //Act var btGwService = _serviceProvider.GetService <DataBrokerService>(); var cts = new CancellationTokenSource(); #pragma warning disable CS4014 // Run as fire & forget Task.Run(() => btGwService.StartAsync(cts.Token)); #pragma warning restore await Task.Delay(500); cts.Cancel(); _dataBrokerMock.Verify(d => d.PublishCurrentData(), Times.Exactly(DataBrokerService.MaxRepeatedFailCount), "The service did not stop after specified amount of repeated failed operations"); }