Пример #1
0
        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));
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }