Exemplo n.º 1
0
        public void ReadBytesTest()
        {
            int bufferLength = 10;
            int chunkSize    = 2;

            byte[] input  = new byte[bufferLength];
            byte[] output = new byte[bufferLength];
            byte[] chunk  = new byte[chunkSize];

            for (int index = 0; index < bufferLength; index++)
            {
                input[index]  = (byte)(index + 10);
                output[index] = 0xff;
            }

            WangStream wangStream = new WangStream(input);
            int        read       = 0;

            while (wangStream.AvailableBytes() != 0)
            {
                Assert.IsFalse(wangStream.IsEnd());
                wangStream.ReadBytes(chunk, chunkSize);
                Array.Copy(chunk, 0, output, read, chunkSize);
                read += chunkSize;
            }

            Assert.IsTrue(wangStream.IsEnd());
            Assert.AreEqual(0, wangStream.AvailableBytes());
            Assert.AreEqual(bufferLength, output.Length);
            for (int index = 0; index < bufferLength; index++)
            {
                Assert.AreEqual(input[index], output[index]);
            }
        }
        public void ReadBlockOiAnText()
        {
            const int headerSize = 12;

            // Stream with a named block header and a display text
            byte[] streamData =
            {
                // Named block header
                79,  105,  65, 110, 84, 101, 120, 116,
                24,    0,   0,   0,
                // Display text
                0,     0,   0,   0,
                242,   2,   0,   0,
                104,   1,   0,   0,
                5,     0,   0,   0,
                72,  101, 108, 108,
                111,   0,   0,   0,
                // Extra bytes
                1,     2,   3, 4
            };

            WangAnnotationProperties properties = new WangAnnotationProperties();
            WangStream stream = new WangStream(streamData);

            Assert.IsTrue(WangAnnotationsReader.ReadBlock(properties, stream, headerSize));
            Assert.AreEqual(4, stream.AvailableBytes());
            Assert.AreEqual((uint)360, properties.DisplayText.CreationScale);
            Assert.AreEqual(0, properties.DisplayText.Orientation);
            Assert.AreEqual("Hello", properties.DisplayText.Text);
        }
Exemplo n.º 3
0
        public void ReadHyperlink()
        {
            // Well formed data
            byte[] streamData =
            {
                1,     0,   0,   0,
                14,    0,   0,   0,
                115, 111, 117, 114,
                99,  101,  92,  48,
                48,   49,  46, 106,
                112, 103,   1,   0,
                0,     0,  49,   0,
                0,     0,   0,   0,
                0,     0, 0
            };


            WangStream    stream    = new WangStream(streamData);
            WangHyperlink hyperlink = WangAnnotationStructureReader.ReadHyperlink(stream, streamData.Length);

            Assert.AreEqual(false, hyperlink.CanRemoveHyperlink);
            Assert.AreEqual(false, hyperlink.InternalLink);
            Assert.AreEqual("source\\001.jpg", hyperlink.Link);
            Assert.AreEqual("1", hyperlink.Location);
            Assert.AreEqual("", hyperlink.WorkingDirectory);
        }
Exemplo n.º 4
0
        public void ReadLogfontZeroSignificant()
        {
            // Well formed data with. Zero significant data and trailing stuff
            byte[] streamData =
            {
                0,  0,   0,  0,   0,   0,   0,  0,   0,   0,
                0,  0,   0,  0,   0,   0,   0,  0,   0,   0,
                0,  0,   0,  0,   0,   0,   0,  0,   0, 223,
                10, 0, 219, 49, 145, 124, 247, 49, 145, 124,
                8,  6,  12,  0, 136,   0, 126,  0,   0,   0,
                0,  0,   0,  0,   0, 0
            };

            WangStream  stream = new WangStream(streamData);
            WangLogFont read   = WangAnnotationStructureReader.ReadLogfont(stream);

            Assert.IsTrue(read != null);

            Assert.AreEqual(0, read.Height);
            Assert.AreEqual(0, read.Width);
            Assert.AreEqual(0, read.Escapement);
            Assert.AreEqual(0, read.Orientation);
            Assert.AreEqual(0, read.Weight);
            Assert.AreEqual(false, read.Italic);
            Assert.AreEqual(false, read.Underline);
            Assert.AreEqual(false, read.StrikeOut);
            Assert.AreEqual(0, read.CharSet);
            Assert.AreEqual(0, read.OutPrecision);
            Assert.AreEqual(0, read.ClipPrecision);
            Assert.AreEqual(0, read.Quality);
            Assert.AreEqual(0, read.PitchAndFamily);
            Assert.AreEqual("", read.FaceName);
        }
