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)); }
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)); }); }
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)); }); }
public static void TestGetAllValues_NullType_Throws() { var nameObjectCollection = new MyNameObjectCollection(); Assert.Throws <ArgumentNullException>("type", () => nameObjectCollection.GetAllValues(null)); }
public static void TestGetAllValues_NullType_Throws() { var nameObjectCollection = new MyNameObjectCollection(); Assert.Throws<ArgumentNullException>("type", () => nameObjectCollection.GetAllValues(null)); }