示例#1
0
        public void ZeroLengthInputStream()
        {
            var gzi = new GZipInputStream(new MemoryStream());
            bool exception = false;
            int retval = int.MinValue;
            try
            {
                retval = gzi.ReadByte();
            }
            catch
            {
                exception = true;
            }

            Assert.IsFalse(exception, "reading from an empty stream should not cause an exception");
            Assert.That(retval, Is.EqualTo(-1), "should yield -1 byte value");
        }
示例#2
0
		override protected void DoOpen (FileInfo info)
		{
			// Try to open the file as if it is gzip.
			// If that fails, we conclude that it must
			// just be a regular text file full of xml.
			is_gzipped = true;
			try {
				Stream s;
				s = new FileStream (info.FullName, FileMode.Open, FileAccess.Read, FileShare.Read);
				Stream z;
				z = new GZipInputStream (s);
				z.ReadByte ();
				z.Close ();
				s.Close ();
			} catch (Exception) {
				is_gzipped = false;
			}

			hotStyles = new Hashtable ();
			reader = BuildReader (info.FullName);
		}
示例#3
0
        public void ZeroLengthInputStream()
        {
            GZipInputStream gzi = new GZipInputStream(new MemoryStream());
            bool exception = false;
            try {
                gzi.ReadByte();
            }
            catch {
                exception = true;
            }

            Assert.IsTrue(exception, "reading from an empty stream should cause an exception");
        }
示例#4
0
        public void ReadByteWithZeroLengthInputStreamShouldReturnEndOfStream()
        {
            using (var gzi = new GZipInputStream(new MemoryStream()))
            {

                int val = gzi.ReadByte();

                Assert.AreEqual(-1,val);
            }
        }