Exemplo n.º 5
0
        public void ReadHyperlink2()
        {
            // Well formed data
            byte[] streamData =
            {
                1,     0,   0,   0,
                22,    0,   0,   0,
                104, 116, 116, 112,
                58,   47,  47, 119,
                119, 119,  46, 111,
                114, 112,  97, 108,
                105, 115,  46,  99,
                111, 109,   0,   0,
                0,     0,   0,   0,
                0,     0,   0,   0,
                0, 0
            };


            WangStream    stream    = new WangStream(streamData);
            WangHyperlink hyperlink = WangAnnotationStructureReader.ReadHyperlink(stream, streamData.Length);

            Assert.AreEqual(false, hyperlink.CanRemoveHyperlink);
            Assert.AreEqual(false, hyperlink.InternalLink);
            Assert.AreEqual("http://www.orpalis.com", hyperlink.Link);
            Assert.AreEqual("", hyperlink.Location);
            Assert.AreEqual("", hyperlink.WorkingDirectory);
        }
Exemplo n.º 6
0
        public void ReadHyperlinkInvalidSize()
        {
            // Well formed data
            byte[] streamData =
            {
                1,   0, 0, 0,
                1,   0, 0, 0,
                104,
                1,   0, 0, 0,
                104,
                1,   0, 0, 0,
                104,
                0,   0, 0, 0
            };

            int[] dataSizes =
            {
                0, 4, 8, 9, 13, 14, 18, 19
            };

            foreach (var dataSize in dataSizes)
            {
                byte[] streamDataTooShort = new byte[dataSize];
                Array.Copy(streamData, streamDataTooShort, dataSize);
                WangStream    stream    = new WangStream(streamDataTooShort);
                WangHyperlink hyperlink = WangAnnotationStructureReader.ReadHyperlink(stream, dataSize);
                Assert.AreEqual(null, hyperlink);
            }
        }
Exemplo n.º 7
0
        public void ReadLogfontArialUnderline()
        {
            // Well formed data with
            byte[] streamData =
            {
                12,   0,   0, 0, 0, 0,   0, 0,  0,   0,
                0,    0,   0, 0, 0, 0, 144, 1,  0,   0,
                0,    1,   0, 0, 0, 0,   0, 0, 65, 114,
                105, 97, 108, 0, 0, 0,   0, 0,  0,   0,
                0,    0,   0, 0, 0, 0,   0, 0,  0,   0,
                0,    0,   0, 0, 0, 0
            };

            WangStream  stream = new WangStream(streamData);
            WangLogFont read   = WangAnnotationStructureReader.ReadLogfont(stream);

            Assert.IsTrue(read != null);

            Assert.AreEqual(12, read.Height);
            Assert.AreEqual(0, read.Width);
            Assert.AreEqual(0, read.Escapement);
            Assert.AreEqual(0, read.Orientation);
            Assert.AreEqual(400, read.Weight);
            Assert.AreEqual(false, read.Italic);
            Assert.AreEqual(true, read.Underline);
            Assert.AreEqual(false, read.StrikeOut);
            Assert.AreEqual(0, read.CharSet);
            Assert.AreEqual(0, read.OutPrecision);
            Assert.AreEqual(0, read.ClipPrecision);
            Assert.AreEqual(0, read.Quality);
            Assert.AreEqual(0, read.PitchAndFamily);
            Assert.AreEqual("Arial", read.FaceName);
        }
        public void ReadBlockOiDib()
        {
            const int headerSize = 12;

            // Stream with a named block header and some bytes for the dib
            byte[] streamData =
            {
                // Named block header
                79, 105, 68, 73, 66, 0, 0, 0, 4, 0, 0, 0,
                // Dummy dib
                0,    1,  2,  3,
                // Extra bytes
                1,    2,  3, 4
            };

            WangAnnotationProperties properties = new WangAnnotationProperties();
            WangStream stream = new WangStream(streamData);

            Assert.IsTrue(WangAnnotationsReader.ReadBlock(properties, stream, headerSize));
            Assert.AreEqual(4, stream.AvailableBytes());
            Assert.IsTrue(properties.HasDib);
            Assert.AreEqual(4, properties.DibInfo.Length);
            for (int index = 0; index < 4; index++)
            {
                Assert.AreEqual((byte)index, properties.DibInfo[index]);
            }
        }
        public void ReadBlockOiFilNam()
        {
            const int headerSize = 12;

            // Stream with a named block header and a file name
            byte[] streamData =
            {
                // Named block header
                79,  105,  70, 105, 108,  78,  97, 109,
                61,    0,   0,   0,
                // Character string for filename
                67,   58,  92,  68, 111,  99, 117,
                109, 101, 110, 116, 115,  32,  97,
                110, 100,  32,  83, 101, 116, 116,
                105, 110, 103, 115,  92,  65, 100,
                109, 105, 110,  92,  68, 101, 115,
                107, 116, 111, 112,  92,  87,  65,
                78,   71,  92, 115, 111, 117, 114,
                99,  101,  92,  48,  48,  49,  46,
                98,  109, 112,   0,   0,
                // Extra bytes
                1,     2,   3, 4
            };

            WangAnnotationProperties properties = new WangAnnotationProperties();
            WangStream stream = new WangStream(streamData);

            Assert.IsTrue(WangAnnotationsReader.ReadBlock(properties, stream, headerSize));
            Assert.AreEqual(4, stream.AvailableBytes());
            Assert.AreEqual("C:\\Documents and Settings\\Admin\\Desktop\\WANG\\source\\001.bmp", properties.Filename);
        }
