public MasterServiceTests() { MqttConfiguration = new MqttConfiguration() { Host = "192.168.66.200", Port = 64220, Username = "******", Password = "******" }; var configuration = new TasmotaConfiguration() { Subnet = IPAddress.Parse("192.168.66.0"), }; Network = new MockNetwork(configuration.Subnet, 30, MqttConfiguration); var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole()); var tasmotaClient = new MockTasmotaClient(Network); var mongoClient = new MongoClient("mongodb://localhost"); Database = mongoClient.GetDatabase("tasmocc-test"); DeviceRepository = new DeviceRepository(Database); var deviceConfigurationRepository = new DeviceConfigurationRepository(Database); TasmotaService = new TasmotaService(Options.Create(configuration), loggerFactory.CreateLogger <TasmotaService>(), tasmotaClient); MasterService = new MasterService(Options.Create(MqttConfiguration), loggerFactory.CreateLogger <MasterService>(), TasmotaService, DeviceRepository, deviceConfigurationRepository) { ScanNetworkOnStart = false }; }
} = true; // Set to false on tests public MasterService(IOptions <MqttConfiguration> mqttOptions, ILogger <MasterService> logger, TasmotaService tasmotaService, DeviceRepository deviceRepository, DeviceConfigurationRepository deviceConfigurationRepository) { _mqttOptions = mqttOptions.Value; _logger = logger; _tasmotaService = tasmotaService; _deviceRepository = deviceRepository; _deviceConfigurationRepository = deviceConfigurationRepository; }
public DatabaseMonitor(IOptions <TasmotaConfiguration> tasmotaOptions, ILogger <DatabaseMonitor> logger, DeviceRepository deviceRepository, DeviceConfigurationRepository deviceConfigurationRepository, TemplateRepository templateRepository, IHubContext <DevicesHub, IDevicesHubClient> hubContext, MasterService masterService) { _tasmotaOptions = tasmotaOptions; _logger = logger; _deviceRepository = deviceRepository; _deviceConfigurationRepository = deviceConfigurationRepository; _templateRepository = templateRepository; _hubContext = hubContext; _masterService = masterService; }
/// <summary> /// Inicializar router /// </summary> /// <param name="devices">Gestor de dispositivos</param> /// <param name="users">Gestor de usuarios</param> public void Init(DeviceManager devices, UserManager users) { m_configRepo = new DeviceConfigurationRepository(); m_deviceManager = devices; m_deviceManager.OnDeviceConnected += DeviceManager_OnDeviceConnected; m_deviceManager.OnDeviceDisconnected += DeviceManager_OnDeviceDisconnected; m_userManager = users; m_userManager.OnUserConnected += UserManager_OnUserConnected; m_userManager.OnUserDisconnected += UserManager_OnUserDisconnected; }
/// <summary> /// Inicializar servicio de datos de dispositivos /// </summary> public DevicesDataService() { m_configRepo = new DeviceConfigurationRepository(); m_transRepo = new DeviceTranslationRepository(); }