Пример #1
0
        public void Swap()
        {
            //Test of Swap<T>(ref T first, ref T second)
            int a = 1, aCopy = a;
            int b = 2, bCopy = b;

            MapGeneratorUtils.Swap(ref a, ref b);
            Assert.AreEqual(b, aCopy);
            Assert.AreEqual(a, bCopy);

            //Test of Swap<T>(IList<T> collection, int firstIndex, int secondIndex)
            string        l1 = "a", l2 = "b", l3 = "c";
            List <string> list = new List <string>();

            list.Add(l1);
            list.Add(l2);
            list.Add(l3);

            MapGeneratorUtils.Swap(list, 0, 2);
            Assert.AreEqual(list[0], l3);
            Assert.AreEqual(list[2], l1);
        }