Exemplo n.º 10
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());
        }
Exemplo n.º 11
0
        public void ReadRectangleStd()
        {
            // Well formed data
            byte[] streamData =
            {
                // Left
                100, 0, 0, 0,
                // Top
                1,   0, 0, 0,
                // Right
                200, 0, 0, 0,
                // Bottom
                55,  0, 0, 0,
            };

            WangStream stream = new WangStream(streamData);

            int[] coordinates = new int[4];
            Assert.IsTrue(WangAnnotationStructureReader.ReadRectangle(coordinates, stream));

            Assert.AreEqual(100, coordinates[WangAnnotationTranslation.LeftIndex]);
            Assert.AreEqual(1, coordinates[WangAnnotationTranslation.TopIndex]);
            Assert.AreEqual(200, coordinates[WangAnnotationTranslation.RightIndex]);
            Assert.AreEqual(55, coordinates[WangAnnotationTranslation.BottomIndex]);
            Assert.AreEqual(0, stream.AvailableBytes());
        }
Exemplo n.º 12
0
        public void ReadRectangleInvalidSize()
        {
            // Well formed data
            byte[] streamData =
            {
                // Left
                100, 0, 0, 0,
                // Top
                1,   0, 0, 0,
                // Right
                200, 0, 0, 0,
                // Bottom
                55,  0, 0, 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);
                int[]      coordinates = new int[4];
                Assert.IsFalse(WangAnnotationStructureReader.ReadRectangle(coordinates, stream));
            }
        }
Exemplo n.º 13
0
        public void ReadRotationStdExactDifferentResolution()
        {
            byte[] streamData =
            {
                1,   0, 0, 0,
                232, 3, 0, 0,
                200, 0, 0, 0,
                200, 0, 0, 0,
                200, 0, 0, 0,
                145, 0, 0, 0,
                0,   0, 0, 0,
                0,   0, 0, 0,
                1,   0, 0, 0,
                0,   0, 0, 0,
                0,   0, 0, 0,
                0,   0, 0, 0,
                0,   0, 0, 0,
                0,   0, 0, 0
            };

            WangStream   stream = new WangStream(streamData);
            WangRotation read   = WangAnnotationStructureReader.ReadRotation(stream, 56);

            Assert.IsTrue(read != null);

            Assert.AreEqual(200, read.OrigHRes);
            Assert.AreEqual(145, read.OrigVRes);
            Assert.AreEqual(1, read.Rotation);
            Assert.AreEqual(0, stream.AvailableBytes());
        }
