Exemplo n.º 1
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);
            }");
        }
Exemplo n.º 2
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();
            }");
        }
Exemplo n.º 3
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);
            }");
        }
Exemplo n.º 4
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);
            }");
        }
Exemplo n.º 5
0
        public void WillNotDelegateANoScriptMethodMethod()
        {
            var delegater = new MethodDelegater();

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

            result.ShouldBeNull();
        }