Beispiel #1
0
 public void NewList_CheckOrder_Remove45()
 {
     //arrange
     NewList<int> list = new NewList<int>();
     int numberRemoved = 45;
     int index = 8;
     int expected = 55;
     int actual;
     //act
     list.Add(5);
     list.Add(10);
     list.Add(15);
     list.Add(20);
     list.Add(25);
     list.Add(30);
     list.Add(35);
     list.Add(40);
     list.Add(45);
     list.Add(50);
     list.Add(55);
     list.Remove(45);
     list.Remove(70);
     list.Remove(30);
     actual = list[index];
     //assert
     Assert.AreEqual(expected, actual);
 }
Beispiel #2
0
 public void NewList_CheckCount_Remove45()
 {
     //arrange
     NewList<int> list = new NewList<int>();
     int expected = 8;
     int actual;
     //act
     list.Add(5);
     list.Add(10);
     list.Add(15);
     list.Add(20);
     list.Add(25);
     list.Add(30);
     list.Add(35);
     list.Add(40);
     list.Add(45);
     list.Add(50);
     list.Add(55);
     list.Remove(45);
     list.Remove(20);
     list.Remove(30);
     actual = list.Count;
     //assert
     Assert.AreEqual(expected, actual);
 }
Beispiel #3
0
        static void Main(string[] args)
        {
            MyList <int> NewInt = new MyList <int>();

            NewInt.Add(100);

            NewList.Remove();


            //List<Item> NewList = new List<Item>();
            //NewList.Add(1000);

            List <int> NewList = new List <int>();

            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine((NewList.Count + 1).ToString() + "Add");
                Console.WriteLine("Capa" + NewList.Capacity.ToString()); //배열의 크기
                Console.WriteLine("Capa" + NewList.Count.ToString());    //자료의 크기
                NewList.Add(i);
            }

            //내부에 자료가 있는지 없는지 확인하다.
            if (NewList.Contains(8))
            {
            }

            Console.WriteLine(NewList[5]);
        }
Beispiel #4
0
        public void Remove_NoExistingItemToRemove()
        {
            NewList <string> list = new NewList <string> {
                "vienas", "vienuolika"
            };
            var result1 = list.Count;
            var result  = list.Remove("vie");
            var result2 = list.Count;

            Assert.Equal(result1, result2);
            Assert.False(result);
        }
Beispiel #5
0
        public void Remove_ItemDeletionAtTheBeginningDoesNotDisturbArraySequence()
        {
            NewList <int> list = new NewList <int> {
                1, 2, 3
            };
            var           result     = list.Remove(1);
            NewList <int> secondList = new NewList <int> {
                2, 3
            };

            Assert.Equal(secondList, list);
            Assert.True(result);
        }
Beispiel #6
0
        public void Remove_ItemDeletionInTheMiddleDoesNotDisturbArraySequence()
        {
            NewList <int> list = new NewList <int> {
                1, 2, 3
            };
            var           result     = list.Remove(2);
            NewList <int> secondList = new NewList <int> {
                1, 3
            };

            Assert.Equal(secondList, list);
            Assert.True(result);
        }
Beispiel #7
0
 public void NewList_CheckString_IntsToStringRemoved()
 {
     //arrange
     NewList<int> list = new NewList<int>();
     string expected = "5, 15, 20, 25, 30, 40, 45, 10";
     string actual;
     //act
     list.Add(5);
     list.Add(10);
     list.Add(15);
     list.Add(20);
     list.Add(25);
     list.Add(30);
     list.Add(35);
     list.Add(40);
     list.Remove(35);
     list.Add(45);
     list.Remove(10);
     list.Add(10);
     actual = list.ToString();
     //assert
     Assert.AreEqual(expected, actual);
 }
Beispiel #8
0
 public void NewList_CheckCount_RemoveString()
 {
     //arrange
     NewList<string> list = new NewList<string>();
     int expected = 2;
     int actual;
     //act
     list.Add("Charles");
     list.Add("King");
     list.Add("Mangos");
     list.Remove("King");
     actual = list.Count;
     //assert
     Assert.AreEqual(expected, actual);
 }
Beispiel #9
0
        public void RegisterRemoved(T obj)
        {
            // remove from dirty list (nothing will happen even if the obj not inside the dirty list)
            DirtyList.Remove(obj);

            if (NewList.Contains(obj))
            {
                // if obj is newly created, not yet saved in db, then just remove it from new list
                NewList.Remove(obj);
            }
            else if (!RemovedList.Contains(obj))
            {
                // only add obj into removed list if its not already inside
                RemovedList.Add(obj);
            }
        }
Beispiel #10
0
 public void NewList_CheckCount_Remove15()
 {
     //arrange
     NewList<int> list = new NewList<int>();
     int numberRemoved = 15;
     int expected = 3;
     int actual;
     //act
     list.Add(5);
     list.Add(10);
     list.Add(15);
     list.Add(20);
     list.Remove(numberRemoved);
     actual = list.Count;
     //assert
     Assert.AreEqual(expected, actual);
 }
Beispiel #11
0
 public void NewList_CheckRemoved_Index2()
 {
     //arrange
     NewList<int> list = new NewList<int>();
     int numberRemoved = 15;
     int index = 2;
     int expected = 20;
     int actual;
     //act
     list.Add(5);
     list.Add(10);
     list.Add(15);
     list.Add(20);
     list.Remove(numberRemoved);
     actual = list[index];
     //assert
     Assert.AreEqual(expected, actual);
 }
Beispiel #12
0
        public void NewList_CheckCombinedList3_Operator()
        {
            NewList<int> one = new NewList<int>();
            NewList<int> two = new NewList<int>();
            string expected = "1, 3, 5, 9, 2, 4, 6, 10";
            string actual;

            one.Add(1);
            one.Add(3);
            one.Add(5);
            one.Add(7);
            one.Add(9);
            two.Add(2);
            two.Add(4);
            two.Add(6);
            two.Add(8);
            two.Add(10);
            one.Remove(7);
            two.Remove(8);
            NewList<int> three = one + two;
            actual = three.ToString();

            Assert.AreEqual(expected, actual);
        }