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"); }
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); }
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"); }
public void ReadByteWithZeroLengthInputStreamShouldReturnEndOfStream() { using (var gzi = new GZipInputStream(new MemoryStream())) { int val = gzi.ReadByte(); Assert.AreEqual(-1,val); } }