Esempio n. 1
0
        public void Should_Check_Clone()
        {
            //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[] { -3, 4, 1, 5, 3 };

            //act
            var clone  = array.Clone();
            var result = new List <int>();

            foreach (var item in clone)
            {
                result.Add(item);
            }

            //assert
            result.SequenceEqual(resultValues).ShouldBeEquivalentTo(true);
            result.Count.ShouldBeEquivalentTo(resultValues.Length);
            clone.Capacity.ShouldBeEquivalentTo(array.Capacity);
            clone.Count.ShouldBeEquivalentTo(array.Count);

            clone.ShouldBeEquivalentTo(array);
            clone.Equals(array).ShouldBeEquivalentTo(false);
        }