Пример #1
0
        public void ReadRgbQuadInvalidSize()
        {
            // Well formed data
            byte[] streamData =
            {
                // Blue
                1,
                // Green
                2,
                // Red
                3,
                // Reserved
                0
            };

            // The streamData is well formed.
            // Just using a part of the data should cause an error to rise.

            for (int dataSize = 0; dataSize < streamData.Length - 1; dataSize++)
            {
                byte[] streamDataTooShort = new byte[dataSize];
                Array.Copy(streamData, 0, streamDataTooShort, 0, dataSize);

                WangStream stream     = new WangStream(streamDataTooShort);
                byte[]     components = new byte[3];
                Assert.IsFalse(WangAnnotationStructureReader.ReadRgbQuad(components, stream));
            }
        }
Пример #2
0
        public void ReadRgbQuadStd()
        {
            // Well formed data
            byte[] streamData =
            {
                // Blue
                1,
                // Green
                2,
                // Red
                3,
                // Reserved
                0
            };

            WangStream stream = new WangStream(streamData);

            byte[] components = new byte[3];
            Assert.IsTrue(WangAnnotationStructureReader.ReadRgbQuad(components, stream));

            Assert.AreEqual(1, components[WangAnnotationTranslation.BlueIndex]);
            Assert.AreEqual(2, components[WangAnnotationTranslation.GreenIndex]);
            Assert.AreEqual(3, components[WangAnnotationTranslation.RedIndex]);
            Assert.AreEqual(0, stream.AvailableBytes());
        }