public void CanSetPrivateFieldIninstanceOfObject() { Person p = new Person(); SetInstanceFieldValue(p, PERSON_TEST_FIELD_NAME, PERSON_TEST_FIELD_VALUE); Assert.AreEqual(PERSON_TEST_FIELD_VALUE, p.Firstname); }
public void CanThrowExceptionOnFieldnameNotFoundInObject() { try { Person p = new Person(); SetInstanceFieldValue(p, String.Format("{0}zzz", PERSON_TEST_FIELD_NAME), PERSON_TEST_FIELD_VALUE); Assert.Fail("Expected Exception of type 'InvalidOperationException 'not thrown."); } catch (ArgumentException) { } }
public void CanThrowExceptionWhenSettingFieldToInvalidType() { try { Person p = new Person(); SetInstanceFieldValue(p, PERSON_TEST_FIELD_NAME, new Person()); Assert.Fail("Expected Exception of type 'ArgumentException' not thrown."); } catch (ArgumentException) { } }
public void CanGetPrivateFieldInInstanceOfObject() { Person p = new Person { Firstname = PERSON_TEST_FIELD_VALUE }; Assert.AreEqual(PERSON_TEST_FIELD_VALUE, GetInstanceFieldValue(p, PERSON_TEST_FIELD_NAME)); }