public void BytesToDouble(byte[] input, double expected) { var final = new byte[10]; Array.Copy(input, 0, final, 3, input.Length); var result = Dpt9.BytesToDouble(new ArraySegment <byte>(final, 3, 2)); Assert.Equal(expected, result, 3); }
public void Too_much_data_throws() { Assert.Throws <ArgumentException>(() => Dpt9.BytesToDouble(new ArraySegment <byte>(new byte[] { 0x7f, 0xff, 0x44, 0x33 }, 1, 3))); }
public void Not_enough_data_throws() { Assert.Throws <ArgumentException>(() => Dpt9.BytesToDouble(new ArraySegment <byte>(new byte[] { 0x7f, 0xff }, 1, 1))); }
public void Throws_when_input_float_is_too_big2() { byte[] outBytes = new byte[10]; Assert.Throws <ArgumentOutOfRangeException>(() => Dpt9.DoubleToBytes(1000000000d, outBytes, 0)); }
public void Throws_when_not_enough_space_in_array2() { byte[] outBytes = new byte[1]; Assert.Throws <ArgumentException>(() => Dpt9.DoubleToBytes(0d, outBytes, 0)); }
public void DoubleToBytes(byte[] input, double expected) { byte[] outBytes = new byte[5]; Dpt9.DoubleToBytes(expected, outBytes, 3); Assert.Equal(input, outBytes.Skip(3).ToArray()); }