private static void testPing(bool pingResponse) { using (var scenario = new SerialPortScenario()) { const byte SEND_MESSAGE_FLAGS = Constants.MSG_FLAGS_DIRECT | Constants.MSG_FLAGS_MAX_HOPS; const byte RECV_MESSAGE_FLAGS_ACK = Constants.MSG_FLAGS_DIRECT_ACK; byte[] peerResponse = new byte[] { 0x02, 0x50, PEER_ID_HI, PEER_ID_MI, PEER_ID_LO, PLM_ID_HI, PLM_ID_MI, PLM_ID_LO, RECV_MESSAGE_FLAGS_ACK, 0x0F, 0x00 }; scenario .ShouldSend(0x02, 0x62, PEER_ID_HI, PEER_ID_MI, PEER_ID_LO, SEND_MESSAGE_FLAGS, 0x0F, 0x00) .AndReceive(0x02, 0x62, PEER_ID_HI, PEER_ID_MI, PEER_ID_LO, SEND_MESSAGE_FLAGS, 0x0F, 0x00, 0x06); if (pingResponse) { scenario .WaitsForMessageOfType(0x50) .AndReceives(peerResponse); } else { scenario .WaitsForMessageOfType(0x50) .AndReceives(); } var test = buildObjectForTest(scenario.Playback()); Assert.AreEqual(pingResponse, test.Ping()); } }
public void Can_turn_off_sprinkler_program() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x43, 0x09); // program 9 off var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.TurnOffSprinklerProgram(9)); } }
public void Can_turn_off_sprinkler_valve() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x41, 0x05); // valve 5 off var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.TurnOffSprinklerValve(5)); } }
public void Can_take_device_out_of_self_diagnostics_mode() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x44, 0x0F); var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.DiagnosticsOff()); } }
public void Can_disable_sensor_reading() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x44, 0x0D); var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.DisableSensorReading()); } }
public void Can_disable_device_status_changed_broadcast() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x44, 0x0A); var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.DisableDeviceStatusChangedBroadcast()); } }
public void Can_disable_pump_on_V8() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x44, 0x08); var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.DisablePumpOnV8()); } }
public void Can_skip_back() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x44, 0x06); var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.SkipBack()); } }
public void Can_turn_on_light() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x12, 0xFF); var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.TurnOn()); } }
public void Can_move_to_position() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x61, 0x80); // half-way-open var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.MoveToPosition(0x80)); } }
public void Can_manually_dim_light() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x17, 0x00); var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.BeginDimming()); } }
public void Can_brighten_light() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x15, 0x00); var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.BrightenOneStep()); } }
public void Can_write_output_port() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x48, 0xAF); var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.WriteByteToOutputPort(0xAF)); } }
public void Can_program() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x60, 0x03); var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.Program()); } }
public void Can_dim_light() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x16, 0x00); var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.DimOneStep()); } }
public void Can_load_eeprom_from_ram() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x54, 0x01); var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.LoadEepromFromRam()); } }
public void Can_turn_off_light() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x14, 0x00); var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.TurnOff()); } }
public void Can_lower_temperature_setting() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x53, 0x04); var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.LowerTemperatureSettingBy(0x04)); } }
public void Can_turn_on_to_level() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x12, 0x80); var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.TurnOn(0x80)); } }
public void Can_ramp_on_light() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x11, 0x70); var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.RampOn(0x70)); } }
public void Can_stop_manually_brightening_or_dimming_light() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x18, 0x00); var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.StopBrighteningOrDimming()); } }
public void Can_turn_off_io_output() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x46, 0x00); // output 0 off var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.TurnOffOutput(0)); } }
public void Can_manually_brighten_light() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x17, 0x01); var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.BeginBrightening()); } }
private static void testTurnOffPoolAndSpaDevice(byte deviceCode, PoolAndSpaDevice device) { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x51, deviceCode); var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.TurnOffDevice(device)); } }
public void Can_enable_device_status_changed_broadcast() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x44, 0x09); var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.EnableDeviceStatusChangedBroadcast()); } }
public void Can_resume_command_acceptance() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x44, 0x04); var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.ResumeCommandAcceptance()); } }
public void Can_load_initialization_values() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x54, 0x00); var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.LoadInitializationValues()); } }
public void Can_turn_on_io_output() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x45, 0x02); // output 2 on var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.TurnOnOutput(2)); } }
public void Can_get_on_level() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x19, 0x00, 0x11, 0x55); var test = buildObjectForTest(scenario.Playback()); byte onLevel; Assert.IsTrue(test.TryGetOnLevel(out onLevel)); Assert.AreEqual(0x55, onLevel); } }
public void Can_get_pH() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x54, 0x05, 0x54, 0x55); var test = buildObjectForTest(scenario.Playback()); byte pH; Assert.IsTrue(test.TryGetPH(out pH)); Assert.AreEqual(0x55, pH); } }
public void Can_get_ambient_temperature() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x54, 0x03, 0x54, 0x05); var test = buildObjectForTest(scenario.Playback()); byte ambientTemperature; Assert.IsTrue(test.TryGetAmbientTemperature(out ambientTemperature)); Assert.AreEqual(0x05, ambientTemperature); } }
public void Can_get_input_port_values() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x49, 0x00, 0x49, 0xAB); // response with input status in command 2 var test = buildObjectForTest(scenario.Playback()); byte inputPortValue; Assert.IsTrue(test.TryGetInputPort(out inputPortValue)); Assert.AreEqual(0xAB, inputPortValue); } }
public void Can_get_water_temperature() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x54, 0x04, 0x54, 0x18); var test = buildObjectForTest(scenario.Playback()); byte waterTemperature; Assert.IsTrue(test.TryGetWaterTemperature(out waterTemperature)); Assert.AreEqual(0x18, waterTemperature); } }
public void Can_get_sensor_value() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x4A, 0x03, 0x4A, 0xAB); // get sensor value 3 var test = buildObjectForTest(scenario.Playback()); byte sensorValue; Assert.IsTrue(test.TryGetSensorValue(3, out sensorValue)); Assert.AreEqual(0xAB, sensorValue); } }
public void Can_get_valve_status() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x44, 0x02, 0x44, 0xAB); // response with valve status in command 2 var test = buildObjectForTest(scenario.Playback()); byte valveStatus; Assert.IsTrue(test.TryGetValveStatus(out valveStatus)); Assert.AreEqual(0xAB, valveStatus); } }
public void Can_get_thermostat_mode() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x54, 0x02, 0x54, 0x01); // response with thermostat in spa mode var test = buildObjectForTest(scenario.Playback()); PoolAndSpaThermostatMode thermostatMode; Assert.IsTrue(test.TryGetThermostatMode(out thermostatMode)); Assert.AreEqual(PoolAndSpaThermostatMode.Spa, thermostatMode); } using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x54, 0x02, 0x54, 0x00); // response with thermostat in pool mode var test = buildObjectForTest(scenario.Playback()); PoolAndSpaThermostatMode thermostatMode; Assert.IsTrue(test.TryGetThermostatMode(out thermostatMode)); Assert.AreEqual(PoolAndSpaThermostatMode.Pool, thermostatMode); } }
public void Can_ramp_off_light() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x13, 0x00); var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.RampOff()); } }
public void Can_raise_temperature_setting() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x52, 0x03); var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.RaiseTemperatureSettingBy(0x03)); } }
public void Can_turn_on_device() { testTurnOnPoolAndSpaDevice(0x01, PoolAndSpaDevice.Pool); testTurnOnPoolAndSpaDevice(0x02, PoolAndSpaDevice.Spa); testTurnOnPoolAndSpaDevice(0x03, PoolAndSpaDevice.Heat); testTurnOnPoolAndSpaDevice(0x04, PoolAndSpaDevice.Pump); // test invalid input using (var scenario = new SerialPortScenario()) { var test = buildObjectForTest(scenario.Playback()); Assert.Throws<ArgumentOutOfRangeException>(() => test.TurnOnDevice(PoolAndSpaDevice.All)); } }
private static void testTurnOnPoolAndSpaDevice(byte deviceCode) { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x50, deviceCode); var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.TurnOnDevice(deviceCode)); } }
public void Can_turn_on_sprinkler_valve() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x40, 0x03); // valve 3 on var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.TurnOnSprinklerValve(3)); } }
public void Can_turn_on_sprinkler_program() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x42, 0x07); // program 7 on var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.TurnOnSprinklerProgram(7)); } }
public void Can_skip_forward() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x44, 0x05); var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.SkipForward()); } }
public void Can_load_ram_from_eeprom() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x44, 0x0B); var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.LoadRamFromEeprom()); } }
public void Can_load_initialization_values() { using (var scenario = new SerialPortScenario()) { scenario.SetupSendStandardCommandReceiveAck(0x44, 0x00); var test = buildObjectForTest(scenario.Playback()); Assert.IsTrue(test.LoadInitializationValues()); } }
public void Can_turn_on_device_by_number() { for (int i = 1; i <= 255; i++) { testTurnOnPoolAndSpaDevice((byte)i); } // test invalid input using (var scenario = new SerialPortScenario()) { var test = buildObjectForTest(scenario.Playback()); Assert.Throws<ArgumentOutOfRangeException>(() => test.TurnOnDevice((byte)0)); } }