Пример #1
0
        public void Should_Check_Copy_To_Throw_If_Destination_Index_Not_In_Range()
        {
            //arrange
            int capacity = 5;
            var array    = new CircularArray <int>(capacity);

            int[] mass = new int[capacity];

            //act
            Action actLower  = () => array.CopyTo(mass, -1);
            Action actHigher = () => array.CopyTo(mass, mass.Length);

            //assert
            actLower.ShouldThrow <ArgumentOutOfRangeException>();
            actHigher.ShouldThrow <ArgumentOutOfRangeException>();
        }
Пример #2
0
        public void CopyTo_Sliced()
        {
            var compareArray = new [] { 3, 4, 5, 6, 7 };
            var array        = new CircularArray <int>(5);

            Fill(array, 7);
            var copyArray = new int[5];

            array.CopyTo(copyArray, 0);
            CheckEnumerator(copyArray, compareArray);
        }
Пример #3
0
        public void CopyTo()
        {
            var compareArray = new [] { 1, 2, 3, 4, 5 };
            var array        = new CircularArray <int>(5);

            Fill(array, 5);
            var copyArray = new int[5];

            array.CopyTo(copyArray, 0);
            CheckEnumerator(copyArray, compareArray);
        }
Пример #4
0
        public void Should_Check_Copy_To_Throw_If_Null()
        {
            //arrange
            int capacity = 5;
            var array    = new CircularArray <int>(capacity);

            //act
            Action act = () => array.CopyTo(null, 1);

            //assert
            act.ShouldThrow <ArgumentNullException>();
        }
Пример #5
0
        public void Should_Check_Copy_To_Throw_If_Not_Enough_Space()
        {
            //arrange
            int capacity = 5;
            var array    = new CircularArray <int>(capacity);

            int[] mass = new int[capacity];

            //act
            Action act = () => array.CopyTo(mass, 1);

            //assert
            act.ShouldThrow <ArgumentException>();
        }
Пример #6
0
        public void Should_Check_Copy_To()
        {
            //arrange
            int capacity = 5;
            var array    = new CircularArray <int>(capacity);

            int[] values = { 5, 3, -3, 4, 1 };
            for (int i = 0; i < values.Length; i++)
            {
                array[i] = values[i];
            }
            array.Rotate(2);

            int[] resultValues = new[] { 0, -3, 4, 1, 5, 3 };

            //act
            var mass = new int[capacity + 1];

            array.CopyTo(mass, 1);

            //assert
            mass.SequenceEqual(resultValues).ShouldBeEquivalentTo(true);
            mass.Length.ShouldBeEquivalentTo(resultValues.Length);
        }
Пример #7
0
        public void CopyTo_DestinationTooSmall()
        {
            var array = new CircularArray <int>(5);

            Assert.Throws <ArgumentException>(() => array.CopyTo(new int[3], 0));
        }