protected void assertContentsMatches(byte[] expected, DocumentEntry doc) { NDocumentInputStream inp = new NDocumentInputStream(doc); byte[] contents = new byte[doc.Size]; Assert.AreEqual(doc.Size, inp.Read(contents)); inp.Close(); if (expected != null) Assert.That(expected, new EqualConstraint(contents)); }
public void TestAvailable() { DocumentInputStream ostream = new DocumentInputStream(_workbook_o); DocumentInputStream nstream = new NDocumentInputStream(_workbook_n); Assert.AreEqual(_workbook_size, ostream.Available()); Assert.AreEqual(_workbook_size, nstream.Available()); ostream.Close(); nstream.Close(); try { ostream.Available(); Assert.Fail("Should have caught IOException"); } catch (InvalidOperationException) { // as expected } try { nstream.Available(); Assert.Fail("Should have caught IOException"); } catch (InvalidOperationException) { // as expected } }
public void TestConstructor() { DocumentInputStream ostream = new DocumentInputStream(_workbook_o); DocumentInputStream nstream = new NDocumentInputStream(_workbook_n); Assert.AreEqual(_workbook_size, _workbook_o.Size); Assert.AreEqual(_workbook_size, _workbook_n.Size); Assert.AreEqual(_workbook_size, ostream.Available()); Assert.AreEqual(_workbook_size, nstream.Available()); }