public void TestAlwaysClose() { TestIS testIS; // Normal case - Read until EOF and close testIS = new TestIS(OpenSampleStream("13224.xls"), -1); try { new POIFSFileSystem(testIS); } catch (IOException) { throw; } Assert.IsTrue(testIS.IsClosed(), "input stream was not closed"); // intended to crash after Reading 10000 bytes testIS = new TestIS(OpenSampleStream("13224.xls"), 10000); try { new POIFSFileSystem(testIS); Assert.Fail("ex Should have been thrown"); } catch (IOException) { throw; } catch (MyEx) { // expected } Assert.IsTrue(testIS.IsClosed(), "input stream was not closed"); // but still Should close }