Example #1
0
        public void StructTest()
        {
            var getter = ModelAccess <MyStruct> .GetGetter(x => x.PropTwo).GetDelegate <int>();

            var setter = ModelAccess <MyStruct> .GetSetter(x => x.PropTwo).GetDelegate <int>();

            MyStruct instance = new MyStruct();

            setter(ref instance, 3);
            var value = getter(ref instance);

            Assert.Equal(3, value);
        }
Example #2
0
        public void GetSettersByName()
        {
            var names = ModelAccess <GrandChildClass>
                        .Setters
                        .Keys
                        .ToList();

            Assert.Equal(22, names.Count);

            foreach (var name in names)
            {
                var setter = ModelAccess <GrandChildClass> .GetSetter(name);

                Assert.NotNull(setter);
            }
        }
Example #3
0
        public void GetSettersByName_CaseInsensitive()
        {
            var names = ModelAccess <GrandChildClass>
                        .Setters
                        .Keys
                        .Select(x => x.ToUpperInvariant())
                        .ToList();

            Assert.Equal(22, names.Count);

            foreach (var name in names)
            {
                var setter = ModelAccess <GrandChildClass> .GetSetter(name);

                Assert.NotNull(setter);
            }
        }
Example #4
0
        public void GetSetterByExpression()
        {
            var setter = ModelAccess <GrandChildClass> .GetSetter(x => x.Child_PublicField);

            Assert.NotNull(setter);
        }