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); } }
public void GetDevice(int deviceId) { using (ITelldusCoreService service = new TelldusCoreService()) { service.Initialize(); Device device = service.GetDevice(deviceId); TestDevice(device); } }
public void Learn() { using (ITelldusCoreService service = new TelldusCoreService()) { service.Initialize(); ResultCode result = service.Learn(2); Assert.Equal(ResultCode.Success, result); } }
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); } }
public void GetAllDevices() { using (ITelldusCoreService service = new TelldusCoreService()) { service.Initialize(); var devices = service.GetDevices(); Assert.NotEmpty(devices); foreach (var device in devices) { TestDevice(device); } } }
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); } }
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); } } } }