Esempio n. 1
0
        public void TestAppendElementToArray()
        {
            var arr = new int[3] {
                1, 2, 3
            };

            Lib.AppendElementToArray <int>(ref arr, 4);

            Assert.AreEqual <int>(4, arr.Length, "Length of resultant array is wrong");
            Assert.AreEqual <int>(1, arr[0], "Index 0 is incorrect");
            Assert.AreEqual <int>(2, arr[1], "Index 1 is incorrect");
            Assert.AreEqual <int>(3, arr[2], "Index 2 is incorrect");
            Assert.AreEqual <int>(4, arr[3], "Index 3 is incorrect");

            arr = null;
            Lib.AppendElementToArray <int>(ref arr, 111);
            Assert.AreEqual <int>(1, arr.Length, "New length from NULL array is incorrect");
            Assert.AreEqual <int>(111, arr[0], "Added element is incorrect from NULL array");
        }