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));
        }
Exemplo n.º 5
0
        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
            });
        }
Exemplo n.º 6
0
        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
            });
        }
Exemplo n.º 7
0
        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) { }
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 10
0
        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 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);
        }
Exemplo n.º 12
0
        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));
        }
Exemplo n.º 13
0
        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) { }
        }
Exemplo n.º 14
0
        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
            });
        }
Exemplo n.º 15
0
        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" }));
        }
Exemplo n.º 16
0
        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
            });
        }
Exemplo n.º 17
0
        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);
        }
Exemplo n.º 18
0
        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) { }
        }
Exemplo n.º 19
0
        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));
        }
Exemplo n.º 20
0
        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" } }));
        }