public void testEmptyStream() { var u = new UnionInputStream(); Assert.IsTrue(u.isEmpty()); Assert.AreEqual(-1, u.read()); Assert.AreEqual(-1, u.Read(new byte[1], 0, 1)); Assert.AreEqual(0, u.available()); Assert.AreEqual(0, u.skip(1)); u.Close(); }
public void testSkip() { var u = new UnionInputStream(); u.add(new MemoryStream(new byte[] { 1, 0, 2 })); u.add(new MemoryStream(new byte[] { 3 })); u.add(new MemoryStream(new byte[] { 4, 5 })); Assert.AreEqual(0, u.skip(0)); Assert.AreEqual(4, u.skip(4)); Assert.AreEqual(4, u.read()); Assert.AreEqual(1, u.skip(5)); Assert.AreEqual(0, u.skip(5)); Assert.AreEqual(-1, u.read()); u.add(new MockMemoryStream(new byte[] { 20, 30 }, null)); // can't mock skip behavior :-( Assert.AreEqual(2, u.skip(8)); Assert.AreEqual(-1, u.read()); }