예제 #1
0
        public void CompleteTests()
        {
            var array = new IntList();

            Assert.Equal(0, array.Count);

            array = AddArray(1, 2, 3, 4);
            Assert.Equal(4, array.Count);

            array.Add(5);
            Assert.Equal(5, array.Count);
            Assert.Equal(5, array[4]);

            array[4] = 220;
            Assert.Equal(220, array[4]);

            Assert.True(array.Contains(3));
            Assert.False(array.Contains(10));

            Assert.Equal(-1, array.IndexOf(100));

            array.Insert(5, 100);
            Assert.Equal(5, array.IndexOf(100));
            Assert.Equal(6, array.Count);

            array.Remove(100);
            Assert.Equal(-1, array.IndexOf(100));
            Assert.Equal(5, array.Count);


            array.RemoveAt(4);
            Assert.Equal(4, array[3]);
            Assert.Equal(4, array.Count);
        }
예제 #2
0
        public void Test_Remove_Should_Correctly_Remove_Element_Simple_Array()
        {
            //Given
            IntList array = AddedArray(1, 2, 3, 4);

            //When
            array.Remove(3);
            //Then
            Assert.Equal(2, array.IndexOf(4));
            Assert.Equal(-1, array.IndexOf(3));
            Assert.Equal(3, array.Count);
        }
예제 #3
0
        public void Test_Insert_Should_Correctly_Insert_Element_Array_Has_Exactly_3_elements()
        {
            //Given
            IntList array = AddedArray(1, 2, 3);

            //When
            array.Insert(1, 100);
            //Then
            array.Add(10);
            Assert.Equal(1, array.IndexOf(100));
            Assert.Equal(3, array.IndexOf(3));
            Assert.Equal(5, array.Count);
        }
예제 #4
0
        public ActionResult GetStandardsByIds(IntList ids)
        {
            var standards = SchoolLocator.StandardService
                            .GetStandards(ids)
                            .OrderBy(np => ids.IndexOf(np.Id))
                            .ToList();

            return(Json(standards.Select(StandardViewData.Create)));
        }
예제 #5
0
        public void Test_Insert_Should_Correctly_Insert_Element_when_Array_Is_Longer_Then_4()
        {
            //Given
            IntList array = AddedArray(1, 2, 3, 4, 5, 6, 7, 8);

            //When
            array.Insert(5, 100);
            //Then
            Assert.Equal(5, array.IndexOf(100));
        }
예제 #6
0
        public void Test_Insert_Should_Correctly_Insert_Element_when_Array_Is_Shorter_Then_4()
        {
            //Given
            IntList array = AddedArray(1, 2, 3);

            //When
            array.Insert(1, 5);
            //Then
            Assert.Equal(1, array.IndexOf(5));
        }
예제 #7
0
        public void TestIndexOf()
        {
            IntList list = new IntList();

            for (int j = 0; j < 1000; j++)
            {
                list.Add(j / 2);
            }
            for (int j = 0; j < 1000; j++)
            {
                if (j < 500)
                {
                    Assert.AreEqual(j * 2, list.IndexOf(j));
                }
                else
                {
                    Assert.AreEqual(-1, list.IndexOf(j));
                }
            }
        }
예제 #8
0
        public void Test_RemoveAt_Should_Correctly_Remove_Element_Index_Is_1()
        {
            //Given
            IntList array = AddedArray(1, 2, 3);

            //When
            array.RemoveAt(1);
            //Then
            Assert.Equal(-1, array.IndexOf(2));
            Assert.Equal(2, array.Count);
        }
예제 #9
0
        public void Test_Remove_Should_Correctly_Remove_Element_1_Element_Array()
        {
            //Given
            IntList array = AddedArray(1);

            //When
            array.Remove(1);
            //Then
            Assert.Equal(-1, array.IndexOf(1));
            Assert.Equal(0, array.Count);
        }
예제 #10
0
        public void Test_Insert_Should_Correctly_Insert_Element_1_element_array()
        {
            //Given
            IntList array = AddedArray(1);

            //When
            array.Insert(0, 100);
            //Then
            Assert.Equal(0, array.IndexOf(100));
            Assert.Equal(2, array.Count);
        }
예제 #11
0
        public void Test_Insert_Should_Correctly_Insert_Element_At_Last_Position()
        {
            //Given
            IntList array = AddedArray(1, 2, 3, 4);

            //When
            array.Insert(3, 100);
            //Then
            Assert.Equal(3, array.IndexOf(100));
            Assert.Equal(5, array.Count);
        }
예제 #12
0
        public void Test_Clear_Should_Remove_all_elements_More_Then_4_elements_Array()
        {
            //Given
            IntList array = AddedArray(1, 2, 3, 4, 5, 6);

            //When
            array.Clear();
            //Then
            Assert.Equal(0, array.Count);
            Assert.Equal(-1, array.IndexOf(6));
        }
예제 #13
0
 static public int IndexOf(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 2)
         {
             IntList      self = (IntList)checkSelf(l);
             System.Int32 a1;
             checkType(l, 2, out a1);
             var ret = self.IndexOf(a1);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         else if (argc == 3)
         {
             IntList      self = (IntList)checkSelf(l);
             System.Int32 a1;
             checkType(l, 2, out a1);
             System.Int32 a2;
             checkType(l, 3, out a2);
             var ret = self.IndexOf(a1, a2);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         else if (argc == 4)
         {
             IntList      self = (IntList)checkSelf(l);
             System.Int32 a1;
             checkType(l, 2, out a1);
             System.Int32 a2;
             checkType(l, 3, out a2);
             System.Int32 a3;
             checkType(l, 4, out a3);
             var ret = self.IndexOf(a1, a2, a3);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #14
0
        public void Test_IndexOf_Should_Return_Negative_When_Array_Does_NotContains_Given_Element()
        {
            IntList array = AddedArray(1, 2, 3, 4, 5, 6);

            Assert.Equal(-1, array.IndexOf(100));
        }
예제 #15
0
        public void Test_IndexOf_Should_Return_Correct_Index_When_Array_Contains_2_Elements()
        {
            IntList array = AddedArray(2, 1);

            Assert.Equal(0, array.IndexOf(2));
        }
예제 #16
0
        public void Test_IndexOf_Should_Return_Correct_Index_When_Array_Contains_Given_Element()
        {
            IntList array = AddedArray(1, 2, 3, 4, 5, 6);

            Assert.Equal(3, array.IndexOf(4));
        }