Ejemplo n.º 1
0
        void TestForIndexOfInObjectArray()
        {
            var testObj = new ObjectArrayCollection();

            testObj.Add(1);
            testObj.Add("String");
            testObj.Add(123.123);

            Assert.Equal(0, testObj.IndexOf(1));
            Assert.Equal(1, testObj.IndexOf("String"));
            Assert.Equal(2, testObj.IndexOf(123.123));
            Assert.Equal(3, testObj.Count);
        }
Ejemplo n.º 2
0
        void TestForIndexAssignInObjectArray()
        {
            var testObj = new ObjectArrayCollection();

            testObj.Add(1);
            testObj.Add("String");
            testObj.Add(123.123);
            testObj[0] = "first";

            Assert.False(testObj.Contains(1));
            Assert.True(testObj.Contains("first"));
            Assert.Equal(0, testObj.IndexOf("first"));
            Assert.Equal(1, testObj.IndexOf("String"));
            Assert.Equal(2, testObj.IndexOf(123.123));
            Assert.Equal(3, testObj.Count);
        }
        public void IndexOfWhenNoExistsShouldReturnMinus1()
        {
            ObjectArrayCollection arrayTest = new ObjectArrayCollection();

            arrayTest.Add("test");

            Assert.Equal(-1, arrayTest.IndexOf("noTest"));
        }
        public void IndexOfWhenTextShouldReturn0()
        {
            ObjectArrayCollection arrayTest = new ObjectArrayCollection();

            arrayTest.Add("test");

            Assert.Equal(0, arrayTest.IndexOf("test"));
        }
Ejemplo n.º 5
0
        public void TestInsertObjectMixedArray()
        {
            var array = new ObjectArrayCollection {
                (object)true, (object)false,
                (object)"string", (object)null,
                (object)string.Empty, (object)int.MaxValue,
                (object)float.MaxValue
            };


            array.Insert(1, 4);
            array.Insert(4, string.Empty);

            Assert.False(array.Contains("string2"));
            Assert.True(array.Contains(null));
            Assert.Equal(0, array.IndexOf(true));
            Assert.Equal(1, array.IndexOf(4));
            Assert.Equal(9, array.Count);
            Assert.Equal(float.MaxValue, array[array.Count - 1]);
        }
Ejemplo n.º 6
0
        void TestForIndexOfNotPresentInObjectArray()
        {
            var testObj = new ObjectArrayCollection();

            testObj.Add(1);
            testObj.Add("String");
            testObj.Add(123.123);

            Assert.Equal(-1, testObj.IndexOf(23.23));
            Assert.Equal(3, testObj.Count);
        }
Ejemplo n.º 7
0
        public void TestIndexOfBooleanInObjectArray()
        {
            var objectArray = new ObjectArrayCollection();

            objectArray.Add(true);
            objectArray.Add(false);

            Assert.False(objectArray.Contains("test"));
            Assert.False(objectArray.Contains(null));
            Assert.Equal(0, objectArray.IndexOf(true));
        }
Ejemplo n.º 8
0
        public void TestInsertObjectsInObjectArray()
        {
            var objectArray = new ObjectArrayCollection();

            objectArray.Add(true);
            objectArray.Add(false);
            objectArray.Add("string");
            objectArray.Add(null);
            objectArray.Add(string.Empty);
            objectArray.Add(int.MinValue);
            objectArray.Insert(1, 1);
            objectArray.Insert(4, string.Empty);
            objectArray.Insert(5, "string2");
            objectArray[9] = int.MaxValue;

            Assert.False(objectArray.Contains("test"));
            Assert.Equal(0, objectArray.IndexOf(true));
            Assert.Equal(1, objectArray.IndexOf(1));
            Assert.Equal(9, objectArray.Count);
            Assert.Null(objectArray[6]);
        }
Ejemplo n.º 9
0
        void TestForInsertInObjectArray()
        {
            var testObj = new ObjectArrayCollection();

            testObj.Add(1);
            testObj.Add("String");
            testObj.Add(123.123);
            testObj.Insert(2, "Inserted String");

            Assert.True(testObj.Contains("Inserted String"));
            Assert.Equal(2, testObj.IndexOf("Inserted String"));
            Assert.Equal(4, testObj.Count);
        }
        public void RemoveWhen1AndMoreThanOne1ShouldReturnReturnTrueForContainsAnd2ForIndexOf()
        {
            ObjectArrayCollection arrayTest = new ObjectArrayCollection();

            arrayTest.Add(1);
            arrayTest.Add('2');
            arrayTest.Add("3");
            arrayTest.Add(1);

            arrayTest.Remove(1);

            Assert.True(arrayTest.Contains(1));
            Assert.Equal(2, arrayTest.IndexOf(1));
        }
Ejemplo n.º 11
0
        public void IndexOfElement()
        {
            var intArr = new int[] { 2, 3, 4 };
            var sut    = new ObjectArrayCollection();

            sut.Add(0);
            sut.Add(true);
            sut.Add(3.4647);
            sut.Add("string");
            sut.Add(intArr);
            sut.Add(6);
            sut.Add(0);
            sut.Add(8);
            sut.Add(9);
            sut.Add(10);

            Assert.Equal(3, sut.IndexOf("string"));
        }
Ejemplo n.º 12
0
        public void TestForNumeratorInObjectArrayColection()
        {
            var array = new ObjectArrayCollection {
                (object)true, (object)false,
                (object)"string", (object)null,
                (object)string.Empty, (object)int.MaxValue,
                (object)float.MaxValue
            };

            var numerator = array.GetEnumerator();

            numerator.MoveNext();
            numerator.MoveNext();
            numerator.MoveNext();
            var current = numerator.Current;

            Assert.Equal("string", current);
            Assert.Equal(6, array.IndexOf(float.MaxValue));
            Assert.Equal(7, array.Count);
        }
Ejemplo n.º 13
0
        public void IndexOfElementNotFound()
        {
            string str    = "abc";
            object s      = str;
            var    intArr = new int[] { 2, 3, 4 };
            var    sut    = new ObjectArrayCollection();

            sut.Add(0);
            sut.Add(true);
            sut.Add(3.4647);
            sut.Add("string");
            sut.Add(intArr);
            sut.Add(6);
            sut.Add(0);
            sut.Add(8);
            sut.Add(9);
            sut.Add(10);

            Assert.Equal(-1, sut.IndexOf(s));
        }
Ejemplo n.º 14
0
        public void IndexOfElement()
        {
            int    val      = 9;
            object objValue = val;
            var    sut      = new ObjectArrayCollection();
            var    intArr   = new int[] { 2, 3, 4 };

            sut.Add(0);
            sut.Add(true);
            sut.Add(3.4647);
            sut.Add("string");
            sut.Add(intArr);
            sut.Add(6);
            sut.Add(0);
            sut.Add(8);
            sut.Add(9);
            sut.Add(10);
            sut.Insert(1, objValue);
            Assert.Equal(1, sut.IndexOf(objValue));
        }
Ejemplo n.º 15
0
        public void TestForNumerator_Move_Next_InObjectArrayColectionOutOfIndex()
        {
            var array = new ObjectArrayCollection {
                (object)true, (object)false,
                (object)"string", (object)null,
                (object)string.Empty, (object)int.MaxValue,
                (object)float.MaxValue
            };

            var numerator = array.GetEnumerator();

            for (int i = 0; i < 10; i++)
            {
                numerator.MoveNext();
            }

            var current = numerator.Current;

            Assert.Equal(array[array.Count - 1], current);
            Assert.Equal(6, array.IndexOf(float.MaxValue));
            Assert.Equal(7, array.Count);
        }