Exemplo n.º 14
0
        public void ReadRotationInvalidSize()
        {
            // Well formed stream data
            byte[] streamData =
            {
                1,   0, 0, 0,
                232, 3, 0, 0,
                200, 0, 0, 0,
                200, 0, 0, 0,
                145, 0, 0, 0,
                145, 0, 0, 0,
                0,   0, 0, 0,
                0,   0, 0, 0,
                1,   0, 0, 0,
                0,   0, 0, 0,
                0,   0, 0, 0,
                0,   0, 0, 0,
                0,   0, 0, 0,
                0,   0, 0, 0
            };

            for (int dataSize = 0; dataSize < streamData.Length - 1; dataSize++)
            {
                WangStream   stream = new WangStream(streamData);
                WangRotation read   = WangAnnotationStructureReader.ReadRotation(stream, dataSize);
                Assert.IsTrue(read == null);
            }
        }
Exemplo n.º 15
0
        public void ReadPointsReadFailure()
        {
            // Well formed data
            byte[] streamData =
            {
                // max is 2
                2,   0, 0, 0,
                // count is 2
                2,   0, 0, 0,
                // x0 = 729
                217, 2, 0, 0,
                // y0 = 446
                190, 1, 0, 0,
                // x1 = 0
                0,   0, 0, 0,
                // y1 = 0
                0,   0, 0, 0,
            };

            // The stream contains exactly the correct amount of data.
            // With fewer data, an error should rise.
            for (int dataSize = 0; dataSize < streamData.Length - 1; dataSize++)
            {
                WangStream stream = new WangStream(streamData);
                int[]      read   = WangAnnotationStructureReader.ReadPoints(stream, dataSize);
                Assert.IsTrue(read == null);
            }
        }
        public void ReadBlockOiHypLnk()
        {
            const int headerSize = 12;

            // Stream with a named block header and a display text
            byte[] streamData =
            {
                // Named block header
                79,  105,  72, 121, 112, 76, 110, 107, 35, 0, 0, 0,
                // Hyperlink
                1,     0,   0,   0,
                14,    0,   0,   0,
                115, 111, 117, 114,
                99,  101,  92,  48,
                48,   49,  46, 106,
                112, 103,   1,   0,
                0,     0,  49,   0,
                0,     0,   0,   0,
                0,     0,   0,
                // Extra bytes
                1,     2,   3, 4
            };

            WangAnnotationProperties properties = new WangAnnotationProperties();
            WangStream stream = new WangStream(streamData);

            Assert.IsTrue(WangAnnotationsReader.ReadBlock(properties, stream, headerSize));
            Assert.AreEqual(4, stream.AvailableBytes());
            Assert.AreEqual(false, properties.Hyperlink.CanRemoveHyperlink);
            Assert.AreEqual(false, properties.Hyperlink.InternalLink);
            Assert.AreEqual("source\\001.jpg", properties.Hyperlink.Link);
            Assert.AreEqual("1", properties.Hyperlink.Location);
            Assert.AreEqual("", properties.Hyperlink.WorkingDirectory);
        }
Exemplo n.º 17
0
        public void ReadLogfontGeorgia()
        {
            // Well formed data with
            byte[] streamData =
            {
                14,    0,   0,   0,  0,   0,   0,   0,   0,   0,
                0,     0,   0,   0,  0,   0, 188,   2,   0,   0,
                0,     0,   1,   0,  3,   2,   1,  18,  71, 101,
                111, 114, 103, 105, 97,   0,  32,  71, 111, 116,
                104, 105,  99,  32, 77, 101, 100, 105, 117, 109,
                0,     0,   0,   0,  0, 0
            };

            WangStream  stream = new WangStream(streamData);
            WangLogFont read   = WangAnnotationStructureReader.ReadLogfont(stream);

            Assert.IsTrue(read != null);

            Assert.AreEqual(14, read.Height);
            Assert.AreEqual(0, read.Width);
            Assert.AreEqual(0, read.Escapement);
            Assert.AreEqual(0, read.Orientation);
            Assert.AreEqual(700, read.Weight);
            Assert.AreEqual(false, read.Italic);
            Assert.AreEqual(false, read.Underline);
            Assert.AreEqual(true, read.StrikeOut);
            Assert.AreEqual(0, read.CharSet);
            Assert.AreEqual(3, read.OutPrecision);
            Assert.AreEqual(2, read.ClipPrecision);
            Assert.AreEqual(1, read.Quality);
            Assert.AreEqual(18, read.PitchAndFamily);
            Assert.AreEqual("Georgia", read.FaceName);
        }
