Пример #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);
}");
        }