public void GetFieldGetterDelegate_should_return_getter_if_exists() { // Arrange var target = new ClassWithNonPublicField(); // Act var get_m_value = typeof(ClassWithNonPublicField).GetFieldGetterDelegate("m_value"); target.Value = 42; // Assert Assert.AreEqual(42, get_m_value(target, null)); }
public void GetFieldSetterDelegate_should_return_setter_if_exists() { // Arrange var target = new ClassWithNonPublicField(); // Act var set_m_value = typeof(ClassWithNonPublicField).GetFieldSetterDelegate("m_value"); set_m_value(target, new object[] { 42 }); // Assert Assert.AreEqual(42, target.Value); }
public void GetMemberDelegate_should_return_field_setter_if_condition_for_its_field_is_passed() { // Arrange var target = new ClassWithNonPublicField(); // Act var actual = typeof(ClassWithNonPublicField).GetMemberDelegate("m_value", Type.EmptyTypes); actual(target, new object[] { 42 }); // Assert Assert.AreEqual(42, target.Value); }