GetAllValues() public method

public GetAllValues ( ) : object[]
return object[]
        public static void GetAllValues_Invalid()
        {
            MyNameObjectCollection nameObjectCollection = new MyNameObjectCollection();
            Assert.Throws<ArgumentNullException>("type", () => nameObjectCollection.GetAllValues(null));

            nameObjectCollection.Add("name", new Foo("value"));
            Assert.Throws<ArrayTypeMismatchException>(() => nameObjectCollection.GetAllValues(typeof(string)));
        }
        public static void GetAllValues_Invalid()
        {
            MyNameObjectCollection nameObjectCollection = new MyNameObjectCollection();

            AssertExtensions.Throws <ArgumentNullException>("type", () => nameObjectCollection.GetAllValues(null));

            nameObjectCollection.Add("name", new Foo("value"));
            Assert.Throws <ArrayTypeMismatchException>(() => nameObjectCollection.GetAllValues(typeof(string)));
        }
        public void GetAllValues(int count, Type type)
        {
            MyNameObjectCollection nameObjectCollection = Helpers.CreateNameObjectCollection(count);

            if (type == typeof(object))
            {
                VerifyGetAllValues(nameObjectCollection, nameObjectCollection.GetAllValues());
            }
            VerifyGetAllValues(nameObjectCollection, nameObjectCollection.GetAllValues(type));
        }
Exemplo n.º 4
0
        public void Test01()
        {
            MyNameObjectCollection noc;

            Object[] objarray;
            Foo[]    fooarray;


            // [] GetAllValues() on empty collection
            noc      = new MyNameObjectCollection();
            objarray = noc.GetAllValues();
            CheckObjArray(objarray, noc);
            // [] GetAllValues() on non-empty collection
            noc = new MyNameObjectCollection();
            for (int i = 0; i < 15; i++)
            {
                noc.Add("str_" + i.ToString(), new Foo());
            }
            objarray = noc.GetAllValues();
            CheckObjArray(objarray, noc);

            // [] GetAllValues(Type) on empty collection
            _strErr  = "Err_003, ";
            noc      = new MyNameObjectCollection();
            fooarray = (Foo[])noc.GetAllValues(typeof(Foo));
            CheckFooArray(fooarray, noc);

            // [] GetAllValues(Type) on non-empty collection
            noc = new MyNameObjectCollection();
            for (int i = 0; i < 15; i++)
            {
                noc.Add("str_" + i.ToString(), new Foo());
            }
            fooarray = (Foo[])noc.GetAllValues(typeof(Foo));
            CheckFooArray(fooarray, noc);

            // [] GetAllValues(Type) with incompatible type
            noc = new MyNameObjectCollection();
            for (int i = 0; i < 15; i++)
            {
                noc.Add("str_" + i.ToString(), new Foo());
            }

            Assert.Throws <ArrayTypeMismatchException>(() => { Array array = noc.GetAllValues(typeof(String)); });
        }
Exemplo n.º 5
0
        public void Test01()
        {
            MyNameObjectCollection noc;
            Object[] objarray;
            Foo[] fooarray;


            // [] GetAllValues() on empty collection
            noc = new MyNameObjectCollection();
            objarray = noc.GetAllValues();
            CheckObjArray(objarray, noc);
            // [] GetAllValues() on non-empty collection
            noc = new MyNameObjectCollection();
            for (int i = 0; i < 15; i++)
            {
                noc.Add("str_" + i.ToString(), new Foo());
            }
            objarray = noc.GetAllValues();
            CheckObjArray(objarray, noc);

            // [] GetAllValues(Type) on empty collection
            _strErr = "Err_003, ";
            noc = new MyNameObjectCollection();
            fooarray = (Foo[])noc.GetAllValues(typeof(Foo));
            CheckFooArray(fooarray, noc);

            // [] GetAllValues(Type) on non-empty collection
            noc = new MyNameObjectCollection();
            for (int i = 0; i < 15; i++)
            {
                noc.Add("str_" + i.ToString(), new Foo());
            }
            fooarray = (Foo[])noc.GetAllValues(typeof(Foo));
            CheckFooArray(fooarray, noc);

            // [] GetAllValues(Type) with incompatible type
            noc = new MyNameObjectCollection();
            for (int i = 0; i < 15; i++)
            {
                noc.Add("str_" + i.ToString(), new Foo());
            }

            Assert.Throws<ArrayTypeMismatchException>(() => { Array array = noc.GetAllValues(typeof(String)); });
        }
Exemplo n.º 6
0
        public static void TestGetAllValues_NullType_Throws()
        {
            var nameObjectCollection = new MyNameObjectCollection();

            Assert.Throws <ArgumentNullException>("type", () => nameObjectCollection.GetAllValues(null));
        }
Exemplo n.º 7
0
 public static void TestGetAllValues_NullType_Throws()
 {
     var nameObjectCollection = new MyNameObjectCollection();
     Assert.Throws<ArgumentNullException>("type", () => nameObjectCollection.GetAllValues(null));
 }