public static void SetValue_ThrowsArgumentException(string propertyName, object setValue, object[] index) { TypeWithProperties obj = new TypeWithProperties(); PropertyInfo pi = typeof(TypeWithProperties).GetTypeInfo().GetProperty(propertyName); Assert.Equal(propertyName, pi.Name); Assert.Throws <ArgumentException>(() => pi.SetValue(obj, setValue, index)); }
public static void TestSetValue12() { string propertyName = "Item"; TypeWithProperties twpObj = new TypeWithProperties(); PropertyInfo pi = getProperty(typeof(TypeWithProperties), propertyName); Assert.Equal(pi.Name, propertyName); Assert.ThrowsAny <Exception>(() => pi.SetValue(null, "pw", new Object[] { 99, 2, "SOME string" })); }
public static void SetValue_IndexerProperty_IncorrectNumberOfParameters_ThrowsTargetParameterCountException() { string propertyName = "Item"; TypeWithProperties obj = new TypeWithProperties(); PropertyInfo pi = typeof(TypeWithProperties).GetTypeInfo().GetProperty(propertyName); Assert.Equal(propertyName, pi.Name); Assert.Throws <TargetParameterCountException>(() => pi.SetValue(obj, "pw", new object[] { 99, 2, new string[] { "SOME string" } })); }
public static void TestSetValue7() { string propertyName = "hassetterprop"; TypeWithProperties twpObj = new TypeWithProperties(); PropertyInfo pi = getProperty(typeof(TypeWithProperties), propertyName); Assert.Equal(pi.Name, propertyName); // Generic Exception is thrown in WP8 instead of TargetException Assert.ThrowsAny <Exception>(() => pi.SetValue(twpObj, "foo", null)); }
public static void TestSetValue11() { string propertyName = "Item"; TypeWithProperties twpObj = new TypeWithProperties(); PropertyInfo pi = getProperty(typeof(TypeWithProperties), propertyName); Assert.Equal(pi.Name, propertyName); Assert.Throws <TargetParameterCountException>(() => { pi.SetValue(twpObj, "pw", new Object[] { 99, 2, new String[] { "SOME string" } }); // Incorrect number of parameters }); }
public static void TestSetValue10() { string propertyName = "Item"; TypeWithProperties twpObj = new TypeWithProperties(); PropertyInfo pi = getProperty(typeof(TypeWithProperties), propertyName); string h = "hello"; Assert.Equal(pi.Name, propertyName); Assert.Throws <ArgumentException>(() => { pi.SetValue(twpObj, "pw", new Object[] { 99, 2, h, "SOME string" }); // Incorrect Type for h }); }
public static void TestSetValue12() { string propertyName = "Item"; TypeWithProperties twpObj = new TypeWithProperties(); PropertyInfo pi = getProperty(typeof(TypeWithProperties), propertyName); Assert.Equal(pi.Name, propertyName); try { pi.SetValue(null, "pw", new Object[] { 99, 2, "SOME string" }); Assert.False(true); } catch (Exception) { } }
public static void TestSetValue9() { string propertyName = "Item"; TypeWithProperties twpObj = new TypeWithProperties(); PropertyInfo pi = getProperty(typeof(TypeWithProperties), propertyName); string[] h = { "hello" }; Assert.Equal(pi.Name, propertyName); pi.SetValue(twpObj, "pw", new Object[] { 99, 2, h, "SOME string" }); Assert.Equal("992SOME string1pw", twpObj.setValue); }
public static void SetValue_Item() { string propertyName = "Item"; TypeWithProperties obj = new TypeWithProperties(); PropertyInfo pi = typeof(TypeWithProperties).GetTypeInfo().GetProperty(propertyName); string[] h = { "hello" }; Assert.Equal(pi.Name, propertyName); pi.SetValue(obj, "someotherstring", new object[] { 99, 2, h, "f" }); Assert.Equal("992f1someotherstring", obj.setValue); pi.SetValue(obj, "pw", new object[] { 99, 2, h, "SOME string" }); Assert.Equal("992SOME string1pw", obj.setValue); }
public static void TestSetValue7() { string propertyName = "hassetterprop"; TypeWithProperties twpObj = new TypeWithProperties(); PropertyInfo pi = getProperty(typeof(TypeWithProperties), propertyName); Assert.Equal(pi.Name, propertyName); // Generic Exception is thrown in WP8 instead of TargetException try { pi.SetValue(twpObj, "foo", null); Assert.False(true); } catch (Exception) { } }
public static void TestSetValue7() { string propertyName = "hassetterprop"; TypeWithProperties twpObj = new TypeWithProperties(); PropertyInfo pi = getProperty(typeof(TypeWithProperties), propertyName); Assert.Equal(pi.Name, propertyName); // Generic Exception is thrown in WP8 instead of TargetException Assert.ThrowsAny<Exception>(() => pi.SetValue(twpObj, "foo", null)); }
public static void TestSetValue13() { string propertyName = "Item"; TypeWithProperties twpObj = new TypeWithProperties(); PropertyInfo pi = getProperty(typeof(TypeWithProperties), propertyName); string[] h = { "hello" }; Assert.Equal(pi.Name, propertyName); Assert.Throws<ArgumentException>(() => { pi.SetValue(twpObj, 100, new Object[] { 99, 2, h, "SOME string" }); // iuncorrect type for value }); }
public static void TestSetValue12() { string propertyName = "Item"; TypeWithProperties twpObj = new TypeWithProperties(); PropertyInfo pi = getProperty(typeof(TypeWithProperties), propertyName); Assert.Equal(pi.Name, propertyName); Assert.ThrowsAny<Exception>(() => pi.SetValue(null, "pw", new Object[] { 99, 2, "SOME string" })); }
public static void TestSetValue11() { string propertyName = "Item"; TypeWithProperties twpObj = new TypeWithProperties(); PropertyInfo pi = getProperty(typeof(TypeWithProperties), propertyName); Assert.Equal(pi.Name, propertyName); Assert.Throws<TargetParameterCountException>(() => { pi.SetValue(twpObj, "pw", new Object[] { 99, 2, new String[] { "SOME string" } }); // Incorrect number of parameters }); }
public static void SetValue_ThrowsArgumentException(string propertyName, object setValue, object[] index) { TypeWithProperties obj = new TypeWithProperties(); PropertyInfo pi = typeof(TypeWithProperties).GetTypeInfo().GetProperty(propertyName); Assert.Equal(propertyName, pi.Name); Assert.Throws<ArgumentException>(() => pi.SetValue(obj, setValue, index)); }
public static void SetValue_IndexerProperty_IncorrectNumberOfParameters_ThrowsTargetParameterCountException() { string propertyName = "Item"; TypeWithProperties obj = new TypeWithProperties(); PropertyInfo pi = typeof(TypeWithProperties).GetTypeInfo().GetProperty(propertyName); Assert.Equal(propertyName, pi.Name); Assert.Throws<TargetParameterCountException>(() => pi.SetValue(obj, "pw", new object[] { 99, 2, new string[] { "SOME string" } })); }