コード例 #1
0
        public void Should_be_able_to_access_a_private_setter()
        {
            var instance = new PrivateSetter();

            PropertyInfo property = instance.GetType()
                .GetProperties(BindingFlags.Instance | BindingFlags.Public)
                .Where(x => x.Name == "Name")
                .First();

            var fastProperty = new ReadWriteProperty<PrivateSetter>(property, true);

            const string expectedValue = "Chris";
            fastProperty.Set(instance, expectedValue);

            Assert.AreEqual(expectedValue, fastProperty.Get(instance));
        }
コード例 #2
0
        public void Should_be_able_to_access_a_private_setter()
        {
            var instance = new PrivateSetter();

            var property = instance
                           .GetType()
                           .GetProperties(BindingFlags.Instance | BindingFlags.Public)
                           .First(x => x.Name == "Name");


            var fastProperty = new ReadWriteProperty <PrivateSetter>(property);

            const string expectedValue = "Chris";

            fastProperty.Set(instance, expectedValue);

            Assert.AreEqual(expectedValue, fastProperty.Get(instance));
        }