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 testExceptionDuringClose() { var u = new UnionInputStream(); u.add(new MockMemoryStream(new byte[] { 1 }, () => { throw new IOException("I AM A TEST"); })); try { u.Close(); Assert.Fail("close ignored inner stream exception"); } catch (IOException e) { Assert.AreEqual("I AM A TEST", e.Message); } }
public void testCloseDuringClose() { var u = new UnionInputStream(); var closed = new bool[2]; u.add(new MockMemoryStream(new byte[] { 1 }, () => { closed[0] = true; })); u.add(new MockMemoryStream(new byte[] { 2 }, () => { closed[1] = true; })); Assert.IsFalse(closed[0]); Assert.IsFalse(closed[1]); u.Close(); Assert.IsTrue(closed[0]); Assert.IsTrue(closed[1]); }