public void AppendConstrainedTest1() { var buffer = new NetworkBuffer(10); var data = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; buffer.AppendConstrained(data, 2, 5); Assert.AreEqual <int>(5, buffer.Received); var received = buffer.ToArray(); Assert.AreEqual <byte>(2, received[0]); Assert.AreEqual <byte>(6, received[4]); buffer.Dispose(); }
public void AppendConstrainedTest4() { var buffer = new NetworkBuffer(20, new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); var data = new byte[] { 10, 121, 55, 32, 44, 56, 31, 46, 71, 88 }; buffer.AppendConstrained(data, 2, 5); Assert.AreEqual <int>(15, buffer.Received); var received = buffer.ToArray(); Assert.AreEqual <byte>(0, received[0]); Assert.AreEqual <byte>(4, received[4]); Assert.AreEqual <byte>(55, received[10]); Assert.AreEqual <byte>(31, received[14]); buffer.Dispose(); }
public void AppendConstrainedTest3() { var buffer = new NetworkBuffer(10, new byte[] { 0, 1, 2, 3, 4, 5, 6 }); try { buffer.AppendConstrained(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, 2, 8); Assert.Fail("An exception should be thrown"); } catch (Exception ex) { Assert.IsTrue(ex is ArgumentOutOfRangeException, "The exception thrown should be an \"Argument Out Of Range Exception\"."); } finally { buffer.Dispose(); } }
public void AppendConstrainedTest2() { var buffer = new NetworkBuffer(10); try { buffer.AppendConstrained(null, 2, 5); Assert.Fail("An exception should be thrown"); } catch (Exception ex) { Assert.IsTrue(ex is ArgumentNullException, "The exception thrown should be an \"Argument Null Exception\"."); } finally { buffer.Dispose(); } }