Beispiel #1
0
        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
            };
        }
Beispiel #2
0
        } = 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 TasmotaServiceTests()
        {
            MqttConfiguration = new MqttConfiguration()
            {
                Host     = "192.168.66.200",
                Port     = 64220,
                Username = "******",
                Password = "******"
            };

            var configuration = new TasmotaConfiguration()
            {
                Subnet = IPAddress.Parse("192.168.66.0"),
            };

            var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole());

            Network = new MockNetwork(configuration.Subnet, 30, MqttConfiguration);
            Service = new TasmotaService(Options.Create(configuration), loggerFactory.CreateLogger <TasmotaService>(), new MockTasmotaClient(Network));
        }