Beispiel #1
0
        /// <summary>
        ///     Checks that the given stream contains the content
        ///     we expect to find in it.
        /// </summary>
        static public void CheckBinaryStream(CvsStream cvsStream, bool isCompressed)
        {
            int    len;
            String numStr;
            String msg;

            // Rewind the memory stream so we can check what was written to it
            cvsStream.Position = 0;

            if (isCompressed)
            {
                // First char should be a 'z'
                Assert.AreEqual(cvsStream.ReadByte(), 'z');
            }

            // Read the first line which should be the line length
            numStr = cvsStream.ReadLine();
            len    = Int32.Parse(numStr);
            msg    = String.Format("Expected length of {0} but got length {1}",
                                   GetBinaryLen(BINARY_BLOCKS), len);
            Assert.AreEqual(GetBinaryLen(BINARY_BLOCKS), len);

            // Check what was written to the memory stream matches the file we generated
            for (int n = 0; n < GetBinaryLen(BINARY_BLOCKS); n++)
            {
                byte actual = (byte)cvsStream.ReadByte();
                byte wanted = GenerateBinaryByte(n);
                msg = String.Format("n:{0} actual:0x{1:X2} wanted:0x{2:X2}", n, actual, wanted);
                Assert.AreEqual(wanted, actual, msg);
            }
        }
Beispiel #2
0
        /// <summary>
        ///     Checks that the given stream contains the content
        ///     we expect to find in it.
        /// </summary>
        static public void CheckTextStream(CvsStream cvsStream, bool isCompressed)
        {
            int    linefeedChars = 1; // this stream is intended for cvs
            int    len;
            String numStr;
            String msg;

            // Rewind the memory stream so we can check what was written to it
            cvsStream.Position = 0;

            if (isCompressed)
            {
                // First char should be a 'z'
                Assert.AreEqual(cvsStream.ReadByte(), 'z');
            }

            // Read the first line which should be the line length
            numStr = cvsStream.ReadLine();
            len    = Int32.Parse(numStr);
            msg    = String.Format("Expected length of {0} but got length {1}",
                                   GetTextLen(TEXT_BLOCKS, linefeedChars), len);
            Assert.AreEqual(GetTextLen(TEXT_BLOCKS, linefeedChars), len);

            // Check what was written to the memory stream matches the file we generated
            for (int n = 0; n < GetTextLen(TEXT_BLOCKS, linefeedChars); n++)
            {
                byte actual = (byte)cvsStream.ReadByte();
                byte wanted = GenerateTextByte(n, linefeedChars);
                msg = String.Format("n:{0} actual:{1} wanted:{2}", n, actual, wanted);
                Assert.AreEqual(wanted, actual, msg);
            }
        }