Exemplo n.º 18
0
        public void ReadLogfontZero()
        {
            // Well formed data (only 0s)
            byte[] streamData = new byte[56];

            WangStream  stream = new WangStream(streamData);
            WangLogFont read   = WangAnnotationStructureReader.ReadLogfont(stream);

            Assert.IsTrue(read != null);

            Assert.AreEqual(0, read.Height);
            Assert.AreEqual(0, read.Width);
            Assert.AreEqual(0, read.Escapement);
            Assert.AreEqual(0, read.Orientation);
            Assert.AreEqual(0, read.Weight);
            Assert.AreEqual(false, read.Italic);
            Assert.AreEqual(false, read.Underline);
            Assert.AreEqual(false, read.StrikeOut);
            Assert.AreEqual(0, read.CharSet);
            Assert.AreEqual(0, read.OutPrecision);
            Assert.AreEqual(0, read.ClipPrecision);
            Assert.AreEqual(0, read.Quality);
            Assert.AreEqual(0, read.PitchAndFamily);
            Assert.AreEqual("", read.FaceName);
        }
Exemplo n.º 19
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));
            }
        }
Exemplo n.º 20
0
        public void ReadMarkAttributes1()
        {
            // Well formed data
            byte[] streamData =
            {
                10,    0,   0,   0, 229,   1,   0,   0, 202,  0,
                0,     0, 233,   3,   0,   0, 155,   2,   0,  0,
                0,   255, 255,   0,   0,   0,   0,   0,   0,  0,
                0,     0,   0,   0,   0,   0,   0,   0,   0,  0,
                0,     0,   0,   0,   0,   0,   0,   0,  12,  0,
                0,     0,   0,   0,   0,   0,   0,   0,   0,  0,
                0,     0,   0,   0, 144,   1,   0,   0,   0,  0,
                0,     0,   0,   0,   0,   0,  65, 114, 105, 97,
                108,   0, 145, 124, 247,  49, 145, 124,   8,  6,
                12,    0, 136,   0, 126,   0,   0,   0,   0,  0,
                0,     0,   0,   0,  44, 224,  10,   0,   0,  0,
                0,     0,  68,   3,  51,  88,   1,   0,   0,  0,
                63,  248,  15,   0,   0,   0,   0,   0,   0,  0,
                0,     0,   0,   0,   0,   0,   0,   0,   0,  0,
                0,     0,   0,   0,   0,   0,   0,   0,   0,  0,
                0,     0,   0,   0,   0,   0,   0,   0,   0,  0,
                0,     0,   0, 0
            };

            WangStream         stream = new WangStream(streamData);
            WangMarkAttributes read   = WangAnnotationStructureReader.ReadMarkAttributes(stream, 164);

            Assert.IsTrue(read != null);

            Assert.AreEqual(12, read.LogFont.Height);
            Assert.AreEqual(0, read.LogFont.Width);
            Assert.AreEqual(0, read.LogFont.Escapement);
            Assert.AreEqual(0, read.LogFont.Orientation);
            Assert.AreEqual(400, read.LogFont.Weight);
            Assert.AreEqual(false, read.LogFont.Italic);
            Assert.AreEqual(false, read.LogFont.Underline);
            Assert.AreEqual(false, read.LogFont.StrikeOut);
            Assert.AreEqual(0, read.LogFont.CharSet);
            Assert.AreEqual(0, read.LogFont.OutPrecision);
            Assert.AreEqual(0, read.LogFont.ClipPrecision);
            Assert.AreEqual(0, read.LogFont.Quality);
            Assert.AreEqual(0, read.LogFont.PitchAndFamily);
            Assert.AreEqual("Arial", read.LogFont.FaceName);
            Assert.AreEqual(false, read.Highlighting);
            Assert.AreEqual(false, read.Transparent);
            Assert.AreEqual((uint)0, read.LineSize);
            Assert.AreEqual(true, read.Visible);
            Assert.AreEqual(485, read.Bounds[0]);
            Assert.AreEqual(202, read.Bounds[1]);
            Assert.AreEqual(1001, read.Bounds[2]);
            Assert.AreEqual(667, read.Bounds[3]);
            Assert.AreEqual(0, read.Color1[0]);
            Assert.AreEqual(255, read.Color1[1]);
            Assert.AreEqual(255, read.Color1[2]);
            Assert.AreEqual(0, read.Color2[0]);
            Assert.AreEqual(0, read.Color2[1]);
            Assert.AreEqual(0, read.Color2[2]);
        }
