public void ShouldThrowExceptionIfDataIndexIsOutOfRange()
        {
            var converter = new Int32ArrayConverter();

            var action = new Action(() => converter.ConvertBack(new byte[] { 0x01, 0x02, 0x03 }, 1));

            action.Should().Throw <ArgumentException>();
        }
        public void ShouldReturnDataValueAndNextDataIndex()
        {
            var converter = new Int32ArrayConverter();

            var(dataValue, nextDataIndex) = converter.ConvertBack(new byte[] { 0xDD, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00 }, 1);

            var ints = (int[])dataValue;

            ints[0].Should().Be(0x00000001);
            ints[1].Should().Be(0x00000002);
            nextDataIndex.Should().Be(0x0B);
        }
示例#3
0
        public void ShouldReturnByteArray()
        {
            var converter = new Int32ArrayConverter();

            int[] data = { 0x11223344, 0x0A223344 };

            var bytes = converter.Convert(data).ToArray();

            bytes.Should().HaveCount(0x0A);
            bytes[0].Should().Be(0x02);
            bytes[1].Should().Be(0x00);
            bytes[2].Should().Be(0x44);
            bytes[3].Should().Be(0x33);
            bytes[4].Should().Be(0x22);
            bytes[5].Should().Be(0x11);
            bytes[6].Should().Be(0x44);
            bytes[7].Should().Be(0x33);
            bytes[8].Should().Be(0x22);
            bytes[9].Should().Be(0x0A);
        }