public void ValidatesIndexOfMethodAndDoesNotReturnIndex()
        {
            var test = new ObjArrayCollection();

            test.Add(5);
            test.Add('b');
            Assert.Equal(-1, test.IndexOf(1000));
        }
        public void ValidatesContainMethodAndFindsElement()
        {
            var test = new ObjArrayCollection();

            test.Add("Andrei");
            test.Add(3);
            Assert.True(test.Contains("Andrei"));
        }
        public void ValidatesIndexOfMethodAndReturnsIndex()
        {
            var test = new ObjArrayCollection();

            test.Add(5);
            test.Add('b');
            Assert.Equal(1, test.IndexOf('b'));
        }
        public void ValidatesContainMethodAndDoesNotFindElement()
        {
            var test = new ObjArrayCollection();

            test.Add("Andrei");
            test.Add(3);
            Assert.False(test.Contains(2));
        }
        public void ValidatesSetElementMethod()
        {
            var test = new ObjArrayCollection();

            test.Add(5);
            test[0] = 'c';
            Assert.Equal('c', test[0]);
        }
        public void ValidatesRemoveAtMethod()
        {
            var test = new ObjArrayCollection();

            test.Add(5);
            test.Add(3);
            test.RemoveAt(0);
            Assert.Equal(3, test[0]);
        }
        public void ValidatesClearMethod()
        {
            var test = new ObjArrayCollection {
                5, 3
            };

            test.Clear();
            Assert.Equal(0, test.Count);
        }
        public void ValidatesConstructor()
        {
            var test = new ObjArrayCollection();

            Assert.Equal(0, test.Count);
            Assert.Null(test[0]);
            Assert.Null(test[1]);
            Assert.Null(test[2]);
            Assert.Null(test[3]);
        }
        public void ValidatesCountMethod()
        {
            var test = new ObjArrayCollection();

            test.Add(5);
            test.Add(3);
            test.Add(2);
            test.Add(6);
            test.Add(7);
            Assert.Equal(5, test.Count);
        }
        public void ValidatesInsertMethod()
        {
            var test = new ObjArrayCollection();

            test.Add(5);
            test.Add(3);
            test.Insert(0, "abc");
            Assert.Equal("abc", test[0]);
            Assert.Equal(5, test[1]);
            Assert.Equal(3, test[2]);
            Assert.Equal(3, test.Count);
        }
        public void ValidatesAddMethod()
        {
            var test = new ObjArrayCollection();

            test.Add("Abc");
            test.Add(3.02);
            test.Add('E');
            test.Add(6);
            test.Add(7);
            Assert.Equal("Abc", test[0]);
            Assert.Equal(3.02, test[1]);
            Assert.Equal('E', test[2]);
            Assert.Equal(6, test[3]);
            Assert.Equal(7, test[4]);
        }
Exemplo n.º 12
0
        public void TestEnumerator()
        {
            var test = new ObjArrayCollection {
                1, "Eu", 4.5, true, false, 'a'
            };
            var enumerator = test.GetEnumerator();

            enumerator.MoveNext();
            Assert.Equal(1, enumerator.Current());
            enumerator.MoveNext();
            Assert.Equal("Eu", enumerator.Current());

            enumerator.Reset();
            for (int i = 0; i < test.Count; i++)
            {
                enumerator.MoveNext();
            }

            Assert.Equal('a', enumerator.Current());
        }
Exemplo n.º 13
0
 public ObjectEnumerator(ObjArrayCollection obj)
 {
     objArray = obj;
 }