示例#1
0
        public void WillNotDelegateANoScriptMethodMethod()
        {
            var delegater = new MethodDelegater();

            var result = delegater.BuildDelegateMethod(typeof(TestDelegaterClass).GetMethod("NoScriptMethod"), "testClass");

            result.ShouldBeNull();
        }
示例#2
0
        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);
}");
        }
示例#3
0
        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();
}");
        }
示例#4
0
        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);
}");
        }
示例#5
0
        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);
}");
        }