public void Given_TurnOnAndOffDevice_CheckDeviceStatus() { var firstSwitchDevice = _deviceFactory.GetDevices().devices.FirstOrDefault(s => s.template == "switch"); Assert.IsNotNull(firstSwitchDevice); var firstSwitchDeviceVariablesBeforeTurnOn = _variableFactory.GetVariables().variables.FirstOrDefault(s => s.name == firstSwitchDevice.id + ".state"); Assert.IsNotNull(firstSwitchDeviceVariablesBeforeTurnOn); _deviceFactory.TurnOffDevice(firstSwitchDevice.id); _deviceFactory.TurnOnDevice(firstSwitchDevice.id); var firstSwitchDeviceVariablesAfterTurnOn = _variableFactory.GetVariables().variables.FirstOrDefault(s => s.name == "dev_switch1.state"); Assert.IsNotNull(firstSwitchDeviceVariablesAfterTurnOn); Assert.IsTrue(Convert.ToBoolean(firstSwitchDeviceVariablesAfterTurnOn.value)); if (!Convert.ToBoolean(firstSwitchDeviceVariablesBeforeTurnOn.value)) { _deviceFactory.TurnOffDevice(firstSwitchDevice.id); } }