public static void CopyToTest() { var valueStack = new ValueStack <int>(new int[] { 1, 2, 3 }); var destination = new int[3]; valueStack.CopyTo(destination); Assert.That(() => destination, Is.EquivalentTo(new int[] { 1, 2, 3 }) ); _ = valueStack.Pop(); valueStack.Push(4); valueStack.CopyTo(destination); Assert.That(() => destination, Is.EquivalentTo(new int[] { 1, 2, 4 }) ); destination = new int[6]; valueStack.CopyTo(destination); Assert.That(() => destination, Is.EquivalentTo(new int[] { 1, 2, 4, 0, 0, 0 }) ); _ = valueStack.Pop(); valueStack.Push(5); valueStack.Push(6); valueStack.CopyTo(destination); Assert.That(() => destination, Is.EquivalentTo(new int[] { 1, 2, 5, 6, 0, 0 }) ); Assert.That(() => valueStack.CopyTo(Array.Empty <int>()), Throws.ArgumentException .And.Property("ParamName").EqualTo("destination") ); valueStack = new ValueStack <int>(); Assert.That(() => valueStack.CopyTo(Array.Empty <int>()), Throws.Nothing ); }