Exemplo n.º 1
0
 public void CopyToWorks()
 {
     var arr = Enumerable.Range(0, 10).ToArray();
     var c = new FastCollection<int>();
     c.CopyTo(arr, 0);
     Assert.True(arr.SequenceEqual(Enumerable.Range(0, 10)));
     c.Add(5);
     c.CopyTo(arr, 0);
     Assert.Equal(5, arr[0]);
     Assert.True(arr.Skip(1).SequenceEqual(Enumerable.Range(1, 9)));
     c.CopyTo(arr, 1);
     Assert.Equal(5, arr[0]);
     Assert.Equal(5, arr[1]);
     Assert.True(arr.Skip(2).SequenceEqual(Enumerable.Range(2, 8)));
     c.Add(6);
     c.CopyTo(arr, 0);
     Assert.Equal(5, arr[0]);
     Assert.Equal(6, arr[1]);
     Assert.True(arr.Skip(2).SequenceEqual(Enumerable.Range(2, 8)));
     c.CopyTo(arr, 1);
     Assert.Equal(5, arr[0]);
     Assert.Equal(5, arr[1]);
     Assert.Equal(6, arr[2]);
     Assert.True(arr.Skip(3).SequenceEqual(Enumerable.Range(3, 7)));
 }