public void UInt16Test() { UInt16 expected = 0x1234; byte[] bytes = Bigendian.GetBigendianBytes(expected); UInt16 actual = Bigendian.BigendianToUInt16(bytes, 0); Assert.AreEqual(expected, actual); }
public override byte[] GetBytes(int extraLength) { byte[] bytes = base.GetBytes(extraLength); int offset = Size - sizeof(UInt32); AddBytes(bytes, ref offset, Bigendian.GetBigendianBytes(Flags)); return(bytes); }
public void UInt32Test() { UInt32 expected = 0x12345678; byte[] bytes = Bigendian.GetBigendianBytes(expected); UInt32 actual = Bigendian.BigendianToUInt32(bytes, 0); Assert.AreEqual(expected, actual); }
public void BigendianToUInt16Test() { byte[] bytes = new byte[] { 0x22, 0x11 }; int startIndex = 0; UInt16 actual = Bigendian.BigendianToUInt16(bytes, ref startIndex); Assert.AreEqual(2, startIndex); Assert.AreEqual(0x2211, actual); }
public void BigendianToUInt32Test() { byte[] bytes = new byte[] { 0x44, 0x33, 0x22, 0x11 }; int startIndex = 0; UInt32 expected = 0x44332211; UInt32 actual = Bigendian.BigendianToUInt32(bytes, ref startIndex); Assert.AreEqual(4, startIndex); Assert.AreEqual(expected, actual); }
public virtual byte[] GetBytes(int extraLength) { byte[] bytes = new byte[Size + extraLength]; int offset = 0; bytes[offset++] = MajorVersion; bytes[offset++] = MinorVersion; AddBytes(bytes, ref offset, Bigendian.GetBigendianBytes(Size)); AddBytes(bytes, ref offset, Bigendian.GetBigendianBytes(ExpiryTimeLow)); AddBytes(bytes, ref offset, Bigendian.GetBigendianBytes(ExpiryTimeHigh)); AddBytes(bytes, ref offset, ClientID); return(bytes); }
public void GetBigendianBytesTest() { byte[] expected = new byte[] { 0x22, 0x11 }; byte[] actual = Bigendian.GetBigendianBytes(0x2211); Helpers.AreArrayEqual(expected, actual); }