public void TestMalformedMessage() { // Arrange List <byte> payload = new List <byte>() { 0x03, 0xA0, 0x43, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; // Act Action action = () => _decoder.Decode(payload, new List <PidMap>() { new PidMap(0x4, 242) }); // Assert OpenThingsException exception = Assert.Throws <OpenThingsException>(action); Assert.Equal("Invalid OpenThings Header length [3]", exception.Message); }
public void TestMessageInvalidBufferLenght() { // Arrange List <byte> payload = new List <byte>() { 0x00 }; // Act Action action = () => _decoder.Decode(payload, new List <PidMap>() { new PidMap(0x4, 242) }); // Assert OpenThingsException exception = Assert.Throws <OpenThingsException>(action); Assert.Equal("Invalid buffer length [1] too short", exception.Message); }