public void WillNotDelegateANoScriptMethodMethod() { var delegater = new MethodDelegater(); var result = delegater.BuildDelegateMethod(typeof(TestDelegaterClass).GetMethod("NoScriptMethod"), "testClass"); result.ShouldBeNull(); }
public void CanDelegateAMethodWithParams() { var delegater = new MethodDelegater(); var result = delegater.BuildDelegateMethod(typeof(TestDelegaterClass).GetMethod("MethodWithParams"), "testClass"); CompileToString(result).ShouldEqual(@"public void MethodWithParams(params object[] objs) { testClass.MethodWithParams(objs); }"); }
public void CanDelegateAMethodWithReturnType() { var delegater = new MethodDelegater(); var result = delegater.BuildDelegateMethod(typeof(TestDelegaterClass).GetMethod("MethodWithReturn"), "testClass"); CompileToString(result).ShouldEqual(@"public string MethodWithReturn() { return testClass.MethodWithReturn(); }"); }
public void CanDelegateAMethodWithOptionalStringParameter() { var delegater = new MethodDelegater(); var result = delegater.BuildDelegateMethod(typeof(TestDelegaterClass).GetMethod("MethodWithOptionalString"), "testClass"); CompileToString(result).ShouldEqual(@"public void MethodWithOptionalString([System.Runtime.InteropServices.OptionalAttribute()] [System.Runtime.InteropServices.DefaultParameterValueAttribute(""Test"")] string str) { testClass.MethodWithOptionalString(str); }"); }
public void CanDelegateAMethodWithSimpleArgument() { var delegater = new MethodDelegater(); var result = delegater.BuildDelegateMethod(typeof(TestDelegaterClass).GetMethod("MethodWithArgument"), "testClass"); CompileToString(result).ShouldEqual(@"public void MethodWithArgument(string test) { testClass.MethodWithArgument(test); }"); }