Exemplo n.º 21
0
        public void ReadMarkAttributes2()
        {
            // Well formed data
            byte[] streamData =
            {
                15,    0,   0,   0, 64,   1,  0,  0, 68, 0,
                0,     0, 156,   4,  0,   0, 16,  3,  0, 0,
                192, 192, 192,   0,  0,   0,  0,  0,  1, 0,
                0,     0,   0,   0,  0,   0,  0,  0,  0, 0,
                0,     0,   0,   0,  0,   0,  0,  0,  0, 0,
                0,     0,   0,   0,  0,   0,  0,  0,  0, 0,
                0,     0,   0,   0,  0,   0,  0,  0,  0, 0,
                0,     0,   0,   0,  0,   0,  0,  0,  0, 0,
                0,     0,   0,   0,  0,   0,  0,  0,  0, 0,
                0,     0,   0,   0,  0,   0,  0,  0,  0, 0,
                0,     0,   0,   0,  0,   0,  0,  0,  0, 0,
                0,     0, 252, 253, 54,  88,  1,  0,  0, 0,
                63,  248,  15,   0, 88, 254, 54, 88,  0, 0,
                0,     0,   0,   0,  0,   0,  0,  0,  0, 0,
                0,     0,   0,   0,  0,   0,  0,  0,  0, 0,
                0,     0,   0,   0,  0,   0,  0,  0,  0, 0,
                0,     0,   0, 0
            };

            WangStream         stream = new WangStream(streamData);
            WangMarkAttributes read   = WangAnnotationStructureReader.ReadMarkAttributes(stream, 164);

            Assert.IsTrue(read != null);

            Assert.AreEqual(0, read.LogFont.Height);
            Assert.AreEqual(0, read.LogFont.Width);
            Assert.AreEqual(0, read.LogFont.Escapement);
            Assert.AreEqual(0, read.LogFont.Orientation);
            Assert.AreEqual(0, read.LogFont.Weight);
            Assert.AreEqual(false, read.LogFont.Italic);
            Assert.AreEqual(false, read.LogFont.Underline);
            Assert.AreEqual(false, read.LogFont.StrikeOut);
            Assert.AreEqual(0, read.LogFont.CharSet);
            Assert.AreEqual(0, read.LogFont.OutPrecision);
            Assert.AreEqual(0, read.LogFont.ClipPrecision);
            Assert.AreEqual(0, read.LogFont.Quality);
            Assert.AreEqual(0, read.LogFont.PitchAndFamily);
            Assert.AreEqual("", read.LogFont.FaceName);
            Assert.AreEqual(true, read.Highlighting);
            Assert.AreEqual(false, read.Transparent);
            Assert.AreEqual((uint)0, read.LineSize);
            Assert.AreEqual(true, read.Visible);
            Assert.AreEqual(320, read.Bounds[0]);
            Assert.AreEqual(68, read.Bounds[1]);
            Assert.AreEqual(1180, read.Bounds[2]);
            Assert.AreEqual(784, read.Bounds[3]);
            Assert.AreEqual(192, read.Color1[0]);
            Assert.AreEqual(192, read.Color1[1]);
            Assert.AreEqual(192, read.Color1[2]);
            Assert.AreEqual(0, read.Color2[0]);
            Assert.AreEqual(0, read.Color2[1]);
            Assert.AreEqual(0, read.Color2[2]);
        }
Exemplo n.º 22
0
 public void ReadLogfontReadFailure()
 {
     for (int dataSize = 0; dataSize < 56; dataSize++)
     {
         byte[]     streamData = new byte[dataSize];
         WangStream stream     = new WangStream(streamData);
         Assert.AreEqual(null, WangAnnotationStructureReader.ReadLogfont(stream));
     }
 }
