Пример #1
0
        public void TestCopyToFail()
        {
            var rr = new RoundRobin <int>(10)
            {
                1, 2, 3, 4, 5, 6, 7, 8, 9, 10
            };
            var array5  = new int[5];
            var array10 = new int[10];

            Assert.ThrowsException <ArgumentNullException>(() => rr.CopyTo(null, 0));
            Assert.ThrowsException <ArgumentOutOfRangeException>(() => rr.CopyTo(array10, -1));
            Assert.ThrowsException <ArgumentException>(() => rr.CopyTo(array5, 0));
            Assert.ThrowsException <ArgumentException>(() => rr.CopyTo(array10, 3));
        }
Пример #2
0
        public void TestICollectionCopyTo()
        {
            ICollection rr = new RoundRobin <int>(10)
            {
                123,
                456
            };

            int[] res = new int[2];

            rr.CopyTo(res, 0);
            CollectionAssert.AreEqual(new int[] { 123, 456 }, res);
        }
Пример #3
0
        public void TestCopyToPartial()
        {
            var rr = new RoundRobin <int>(10);

            for (int i = 0; i < 5; i++)
            {
                rr.Add(i);
            }

            var test = new int[10];

            rr.CopyTo(test, 0);
            CollectionAssert.AreEqual(new int[] { 0, 1, 2, 3, 4, 0, 0, 0, 0, 0 }, test);
        }
Пример #4
0
        public void TestCopyToMiddle()
        {
            var rr = new RoundRobin <int>(10);

            for (int i = 0; i < 15; i++)
            {
                rr.Add(i);
            }

            var test = new int[12];

            rr.CopyTo(test, 2);
            CollectionAssert.AreEqual(new int[] { 0, 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }, test);
        }