Ejemplo n.º 1
0
        public void Should_cache_properties_nicely()
        {
            var cache = new ReadWritePropertyCache<PrivateSetter>(true);

            var instance = new PrivateSetter();

            const string expectedValue = "Chris";
            cache["Name"].Set(instance, expectedValue);

            Assert.AreEqual(expectedValue, instance.Name);
        }
Ejemplo n.º 2
0
        public void Should_cache_properties_nicely()
        {
            var cache = new ReadWritePropertyCache <PrivateSetter>(true);

            var instance = new PrivateSetter();

            const string expectedValue = "Chris";

            cache["Name"].Set(instance, expectedValue);

            Assert.AreEqual(expectedValue, instance.Name);
        }
Ejemplo n.º 3
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));
        }
Ejemplo n.º 4
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));
        }
Ejemplo n.º 5
0
 public void SerializesWithPrivateSetter()
 {
     var start = new PrivateSetter(4);
     var bytes = BsonSerializer.Serialize(start);
     var end = BsonDeserializer.Deserialize<PrivateSetter>(bytes);
     Assert.Equal(start.Id, end.Id);
 }