Exemple #1
0
        static void Main(string[] args)
        {
            FreeIndexArray <int> MyArray = new FreeIndexArray <int>(3, 7);

            MyArray[3] = 3;
            MyArray[5] = 5;
            MyArray[7] = 7;
            for (int i = 3; i <= MyArray.End; i++)
            {
                Console.Write(MyArray[i].ToString(), " ");
            }
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();


            FreeIndexArray <string> MyArray2 = new FreeIndexArray <string>(3, 7);

            MyArray2[3] = "pipa";
            MyArray2[5] = "biba";
            MyArray2[7] = "boba";
            //for (int i = 3; i <= MyArray2.End; i++)
            //	Console.Write(MyArray2[i], " ");
            Console.WriteLine(MyArray2[3]);
            Console.WriteLine(MyArray2[5]);
            Console.WriteLine(MyArray2[7]);

            Console.ReadKey();
        }
        public void EjectingValuesFromArrayOutOfInilialRangeShouldCauseIndexOutOfCustomArrayRangeException(int a, int b, int exp)
        {
            //arrange
            FreeIndexArray <int> TestArray = new FreeIndexArray <int>(a, b);

            //act
            int i = TestArray[exp];
        }
        public void Add_ArrayIsFull_ThrowFreeIndexArrayIsFullException()
        {
            string firstItem  = "A";
            string secondItem = "B";

            array = new FreeIndexArray <string>(0, 0);
            array.Add(firstItem);
            array.Add(secondItem);
        }
        public void FreeIndexArray_IndexesMinusFiveAndSeven_MaxLengthIs13()
        {
            int maxLength;

            array     = new FreeIndexArray <string>(-5, 7);
            maxLength = array.MaxLength;

            Assert.AreEqual(13, maxLength);
        }
        public void     InitialisationOfArrayMustCreateCellForEveryElementInArray(int a, int b)
        {
            //arrange
            FreeIndexArray <int> TestArray = new FreeIndexArray <int>(a, b);
            int testint;

            //act
            for (int i = TestArray.Beg; i <= TestArray.End; i++)
            {
                testint = TestArray[i];
            }
        }
        public void TestConstructorWithBeginAndEndIndexes(int a, int b, int expBeg, int expEnd)
        {
            //arrange
            FreeIndexArray <int> TestArray = new FreeIndexArray <int>(a, b);

            //act
            int actualBeg = TestArray.Beg;
            int actualEnd = TestArray.End;

            //assert
            Assert.AreEqual(expBeg, actualBeg, "Start index of array is not correct");
            Assert.AreEqual(expEnd, actualEnd, "End index of array is not correct");
        }
Exemple #7
0
        static void Main(string[] args)
        {
            FreeIndexArray <int> arr = new FreeIndexArray <int>(-4, 2);

            arr.Add(11);
            arr.Add(12);
            arr.Add(13);
            arr.Add(14);

            var test = arr[-4];

            test = arr[-3];
            test = arr[-2];
            test = arr[-1];

            arr[-4] = 14;
            arr[-3] = 13;
            arr[-2] = 12;
            arr[-1] = 11;

            foreach (var a in arr)
            {
                Console.WriteLine(a);
            }

            Console.ReadKey();

            Console.WriteLine(arr.Contains(14));
            Console.WriteLine(arr.Contains(11));
            Console.WriteLine(arr.Contains(15));

            Console.ReadKey();

            Console.WriteLine(arr.Remove(14));
            Console.WriteLine(arr.Remove(11));

            Console.ReadKey();

            foreach (var a in arr)
            {
                Console.WriteLine(a);
            }

            Console.ReadKey();

            var array = new int[20];

            arr.CopyTo(array, 3);
        }
 public void FreeIndexArray_StopIndexLessStartIndex_ThrowFreeIndexArrayIndexValuesException()
 {
     array = new FreeIndexArray <string>(10, 0);
 }
 public void TestInitialize()
 {
     array = new FreeIndexArray <string>(-3, 2);
 }