public void HubAttachedIOEncoder_Decode_Attached <T>(string messageAsString, DeviceType expectedType, byte expectedPortId, string expectedHwVersion, string expectedSwVersion) { // arrange var data = BytesStringUtil.StringToData(messageAsString).AsSpan().Slice(3); // act var message = new HubAttachedIOEncoder().Decode(0x00, data) as HubAttachedIOForAttachedDeviceMessage; // assert Assert.Equal(expectedPortId, message.PortId); Assert.Equal(expectedType, message.IOTypeId); Assert.Equal(new Version(expectedHwVersion), message.HardwareRevision); Assert.Equal(new Version(expectedSwVersion), message.SoftwareRevision); // reverse test var reverseMessage = new HubAttachedIOForAttachedDeviceMessage() { Event = HubAttachedIOEvent.AttachedIO, IOTypeId = expectedType, PortId = expectedPortId, HardwareRevision = Version.Parse(expectedHwVersion), SoftwareRevision = Version.Parse(expectedSwVersion), }; // act var reverseData = MessageEncoder.Encode(reverseMessage, null); var reverseDataAsString = BytesStringUtil.DataToString(reverseData); Assert.Equal(messageAsString, reverseDataAsString); }
public void HubAttachedIOEncoder_Decode_AttachedVirutalIO(string messageAsString, DeviceType expectedType, byte expectedPortId, byte portA, byte portB) { // arrange var data = BytesStringUtil.StringToData(messageAsString).AsSpan().Slice(3); // act var message = new HubAttachedIOEncoder().Decode(0x00, data) as HubAttachedIOForAttachedVirtualDeviceMessage; // assert Assert.Equal(expectedPortId, message.PortId); Assert.Equal(expectedType, message.IOTypeId); Assert.Equal(portA, message.PortAId); Assert.Equal(portB, message.PortBId); }