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]);
        }
Beispiel #2
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]);
        }
Beispiel #3
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);
        }
Beispiel #4
0
        public void CheckLengthAferInsertion()
        {
            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.Insert(1, 4);
            Assert.Equal(6, sut.Count);
        }
Beispiel #5
0
        public void InsertAndResize()
        {
            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(3, true);
            Assert.Equal(4, sut.IndexOf("string"));
        }
        public void InsertWhenPosition0ShouldReturnElementOnIndex0()
        {
            ObjectArrayCollection arrayTest = new ObjectArrayCollection();

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

            arrayTest.Insert(0, new int[4] {
                0, 1, 2, 3
            });

            Assert.Equal(4, arrayTest.Count);
            Assert.Equal(new int[4] {
                0, 1, 2, 3
            }, arrayTest[0]);
            Assert.Equal(1, arrayTest[1]);
            Assert.Equal('2', arrayTest[2]);
            Assert.Equal("3", arrayTest[3]);
        }
        public void InsertWhenPoistionOutOfBoundsShouldDoNothing()
        {
            ObjectArrayCollection arrayTest = new ObjectArrayCollection();

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

            arrayTest.Insert(3, new int[4] {
                0, 1, 2, 3
            });

            Assert.Equal(3, arrayTest.Count);
            Assert.False(arrayTest.Contains(new int[4] {
                0, 1, 2, 3
            }));
            Assert.Equal(1, arrayTest[0]);
            Assert.Equal('2', arrayTest[1]);
            Assert.Equal("3", arrayTest[2]);
        }
Beispiel #8
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));
        }