Exemplo n.º 23
0
 public void ReadMarkAttributesReadFailure()
 {
     for (int dataSize = 0; dataSize < 164; dataSize++)
     {
         byte[]     streamData = new byte[dataSize];
         WangStream stream     = new WangStream(streamData);
         Assert.AreEqual(null, WangAnnotationStructureReader.ReadMarkAttributes(stream, dataSize));
     }
 }
Exemplo n.º 24
0
        public void ReadCharStringReadOversize()
        {
            // The buffer contains the string "OiGroup" and no null bytes.
            byte[] streamData =
            {
                79, 105, 71, 114, 111, 117, 112, 112
            };

            WangStream stream = new WangStream(streamData);
            string     read   = WangAnnotationStructureReader.ReadCharString(stream, 7);

            Assert.AreEqual("OiGroup", read);
            Assert.AreEqual(1, stream.AvailableBytes());
        }
Exemplo n.º 25
0
        public void ReadCharStringStdShort()
        {
            // The buffer contains the string "OiGroup" and trailing null bytes.
            byte[] streamData =
            {
                79, 105, 71, 114, 111, 117, 112, 0, 0, 0, 0, 0, 0
            };

            WangStream stream = new WangStream(streamData);
            string     read   = WangAnnotationStructureReader.ReadCharString(stream, streamData.Length);

            Assert.AreEqual("OiGroup", read);
            Assert.AreEqual(0, stream.AvailableBytes());
        }
Exemplo n.º 26
0
        public void ReadInt32Test()
        {
            byte[] input = new byte[4] {
                0xff, 0xFF, 0xff, 0xFF
            };

            WangStream wangStream = new WangStream(input);

            Assert.IsFalse(wangStream.IsEnd());
            Assert.AreEqual(-1, wangStream.ReadInt32());
            Assert.AreEqual(0, wangStream.AvailableBytes());
            Assert.IsTrue(wangStream.IsEnd());
            Assert.AreEqual(0, wangStream.AvailableBytes());
        }
Exemplo n.º 27
0
        public void ReadNamedBlockHeaderReadOversize()
        {
            // Well formed data with an extra last byte
            byte[] streamData =
            {
                79, 105, 71, 114, 111, 117, 112, 0, 11, 0, 0, 0, 91
            };

            WangStream stream = new WangStream(streamData);
            // As we ask to read the entire data, including the extra byte, an
            // error should rise.
            WangNamedBlockHeader read = WangAnnotationStructureReader.ReadNamedBlockHeader(stream, streamData.Length);

            Assert.IsTrue(read == null);
        }
Exemplo n.º 28
0
        public void SkipBytesTest()
        {
            byte[] input = new byte[4] {
                1, 2, 3, 4
            };
            WangStream wangStream = new WangStream(input);

            Assert.IsFalse(wangStream.IsEnd());
            wangStream.SkipBytes(2);
            Assert.IsFalse(wangStream.IsEnd());
            Assert.AreEqual(2, wangStream.AvailableBytes());
            Assert.AreEqual(3, wangStream.ReadByte());
            Assert.IsFalse(wangStream.IsEnd());
            Assert.AreEqual(1, wangStream.AvailableBytes());
        }
        public void ReadHeaderInvalid()
        {
            for (int dataSize = 0; dataSize < 8; dataSize++)
            {
                byte[] streamData = new byte[dataSize];
                byte   b          = 0;
                for (int index = 0; index < dataSize; index++)
                {
                    streamData[index] = b++;
                }

                WangStream stream = new WangStream(streamData);
                Assert.IsFalse(WangAnnotationsReader.ReadHeader(stream));
            }
            ;
        }
Exemplo n.º 30
0
        public void ReadNamedBlockHeaderStd32()
        {
            // Well formed data with an extra last byte
            byte[] streamData =
            {
                79, 105, 71, 114, 111, 117, 112, 0, 11, 0, 0, 0, 91
            };

            WangStream           stream = new WangStream(streamData);
            WangNamedBlockHeader read   = WangAnnotationStructureReader.ReadNamedBlockHeader(stream, 12);

            Assert.IsTrue(read != null);

            Assert.AreEqual("OiGroup", read.Name);
            Assert.AreEqual(11, read.Size);
            Assert.AreEqual(1, stream.AvailableBytes());
        }