public void TestOperations() { // invalid operations using (var stream = new CompressionStream(Create("test"), CompressionMode.Compress)) { AssertException(() => stream.Seek(0, SeekOrigin.Current)); AssertException(() => stream.Write(new Byte[10], 0, 10)); } using (var stream = new CompressionStream(Encode("test"), CompressionMode.Decompress)) { AssertException(() => stream.Seek(0, SeekOrigin.Current)); AssertException(() => stream.Write(new Byte[10], 0, 10)); } }
public void TestProperties() { using (var stream = new CompressionStream(Create("test"), CompressionMode.Compress)) { // invalid properties Assert.IsFalse(stream.CanSeek); Assert.IsFalse(stream.CanWrite); AssertException(() => { var x = stream.Position; }); AssertException(() => stream.Position = 10); AssertException(() => { var x = stream.Length; }); AssertException(() => stream.SetLength(10)); // valid properties Assert.IsTrue(stream.CanRead); } using (var stream = new CompressionStream(Encode("test"), CompressionMode.Decompress)) { // invalid properties Assert.IsFalse(stream.CanSeek); Assert.IsFalse(stream.CanWrite); AssertException(() => { var x = stream.Position; }); AssertException(() => stream.Position = 10); AssertException(() => { var x = stream.Length; }); AssertException(() => stream.SetLength(10)); // valid properties Assert.IsTrue(stream.CanRead); } }