Esempio n. 1
0
        public void IntMethod()
        {
            ReadWriteInts target = new ReadWriteInts();

            Assert.That(ValueSetter.CanSetValue(target, "IntMethod"), Is.True);
            ValueSetter.SetValue(target, "IntMethod", 123);
            Assert.That(target.IntMethod(), Is.EqualTo(123));
        }
Esempio n. 2
0
        public void IntFieldWithWrongCase()
        {
            ReadWriteInts target = new ReadWriteInts();

            Assert.That(ValueSetter.CanSetValue(target, "iNTfIELD"), Is.True);
            ValueSetter.SetValue(target, "iNTfIELD", 123);
            Assert.That(target.IntField, Is.EqualTo(123));
        }
Esempio n. 3
0
        public void IntField()
        {
            ReadWriteInts target = new ReadWriteInts();

            Assert.That(ValueSetter.GetValueType(target, "IntField"), Is.SameAs(typeof(int)));
            Assert.That(ValueSetter.CanSetValue(target, "IntField"), Is.True);
            ValueSetter.SetValue(target, "IntField", 123);
            Assert.That(target.IntField, Is.EqualTo(123));
        }
Esempio n. 4
0
        public void Invalid()
        {
            Assert.That(ValueSetter.CanSetValue(this, "x"), Is.False);
            ValueSetter setter = ValueSetter.GetValueSetter(this, "x");

            Assert.That(setter.CanSetValue(), Is.False);
            Assert.Throws(typeof(InvalidOperationException), delegate { setter.GetValueType(); });
            Assert.Throws(typeof(InvalidOperationException), delegate { setter.SetValue(null); });
        }
Esempio n. 5
0
        public void DataRowView()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("IntColumn", typeof(int));
            dt.Rows.Add(new object[] { 123 });
            DataRowView target = dt.DefaultView[0];

            Assert.That(ValueSetter.CanSetValue(target, "IntColumn"), Is.True);
            Assert.That(ValueSetter.GetValueType(target, "IntColumn"), Is.SameAs(typeof(int)));
            ValueSetter.SetValue(target, "IntColumn", 456);
            Assert.That((int)target["IntColumn"], Is.EqualTo(456));
        }
Esempio n. 6
0
 protected bool SetItemValue <TValue>(TValue value, [CallerMemberName] string propertyPath = "", [CallerMemberName] string propertyName = "")
 {
     return(ValueSetter <TValue> .SetValue(this, value, propertyPath, propertyName));
 }