public void TestCombineSeek() { var mem1 = "hello".ToStream(); var mem2 = "world".ToStream(); var stream = new CombineStream(mem1, mem2); var buffer = new byte[5]; Assert.AreEqual(5, stream.Read(buffer, 0, 5)); Assert.AreEqual("hello", Str.Encoding.GetString(buffer)); Assert.AreEqual(5, stream.Read(buffer, 0, 5)); Assert.AreEqual("world", Str.Encoding.GetString(buffer)); stream.Seek(5, SeekOrigin.Begin); Assert.AreEqual(5, stream.Read(buffer, 0, 5)); Assert.AreEqual("world", Str.Encoding.GetString(buffer)); stream.Seek(4, SeekOrigin.Begin); Assert.AreEqual(5, stream.Read(buffer, 0, 5)); Assert.AreEqual("oworl", Str.Encoding.GetString(buffer)); stream.Seek(6, SeekOrigin.Begin); Assert.AreEqual(4, stream.Read(buffer, 0, 5)); Assert.AreEqual("orld", Str.Encoding.GetString(buffer, 0, 4)); stream.Seek(10, SeekOrigin.Begin); Assert.AreEqual(0, stream.Read(buffer, 0, 5)); Assert.AreEqual(0, stream.Read(buffer, 0, 5)); }
public void TestSetLength() { var mem1 = "hello".ToStream(); var mem2 = "world".ToStream(); var stream = new CombineStream(mem1, mem2); stream.SetLength(10); }
public void TestFlush() { var mem1 = "hello".ToStream(); var mem2 = "world".ToStream(); var stream = new CombineStream(mem1, mem2); stream.Flush(); }
public void TestUnknowSeek() { var mem1 = "hello".ToStream(); var mem2 = "world".ToStream(); var stream = new CombineStream(mem1, mem2); stream.Seek(11, (SeekOrigin)100); }
public void TestWrite() { var mem1 = "hello".ToStream(); var mem2 = "world".ToStream(); var stream = new CombineStream(mem1, mem2); stream.Write(new byte[5], 0, 1); }
public void TestSeekOutOfRange() { var mem1 = "hello".ToStream(); var mem2 = "world".ToStream(); var stream = new CombineStream(mem1, mem2); stream.Seek(11, SeekOrigin.Begin); }
public void TestCombineStream() { var mem1 = "hello".ToStream(); var mem2 = "world".ToStream(); var stream = new CombineStream(mem1, mem2); Assert.AreEqual("helloworld", stream.ToText()); }
public void TestGetContstValue() { var mem1 = "hello".ToStream(); var mem2 = "world".ToStream(); var stream = new CombineStream(mem1, mem2); Assert.AreEqual(false, stream.CanWrite); Assert.AreEqual(true, stream.CanSeek); Assert.AreEqual(true, stream.CanRead); }
public void TestCombineStream2() { var mem1 = "hello".ToStream(); var mem2 = "world".ToStream(); var stream = new CombineStream(mem1, mem2); var buffer = new byte[5]; Assert.AreEqual(5, stream.Read(buffer, 0, 5)); Assert.AreEqual("hello", Str.Encoding.GetString(buffer)); Assert.AreEqual(5, stream.Read(buffer, 0, 5)); Assert.AreEqual("world", Str.Encoding.GetString(buffer)); }
public void TestDispose() { var mem1 = "hello".ToStream(); var mem2 = "world".ToStream(); Assert.AreEqual(true, mem1.CanWrite); Assert.AreEqual(true, mem2.CanWrite); using (var stream = new CombineStream(mem1, mem2, true)) { } Assert.AreEqual(false, mem1.CanWrite); Assert.AreEqual(false, mem2.CanWrite); }
public void TestSetPosition() { var mem1 = "hello".ToStream(); var mem2 = "world".ToStream(); var stream = new CombineStream(mem1, mem2); var buffer = new byte[5]; Assert.AreEqual(5, stream.Read(buffer, 0, 5)); Assert.AreEqual("hello", Util.Encoding.GetString(buffer)); Assert.AreEqual(5, stream.Position); stream.Position = 0; Assert.AreEqual(5, stream.Read(buffer, 0, 5)); Assert.AreEqual("hello", Util.Encoding.GetString(buffer)); }
public void TestCombineSeek2() { var mem1 = "hello".ToStream(); var mem2 = "world".ToStream(); var stream = new CombineStream(mem1, mem2); var buffer = new byte[5]; Assert.AreEqual(5, stream.Read(buffer, 0, 5)); Assert.AreEqual("hello", Str.Encoding.GetString(buffer)); stream.Seek(2, SeekOrigin.Current); Assert.AreEqual(3, stream.Read(buffer, 0, 5)); Assert.AreEqual("rld", Str.Encoding.GetString(buffer, 0, 3)); stream.Seek(-3, SeekOrigin.End); Assert.AreEqual(3, stream.Read(buffer, 0, 5)); Assert.AreEqual("rld", Str.Encoding.GetString(buffer, 0, 3)); }
public void TestCannotSeekStreamSetPosition() { var stream = new CombineStream("hello".ToStream(), new CannotSeekStream()); stream.Seek(0, SeekOrigin.Begin); }
public void TestCannotSeekStream() { var stream = new CombineStream("hello".ToStream(), new CannotSeekStream()); Assert.AreEqual(false, stream.CanSeek); }