コード例 #1
0
        public void CanCreateInstance()
        {
            var testClass  = new MethodExecutorClass();
            var methodInfo = testClass.GetType().GetMethod("Foo");

            var executor = ObjectMethodExecutor.Create(methodInfo, typeof(MethodExecutorClass).GetTypeInfo());

            Assert.NotNull(executor);
        }
コード例 #2
0
        public void CanExcuteMethodWithParameters()
        {
            var testClass  = new MethodExecutorClass();
            var methodInfo = testClass.GetType().GetMethod("Add");

            var executor = ObjectMethodExecutor.Create(methodInfo, typeof(MethodExecutorClass).GetTypeInfo());

            Assert.NotNull(executor);

            var objResult = executor.Execute(testClass, 1, 2);

            Assert.Equal(3, objResult);
        }
コード例 #3
0
        public void CanGetExcuteMethodDefaultValue()
        {
            var testClass  = new MethodExecutorClass();
            var methodInfo = testClass.GetType().GetMethod("WithDefaultValue");

            var executor = ObjectMethodExecutor.Create(methodInfo, typeof(MethodExecutorClass).GetTypeInfo());

            var objResult = executor.GetDefaultValueForParameter(0);

            Assert.Equal("aaa", objResult);

            var objResult2 = executor.GetDefaultValueForParameter(1);

            Assert.Equal("bbb", objResult2);
        }