public async Task ProcessBrokerMessageAsync_DoNothingWhenNotWithBrokerTopicPrefix() { var message = new MqttMessage("SYS/broker/clients/connected", "120", _clock.GetCurrentInstant()); var mock = new Mock <IMosquittoBrokerService>(); mock.Setup(b => b.RegisterBrokerStatisticsAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <Instant>())).Returns(Task.FromResult(true)); var service = new MqttMessageIngestionService(_deviceService, _mqttIdentifierService, _brokerService, _valueService, new NullLogger <MqttMessageIngestionService>()); await service.ProcessBrokerMessageAsync(message); mock.Verify(b => b.RegisterBrokerStatisticsAsync("clients/connected", "120", _initial), Times.Never()); }
public MqttMessageIngestionServiceTest() { _dbContext = ApplicationDbContextHelper.BuildTestDbContext(); _initial = SystemClock.Instance.GetCurrentInstant(); _clock = new FakeClock(_initial); var mock = new Mock <IMosquittoBrokerPidAccessor>(); mock.SetupGet(a => a.BrokerPid).Returns(10000); var mockPlugin = new Mock <IMosquittoBrokerPluginPidService>(); mockPlugin.SetupGet(a => a.BrokerPidFromAuthPlugin).Returns(10000); _brokerService = new MosquittoBrokerService(_clock, new NullLogger <MosquittoBrokerService>(), mock.Object, mockPlugin.Object); _mqttIdentifierService = new MqttIdentifierService(_clock); _deviceService = new DeviceService(_dbContext, _mqttIdentifierService); _valueService = new SensorValueService(_dbContext); _service = new MqttMessageIngestionService(_deviceService, _mqttIdentifierService, _brokerService, _valueService, new NullLogger <MqttMessageIngestionService>()); }