示例#1
0
        public ValueInfo ReadValueInfo(byte formatByte, Stream stream)
        {
            if ((formatByte & 0x80) == 0)
            {
                return(ValueInfo.TypeOnlyValue);
            }
            if ((formatByte & 0xe0) == 0xe0)
            {
                return(ValueInfo.TypeOnlyValue);
            }

            switch (formatByte)
            {
            case 0xd0:
                return(ValueInfo.ForHeaderlessContent(1));

            case 0xd1:
                return(ValueInfo.ForHeaderlessContent(2));

            case 0xd2:
                return(ValueInfo.ForHeaderlessContent(4));

            case 0xd3:
                return(ValueInfo.ForHeaderlessContent(8));

            default:
                throw Exceptions.FormatByteNotSupported(formatByte);
            }
        }
        public void GetValue_ForFixString_WithLengthZero_ReturnsEmptyString()
        {
            var info = ValueInfo.ForHeaderlessContent(0);

            var actual = Format.GetValue(FixStringWithZeroLength, info, null);

            Assert.That(actual, Is.EqualTo(""));
        }
        public void GetValue_ForFixString_ThatIsLong_ReturnsExpectedValue()
        {
            const byte formatByte = 0xb5;
            var        info       = ValueInfo.ForHeaderlessContent(TestBytes.Length);

            var actual = Format.GetValue(formatByte, info, TestBytes);

            Assert.That(actual, Is.EqualTo(TestText));
        }
        public void GetValue_ForFixString_ThatIsShort_ReturnsExpectedValue()
        {
            const byte formatByte = 0xa2;
            var        info       = ValueInfo.ForHeaderlessContent(2);

            var actual = Format.GetValue(formatByte, info, ShortFixStrBytes);

            Assert.That(actual, Is.EqualTo(ShortFixStrText));
        }
示例#5
0
        public ValueInfo ReadValueInfo(byte formatByte, Stream stream)
        {
            switch (formatByte)
            {
            case 0xca:
                return(ValueInfo.ForHeaderlessContent(4));

            case 0xcb:
                return(ValueInfo.ForHeaderlessContent(8));

            default:
                throw Exceptions.FormatByteNotSupported(formatByte);
            }
        }
示例#6
0
        public ValueInfo ReadValueInfo(byte formatByte, Stream stream)
        {
            if ((formatByte & 0xe0) == 0xa0)
            {
                return(ValueInfo.ForHeaderlessContent(formatByte & 0x1f));
            }

            switch (formatByte)
            {
            case 0xd9:
                return(GetValueInfo(stream, 1));

            case 0xda:
                return(GetValueInfo(stream, 2));

            case 0xdb:
                return(GetValueInfo(stream, 4));

            default:
                throw Exceptions.FormatByteNotSupported(formatByte);
            }
        }