Esempio n. 1
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. 2
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. 3
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));
        }