Esempio n. 1
0
        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());
            }
        }
Esempio n. 2
0
        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));
            }
        }
Esempio n. 3
0
        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));
            }
        }
Esempio n. 4
0
        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());
            }
        }
Esempio n. 5
0
        public void Can_disable_sensor_reading()
        {
            using (var scenario = new SerialPortScenario())
            {
                scenario.SetupSendStandardCommandReceiveAck(0x44, 0x0D);

                var test = buildObjectForTest(scenario.Playback());
                Assert.IsTrue(test.DisableSensorReading());
            }
        }
Esempio n. 6
0
        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());
            }
        }
Esempio n. 7
0
        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());
            }
        }
Esempio n. 8
0
        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());
            }
        }
Esempio n. 10
0
        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());
            }
        }
Esempio n. 13
0
        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));
            }
        }
Esempio n. 14
0
        public void Can_program()
        {
            using (var scenario = new SerialPortScenario())
            {
                scenario.SetupSendStandardCommandReceiveAck(0x60, 0x03);

                var test = buildObjectForTest(scenario.Playback());
                Assert.IsTrue(test.Program());
            }
        }
Esempio n. 15
0
        public void Can_dim_light()
        {
            using (var scenario = new SerialPortScenario())
            {
                scenario.SetupSendStandardCommandReceiveAck(0x16, 0x00);

                var test = buildObjectForTest(scenario.Playback());
                Assert.IsTrue(test.DimOneStep());
            }
        }
Esempio n. 16
0
        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_program()
        {
            using (var scenario = new SerialPortScenario())
            {
                scenario.SetupSendStandardCommandReceiveAck(0x60, 0x03);

                var test = buildObjectForTest(scenario.Playback());
                Assert.IsTrue(test.Program());
            }
        }
Esempio n. 18
0
        public void Can_turn_off_light()
        {
            using (var scenario = new SerialPortScenario())
            {
                scenario.SetupSendStandardCommandReceiveAck(0x14, 0x00);

                var test = buildObjectForTest(scenario.Playback());
                Assert.IsTrue(test.TurnOff());
            }
        }
Esempio n. 19
0
        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));
            }
        }
Esempio n. 20
0
        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));
            }
        }
Esempio n. 21
0
        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));
            }
        }
Esempio n. 22
0
        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());
            }
        }
Esempio n. 23
0
        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));
            }
        }
Esempio n. 24
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());
            }
        }
Esempio n. 25
0
        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_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_pump_on_V8()
        {
            using (var scenario = new SerialPortScenario())
            {
                scenario.SetupSendStandardCommandReceiveAck(0x44, 0x08);

                var test = buildObjectForTest(scenario.Playback());
                Assert.IsTrue(test.DisablePumpOnV8());
            }
        }
        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());
            }
        }
Esempio n. 29
0
        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_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));
            }
        }
Esempio n. 31
0
        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);
            }
        }
Esempio n. 36
0
        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);
            }
        }
Esempio n. 37
0
        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);
            }
        }
Esempio n. 38
0
        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_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);
            }
        }
Esempio n. 40
0
        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);
            }
        }
Esempio n. 42
0
        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);
            }
        }
Esempio n. 43
0
        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);
            }
        }
Esempio n. 44
0
        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_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_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_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_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_skip_forward()
        {
            using (var scenario = new SerialPortScenario())
            {
                scenario.SetupSendStandardCommandReceiveAck(0x44, 0x05);

                var test = buildObjectForTest(scenario.Playback());
                Assert.IsTrue(test.SkipForward());
            }
        }
        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_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_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_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));
            }
        }
        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);
            }
        }