public void CreateGetterForClass()
        {
            var prop   = typeof(IInternalInterface).GetProperty("PublicProp");
            var getter = PropertyAccessorGenerator.CreateGetter(prop, false);
            var c      = new InternalClass {
                PublicProp = 321, StringProp = "some"
            };

            Assert.AreEqual(c.PublicProp, getter(c));

            var propWithPrivateGetter = typeof(InternalClass).GetProperty("PropWithPrivateGetter");
            var privateGetter         = PropertyAccessorGenerator.CreateGetter(propWithPrivateGetter, true);

            Assert.AreEqual(propWithPrivateGetter.GetValue(c, null), privateGetter(c));

            var stringProp   = typeof(InternalClass).GetProperty("StringProp");
            var stringGetter = PropertyAccessorGenerator.CreateGetter(stringProp, false);

            Assert.AreEqual(c.StringProp, stringGetter(c));

            c.StringProp = null;
            Assert.AreEqual(c.StringProp, stringGetter(c));
        }
        public void CreateGenericPropertySetterForClass()
        {
            var prop   = typeof(IInternalInterface).GetProperty("PublicProp");
            var setter = PropertyAccessorGenerator.CreateSetter <InternalClass, int>(prop, false);
            var c      = new InternalClass();

            setter(c, 123);
            Assert.AreEqual(123, c.PublicProp);

            var propWithPrivateSetter = typeof(InternalClass).GetProperty("PropWithPrivateSetter");
            var privateSetter         = PropertyAccessorGenerator.CreateSetter <InternalClass, int>(propWithPrivateSetter, true);

            privateSetter(c, 234);
            Assert.AreEqual(234, c.PropWithPrivateSetter);

            var stringProp   = typeof(InternalClass).GetProperty("StringProp");
            var stringSetter = PropertyAccessorGenerator.CreateSetter <InternalClass, string>(stringProp, false);

            stringSetter(c, "some string");
            Assert.AreEqual("some string", c.StringProp);

            stringSetter(c, null);
            Assert.AreEqual(null, c.StringProp);
        }