示例#1
0
        public void FastReflectionPropertiesStatic()
        {
            var fastReflection = new FastReflection();

            fastReflection.SetStaticProperty(typeof(MockValue), nameof(MockValue.StaticFoo), 123);
            Assert.AreEqual(123, fastReflection.GetStaticPropertyOrEnum(typeof(MockValue), nameof(MockValue.StaticFoo)));
        }
示例#2
0
        public void FastReflectionEnum()
        {
            var fastReflection = new FastReflection();

            Assert.AreEqual(System.IO.FileMode.CreateNew, fastReflection.GetStaticPropertyOrEnum(typeof(System.IO.FileMode), nameof(System.IO.FileMode.CreateNew)));

            try
            {
                fastReflection.GetStaticPropertyOrEnum(typeof(System.IO.FileMode), "Hello");
                Assert.Fail();
            }
            catch (ArgumentException)
            {
            }
            catch (Exception)
            {
                Assert.Fail();
            }
        }