Пример #1
0
        public void UInt16Test()
        {
            UInt16 expected = 0x1234;

            byte[] bytes  = Bigendian.GetBigendianBytes(expected);
            UInt16 actual = Bigendian.BigendianToUInt16(bytes, 0);

            Assert.AreEqual(expected, actual);
        }
Пример #2
0
        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);
        }
Пример #3
0
        public void UInt32Test()
        {
            UInt32 expected = 0x12345678;

            byte[] bytes  = Bigendian.GetBigendianBytes(expected);
            UInt32 actual = Bigendian.BigendianToUInt32(bytes, 0);

            Assert.AreEqual(expected, actual);
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
        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);
        }
Пример #7
0
 public void GetBigendianBytesTest()
 {
     byte[] expected = new byte[] { 0x22, 0x11 };
     byte[] actual   = Bigendian.GetBigendianBytes(0x2211);
     Helpers.AreArrayEqual(expected, actual);
 }