public void WriteNegativeOffsetOrCountTest() { NoSeekMemoryStream ms = new NoSeekMemoryStream(new byte[10]); byte[] buffer = new byte[10]; try{ ms.Write(buffer, -1, 1); Assert.Fail(); } catch (ArgumentOutOfRangeException) { } try{ ms.Write(buffer, 0, -1); Assert.Fail(); } catch (ArgumentOutOfRangeException) { } }
public void WriteBufferNullTest() { NoSeekMemoryStream ms = new NoSeekMemoryStream(new byte[10]); byte[] buffer = new byte[10]; try{ ms.Write(null, 0, 10); } catch (ArgumentNullException) { } }
public void WriteMovesPositionTest() { NoSeekMemoryStream ms = new NoSeekMemoryStream(new byte[10]); byte[] buffer = new byte[10]; Assert.AreEqual(0, ms.Position); ms.Write(buffer, 0, 3); Assert.AreEqual(3, ms.Position); }
public void TestMethod13() { byte[] buf = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; NoSeekMemoryStream nsms = new NoSeekMemoryStream(buf); byte[] buf2 = { 11, 12, 13, 14, 15 }; nsms.Write(buf2, 0, 5); // not at Position = 5 byte[] expected = { 6, 7, 8, 9, 10, 0, 0, 0, 0, 0 }; byte[] result = new byte[expected.Length]; nsms.Read(result, 0, expected.Length); Assert.AreEqual(expected, result); // checking without offset }