public void BytesToCelsius(byte[] input, Measure <Celsius> expected) { var final = new byte[10]; Array.Copy(input, 0, final, 3, input.Length); var result = Dpt9001.BytesToCelsius(new ArraySegment <byte>(final, 3, 2)); Assert.Equal(expected, result); }
private IMessagePayload CreateBusMessage(KnxAddressBindingTypes bindingType, CemiFrame cemiFrame) { switch (bindingType) { case KnxAddressBindingTypes.Switch: bool onOff = (cemiFrame.Apdu & 1) == 1; return(new SwitchMessage(onOff)); case KnxAddressBindingTypes.Temperature: return(new TemperatureMessage(Dpt9001.BytesToCelsius(new ArraySegment <byte>(cemiFrame.Data.Array, cemiFrame.Data.Offset, cemiFrame.Data.Count)))); break; default: throw new ArgumentOutOfRangeException(nameof(bindingType), bindingType, null); } }
public void Degree_celsius_above_670760_throws() { Assert.Throws <ArgumentOutOfRangeException>(() => Dpt9001.BytesToCelsius(new ArraySegment <byte>(new byte[] { 0x7f, 0xff }, 0, 2))); }
public void Degree_celsius_below_273_throws() { Assert.Throws <ArgumentOutOfRangeException>(() => Dpt9001.BytesToCelsius(new ArraySegment <byte>(new byte[] { 0xf8, 0x02 }, 0, 2))); }