public void TestAttemptingToSetPropertyOfValueTypeInstance()
 {
     MyStruct myYearHolder = new MyStruct();
     IDynamicProperty year = Create( typeof( MyStruct ).GetProperty( "Year" ) );
     year.SetValue( myYearHolder, 2004 );
 }
Beispiel #2
0
        public void TestInstanceFields()
        {
            IDynamicField name = Create( typeof( Inventor ).GetField( "Name" ) );
            Assert.AreEqual( tesla.Name, name.GetValue( tesla ) );
            name.SetValue( tesla, "Tesla, Nikola" );
            Assert.AreEqual( "Tesla, Nikola", tesla.Name );
            Assert.AreEqual( "Tesla, Nikola", name.GetValue( tesla ) );

            MyStruct myYearHolder = new MyStruct();
            myYearHolder.Year = 2004;
            IDynamicField year = Create( typeof( MyStruct ).GetField( "year", BINDANY ) );
            Assert.AreEqual( 2004, year.GetValue( myYearHolder ) );
        }
        public void SetValue(object target, object value)
        {
            MyStruct o = (MyStruct)target;

            o.Year = (int)value;
        }
Beispiel #4
0
 public void TestAttemptingToSetFieldOfValueTypeInstance()
 {
     MyStruct myYearHolder = new MyStruct();
     IDynamicField year = Create( typeof( MyStruct ).GetField( "year" ) );
     year.SetValue( myYearHolder, 2004 );
 }
 public void TestAttemptingToSetPropertyOfValueTypeInstance()
 {
     MyStruct myYearHolder = new MyStruct();
     IDynamicProperty year = Create(typeof(MyStruct).GetProperty("Year"));
     Assert.Throws<InvalidOperationException>(() => year.SetValue(myYearHolder, 2004));
 }