public void CopyToArrayWithStartingIndexOffsetAndCountTest() { // arrange ByteCircularBuffer target; int expectedHead; byte[] expected; byte[] actual; int offset; int count; int index; target = new ByteCircularBuffer(10); expected = new byte[] { 5, 2, 3, 7 }; actual = new byte[] { 5, 0, 0, 7 }; expectedHead = 0; index = 1; offset = 1; count = 2; target.Put(1); target.Put(2); target.Put(3); // act target.CopyTo(index, actual, offset, count); // assert actual.Should(). Equal(expected); target.Contains(1). Should(). BeTrue(); target.Contains(2). Should(). BeTrue(); target.Contains(3). Should(). BeTrue(); target.Head.Should(). Be(expectedHead); }
public void CopyToArrayWithOffsetTest() { // arrange ByteCircularBuffer target; int expectedHead; byte[] expected; byte[] actual; int offset; target = new ByteCircularBuffer(10); expected = new byte[] { 5, 1, 2, 3 }; actual = new byte[] { 5, 0, 0, 0 }; expectedHead = 0; offset = 1; target.Put(1); target.Put(2); target.Put(3); // act target.CopyTo(actual, offset); // assert actual.Should(). Equal(expected); target.Contains(1). Should(). BeTrue(); target.Contains(2). Should(). BeTrue(); target.Contains(3). Should(). BeTrue(); target.Head.Should(). Be(expectedHead); }
public void CopyToTest() { // arrange ByteCircularBuffer target; int expectedHead; byte[] expected; byte[] actual; target = new ByteCircularBuffer(10); expected = new byte[] { 1, 2, 3 }; expectedHead = 0; actual = new byte[3]; target.Put(1); target.Put(2); target.Put(3); // act target.CopyTo(actual); // assert actual.Should(). Equal(expected); target.Contains(1). Should(). BeTrue(); target.Contains(2). Should(). BeTrue(); target.Contains(3). Should(). BeTrue(); target.Head.Should(). Be(expectedHead); }
public void CopyToExceptionTest() { // arrange ByteCircularBuffer target; byte[] actual; int offset; int count; int index; target = new ByteCircularBuffer(10); actual = new byte[target.Capacity]; index = 0; offset = 0; count = 4; target.Put(1); target.Put(2); target.Put(3); // act & assert Assert.That(() => target.CopyTo(index, actual, offset, count), Throws.TypeOf <ArgumentOutOfRangeException>()); }