public void CopyTo() { // Create a new heap. ConcurrentBinaryMinHeap <int> heap = new ConcurrentBinaryMinHeap <int>(); // Create a new array of size 5. PriorityValuePair <int>[] arrayCopy = new PriorityValuePair <int> [5]; // Push 3 elements onto the queue. PriorityValuePair <int> elem = new PriorityValuePair <int>(3f, 6); heap.Push(1f, 2); heap.Push(elem); heap.Push(2f, 4); // Copy the heap data to the array, starting from index 1 (not 0). heap.CopyTo(arrayCopy, 1); // Expect the first array index to be unset, but all the rest to be set. // Note: The order of elements after the first can't be guaranteed, because the heap // doesn't store things in an exact linear order, but we can be sure that the elements // aren't going to be equal to null because we set them. Assert.That(arrayCopy[0], Is.EqualTo(null)); Assert.That(arrayCopy[1], Is.EqualTo(elem)); Assert.That(arrayCopy[2], Is.Not.EqualTo(null)); Assert.That(arrayCopy[3], Is.Not.EqualTo(null)); Assert.That(arrayCopy[4], Is.EqualTo(null)); }