public void CanCreateInstance() { var testClass = new MethodExecutorClass(); var methodInfo = testClass.GetType().GetMethod("Foo"); var executor = ObjectMethodExecutor.Create(methodInfo, typeof(MethodExecutorClass).GetTypeInfo()); Assert.NotNull(executor); }
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); }
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); }