public void OTFileReadUInt8Test() { byte[] b = new byte[32] { 0, 1, 0, 0, 0, 0x0F, 0, 0x80, 0, 3, 0, 0x70, 0x44, 0x53, 0x49, 0x47, 0xF0, 0x54, 0x3E, 0x26, 0, 0, 0x91, 0xE4, 0, 0, 0x1A, 0xDC, 0x47, 0x44, 0x45, 0x46 }; MemoryStream ms = new MemoryStream(b); ms.Position = 5; // 0x0F Assert.IsTrue(OTFile.ReadUInt8(ms) == 0x0F, "Error: unexpected value read"); ms.Position = 16; // 0xF0 Assert.IsTrue(OTFile.ReadUInt8(ms) == 0xF0, "Error: unexpected value read"); bool caughtExpectedException = false; ms.Position = ms.Length; try { OTFile.ReadUInt8(ms); } catch (OTDataIncompleteReadException) { caughtExpectedException = true; } catch (Exception) { // unexpected exception } Assert.IsTrue(caughtExpectedException, "Error: expected exception not caught"); ms.Close(); caughtExpectedException = false; try { OTFile.ReadUInt8(ms); } catch (ObjectDisposedException) { caughtExpectedException = true; } catch (Exception) { // unexpected exception } Assert.IsTrue(caughtExpectedException, "Error: expected exception not caught"); }