示例#1
0
        public void GetMethod()
        {
            var target   = new TypeA2();
            var accessor = new TypeAccessor(target);

            var member = accessor.Methods[1];

            member.Invoke(new object[] { "A" });

            Assert.AreEqual(true, target.MethodBCalled);
            Assert.AreEqual("A", target.P1);
        }
示例#2
0
        public void Invoke_Generic_Method_With_Accessor()
        {
            var target   = new TypeA2();
            var accessor = new TypeAccessor(target);

            var member = accessor.Methods["Method"][2];

            Assert.IsTrue(member.Method.IsGenericMethod);

            member
            .MakeGenericMethod(new Type[] { typeof(string) })
            .Invoke(new object[] { "B" });

            Assert.AreEqual(false, target.MethodACalled);
            Assert.AreEqual(false, target.MethodBCalled);
            Assert.AreEqual(true, target.MethodCCalled);
            Assert.AreEqual("B", target.P2);
        }