示例#1
0
        public void ContainsTest()
        {
            list.Add(7);
            list.Add(9);

            Assert.AreEqual(true, list.Contains(9));
            Assert.AreEqual(false, list.Contains(22));
        }
示例#2
0
        static void TestMyArrayList()
        {
            MyArrayList <string> temp = new MyArrayList <string>();

            temp.Add("fuck1");
            temp.Add("fuck2");
            temp.Add("fuck3");
            temp.Add("fuck4");
            temp.Add("fuckall");

            temp.RemoveAt(3);

            for (int i = 0; i < temp.Count; i++)
            {
                Console.WriteLine(temp[i]);
            }

            Console.WriteLine("Contains fuck4: " + temp.Contains("fuck4") + temp.Find("fuck4"));
            Console.WriteLine("Contains fuck3: " + temp.Contains("fuck3") + temp.Find("fuck3"));

            temp.Insert(3, "fuck4");

            Console.WriteLine("Contains fuck4: " + temp.Contains("fuck4") + temp.Find("fuck4"));
            Console.WriteLine("Contains fuck3: " + temp.Contains("fuck3") + temp.Find("fuck3"));

            for (int i = 0; i < temp.Count; i++)
            {
                Console.WriteLine(temp[i]);
            }

            temp.Reverse();

            for (int i = 0; i < temp.Count; i++)
            {
                Console.WriteLine(temp[i]);
            }

            temp.Insert(3, "fuckbbb");
            temp.Sort();

            for (int i = 0; i < temp.Count; i++)
            {
                Console.WriteLine(temp[i]);
            }

            temp.Clear();

            for (int i = 0; i < temp.Count; i++)
            {
                Console.WriteLine(temp[i]);
            }
        }
示例#3
0
        public void Should_check_if_contains_element()
        {
            var arrayList = new MyArrayList();

            arrayList.Add("test");
            arrayList.Add(5);

            var contains     = arrayList.Contains("test");
            var dontContains = arrayList.Contains(1);

            Assert.True(contains);
            Assert.False(dontContains);
        }
        public void ContainTest()
        {
            MyList <int> List = new MyArrayList <int>();

            List.Add(31);
            List.Add(9);
            Assert.AreEqual(List.Contains(31), true);
        }
        public void NotContainTest()
        {
            MyList <int> List = new MyArrayList <int>();

            List.Add(31);
            List.Add(9);
            Assert.AreEqual(List.Contains(63), false);
        }
        public void RemoveExistingElementTest()
        {
            MyList <int> List = new MyArrayList <int>();

            List.Add(75);
            List.Add(57);
            List.Add(50);
            Assert.AreEqual(List.Remove(57), true);
            Assert.AreEqual(List.Contains(57), false);
        }
示例#7
0
        public void Should_Contains_True_With_Null_Items()
        {
            //arrange
            var list = new MyArrayList(5);

            list.Add(null);
            list.Add(2);
            list.Add(3);

            //act
            var result = list.Contains(2);

            //assert
            result.ShouldBeEquivalentTo(true);
        }
示例#8
0
        public void Should_Contains_False()
        {
            //arrange
            var list = new MyArrayList(5);

            list.Add(1);
            list.Add(2);
            list.Add(3);

            //act
            var result = list.Contains(5);

            //assert
            result.ShouldBeEquivalentTo(false);
        }
 public void NotContainTest()
 {
     MyList<int> List = new MyArrayList<int>();
     List.Add(31);
     List.Add(9);
     Assert.AreEqual(List.Contains(63), false);
 }
 public void ContainTest()
 {
     MyList<int> List = new MyArrayList<int>();
     List.Add(31);
     List.Add(9);
     Assert.AreEqual(List.Contains(31), true);
 }
 public void RemoveExistingElementTest()
 {
     MyList<int> List = new MyArrayList<int>();
     List.Add(75);
     List.Add(57);
     List.Add(50);
     Assert.AreEqual(List.Remove(57), true);
     Assert.AreEqual(List.Contains(57), false);
 }
示例#12
0
 public void TestContainer()
 {
     Assert.AreEqual(true, list.Contains(2));
 }
示例#13
0
        public bool ContainsTest(int val)
        {
            MyArrayList myAL = new MyArrayList(new int[] { 0, 1, 2, 5, 6, 0 });

            return(myAL.Contains(val));
        }
示例#14
0
        public void Should_throw_ArgumentOutOfRangeException_when_calling_contains_with_null()
        {
            var arrayListTarget = new MyArrayList();

            Assert.Throws <ArgumentOutOfRangeException>(() => arrayListTarget.Contains(null));
        }