Пример #1
0
        public void Test_FromUInt16_NoNboSpecified(ushort value, int offset, byte[] expected)
        {
            var converter = new DefaultConverter();
            var actual    = new byte[8];

            converter.FromUInt16(value, actual, offset);

            Assert.Equal(expected, actual);
        }
Пример #2
0
        public void Test_FromUInt16(ushort value, int offset, bool useNbo, byte[] expected)
        {
            var converter = new DefaultConverter();
            var actual    = new byte[8];

            converter.FromUInt16(value, ref actual, offset, useNbo);

            Assert.Equal(expected, actual);
        }
Пример #3
0
        public void Test_FromUInt16()
        {
            var converter = new DefaultConverter();
            var actual    = new byte[8];

            converter.FromUInt16(5, actual, 2);
            var expected = new byte[] { 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00 };

            Assert.AreEqual(expected, actual);
        }
        public void Create_Header_and_get_server_duration_from_framing_extras(ushort encoded, long?decoded)
        {
            // first four bits is 0 (type: server duration), last four bits is 2 (length)
            const byte frameInfo = 1 << 1;

            var converter = new DefaultConverter();
            var bytes     = new byte[27];

            converter.FromByte((byte)Magic.AltResponse, bytes, HeaderIndexFor.Magic);
            converter.FromByte(3, bytes, HeaderIndexFor.FramingExtras);
            converter.FromByte(frameInfo, bytes, 24);
            converter.FromUInt16(encoded, bytes, 25);

            var header = bytes.CreateHeader();

            Assert.IsNotNull(header);
            Assert.AreEqual(3, header.FramingExtrasLength);

            var serverDuration = header.GetServerDuration(bytes);

            Assert.AreEqual(decoded, serverDuration);
        }