Esempio n. 1
0
        public void AddAndRemoveDevice()
        {
            using (ITelldusCoreService service = new TelldusCoreService())
            {
                service.Initialize();

                string name     = "Device from xUnit";
                string protocol = "arctech";
                string model    = "selflearning-switch";
                Dictionary <string, string> parameters = new Dictionary <string, string> {
                    { "house", "1" }
                };

                int deviceId = service.AddDevice(name, protocol, model, parameters);
                Assert.True(deviceId > 0);

                Device device = service.GetDevice(deviceId);
                TestDevice(device);

                bool result = service.RemoveDevice(deviceId);
                Assert.True(result);

                Device deviceAfterDeletion = service.GetDevice(deviceId);
                Assert.Null(deviceAfterDeletion);
            }
        }
Esempio n. 2
0
        public void GetDevice(int deviceId)
        {
            using (ITelldusCoreService service = new TelldusCoreService())
            {
                service.Initialize();

                Device device = service.GetDevice(deviceId);
                TestDevice(device);
            }
        }
Esempio n. 3
0
        public void Learn()
        {
            using (ITelldusCoreService service = new TelldusCoreService())
            {
                service.Initialize();

                ResultCode result = service.Learn(2);
                Assert.Equal(ResultCode.Success, result);
            }
        }
Esempio n. 4
0
        public void SendCommand(int deviceId, DeviceMethods command)
        {
            using (ITelldusCoreService service = new TelldusCoreService())
            {
                service.Initialize();

                ResultCode result = service.SendCommand(deviceId, command);
                Assert.Equal(ResultCode.Success, result);
            }
        }
Esempio n. 5
0
        public void GetAllDevices()
        {
            using (ITelldusCoreService service = new TelldusCoreService())
            {
                service.Initialize();

                var devices = service.GetDevices();

                Assert.NotEmpty(devices);

                foreach (var device in devices)
                {
                    TestDevice(device);
                }
            }
        }
Esempio n. 6
0
        public void SensorUpdated_ReceivesEvent()
        {
            using (ITelldusCoreService service = new TelldusCoreService())
            {
                service.Initialize();

                ManualResetEvent resetEvent = new ManualResetEvent(false);

                service.SensorUpdated += (s, eventArgs) =>
                {
                    Assert.NotNull(eventArgs.Value);

                    resetEvent.Set();
                };

                bool result = resetEvent.WaitOne(WAIT_TIME);

                Assert.True(result);
            }
        }
Esempio n. 7
0
        public void GetAllSensorsWithValues()
        {
            using (ITelldusCoreService service = new TelldusCoreService())
            {
                service.Initialize();

                var sensors = service.GetSensors();
                Assert.NotEmpty(sensors);

                foreach (var sensor in sensors)
                {
                    TestSensor(sensor);

                    var values = service.GetSensorValues(sensor);
                    Assert.NotEmpty(values);

                    foreach (var value in values)
                    {
                        TestSensorValue(value);
                    }
                }
            }
        }