Пример #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));
        }
Пример #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));
        }
Пример #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));
        }
Пример #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); });
        }
Пример #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));
        }
Пример #6
0
        public void ReadOnlyIntMethod()
        {
            ReadOnlyInts target = new ReadOnlyInts();

            Assert.That(ValueSetter.CanSetValue(target, "IntMethod"), Is.False);
        }