public void CanItemHeaderGetRawHeaderData(SecsFormat expectedSecsFormat, int expectedItemLength, byte expectedNumberOfLengthBytes, byte expectedRawHeaderDataSize)
        {
            ItemHeader itemHeader = new ItemHeader(expectedSecsFormat, expectedItemLength);

            byte[] expectedRawHeaderData = new byte[expectedRawHeaderDataSize];
            expectedRawHeaderData[0] = (byte)((int)expectedSecsFormat | expectedNumberOfLengthBytes);

            switch (expectedNumberOfLengthBytes)
            {
            case 1:
                expectedRawHeaderData[1] = (byte)expectedItemLength;
                break;

            case 2:
                expectedRawHeaderData[1] = (byte)(expectedItemLength >> 8);
                expectedRawHeaderData[2] = (byte)expectedItemLength;
                break;

            case 3:
                expectedRawHeaderData[1] = (byte)(expectedItemLength >> 16);
                expectedRawHeaderData[2] = (byte)(expectedItemLength >> 8);
                expectedRawHeaderData[3] = (byte)expectedItemLength;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(expectedNumberOfLengthBytes), expectedNumberOfLengthBytes, "The argument must be 1, 2 or 3.");
            }

            byte[] actualRawHeaderData = itemHeader.GetRawHeaderData();
            CollectionAssert.AreEqual(expectedRawHeaderData, actualRawHeaderData);
        }
        public void CanItemHeaderBeConstructed(SecsFormat expectedSecsFormat, int expectedItemLength, byte expectedNumberOfLengthBytes, byte expectedRawHeaderDataSize)
        {
            ItemHeader itemHeader = new ItemHeader(expectedSecsFormat, expectedItemLength);

            Assert.IsTrue(itemHeader.IsValid, nameof(itemHeader.IsValid));
            Assert.AreEqual(expectedSecsFormat, itemHeader.Format, nameof(itemHeader.Format));
            Assert.AreEqual(expectedItemLength, itemHeader.ItemLength, nameof(itemHeader.ItemLength));
            Assert.AreEqual(expectedNumberOfLengthBytes, itemHeader.NumberOfLengthBytes, nameof(itemHeader.NumberOfLengthBytes));
            Assert.AreEqual(expectedRawHeaderDataSize, itemHeader.RawHeaderDataSize, nameof(itemHeader.RawHeaderDataSize));

            byte[] expectedRawHeaderData = new byte[expectedRawHeaderDataSize];
            expectedRawHeaderData[0] = (byte)((int)expectedSecsFormat | expectedNumberOfLengthBytes);

            switch (expectedNumberOfLengthBytes)
            {
            case 1:
                expectedRawHeaderData[1] = (byte)expectedItemLength;
                break;

            case 2:
                expectedRawHeaderData[1] = (byte)(expectedItemLength >> 8);
                expectedRawHeaderData[2] = (byte)expectedItemLength;
                break;

            case 3:
                expectedRawHeaderData[1] = (byte)(expectedItemLength >> 16);
                expectedRawHeaderData[2] = (byte)(expectedItemLength >> 8);
                expectedRawHeaderData[3] = (byte)expectedItemLength;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(expectedNumberOfLengthBytes), expectedNumberOfLengthBytes, "The argument must be 1, 2 or 3.");
            }

            byte[] actualRawHeaderData = itemHeader.GetRawHeaderData();
            CollectionAssert.AreEqual(expectedRawHeaderData, actualRawHeaderData);

            byte[] expectedItemBufferWithRawHeaderData = new byte[expectedRawHeaderDataSize + expectedItemLength];
            Array.Copy(expectedRawHeaderData, 0, expectedItemBufferWithRawHeaderData, 0, expectedRawHeaderData.Length);

            var(actualItemBufferWithRawHeaderData, actualOffset) = itemHeader.GetItemBufferWithRawHeaderData();
            Assert.AreEqual(expectedRawHeaderDataSize, actualOffset, nameof(actualOffset));
            CollectionAssert.AreEqual(expectedItemBufferWithRawHeaderData, actualItemBufferWithRawHeaderData);
        }