public void CopyTo()
        {
            var destArray = new[] { "x", "x", "x", "x", "x", "x" };

            _adapter.CopyTo(destArray, 2);

            Assert.That(destArray, Is.EqualTo(new[] { "x", "x", "1", "2", "3", "x" }));
        }
예제 #2
0
        public void CopyToArrayWillStopWhenNoMoreItemsExist()
        {
            var destList = new ListAdapter <string, Uri>(
                str => new Uri(str),
                uri => uri.ToString(),
                (str, uri) => string.Equals(str, uri?.ToString()),
                new List <Uri>())
            {
                "http://maps.google.com",
                "http://www.twitter.com",
                "http://localhost/one",
                "http://localhost/two",
                "http://localhost/three"
            };

            var array = new string[10];

            destList.CopyTo(array, 2);

            for (var i = 0; i < array.Length; i++)
            {
                if (i < 3)
                {
                    array[i].Should().Be(destList[i + 2]);
                }
                else
                {
                    array[i].Should().BeNull();
                }
            }
        }
예제 #3
0
        public void CanCopyToArray()
        {
            var destList = new ListAdapter <string, Uri>(
                str => new Uri(str),
                uri => uri.ToString(),
                (str, uri) => string.Equals(str, uri?.ToString()),
                new List <Uri>())
            {
                "http://maps.google.com",
                "http://www.twitter.com"
            };

            var array = new string[2];

            destList.CopyTo(array, 0);

            for (var i = 0; i < array.Length; i++)
            {
                array[i].Should().Be(destList[i]);
            }
        }
예제 #4
0
        public void CopyToArrayRespectsStartIndex()
        {
            var destList = new ListAdapter <string, Uri>(
                str => new Uri(str),
                uri => uri.ToString(),
                (str, uri) => string.Equals(str, uri?.ToString()),
                new List <Uri>())
            {
                "http://maps.google.com",
                "http://www.twitter.com",
                "http://localhost/one",
                "http://localhost/two",
                "http://localhost/three"
            };

            var array = new string[3];

            destList.CopyTo(array, 2);

            for (var i = 0; i < array.Length; i++)
            {
                array[i].Should().Be(destList[i + 2]);
            }
        }