Prepare() public method

Prepare the specified method.

The method can be invoked any number of times afterwards.

/// If all required properties are not set. /// /// If the specified method could not be found. ///
public Prepare ( ) : void
return void
 public void Invoke () {
     ArgumentConvertingMethodInvoker vkr = new ArgumentConvertingMethodInvoker ();
     vkr.TargetObject = new Voker ();
     vkr.TargetMethod = "Hi";
     vkr.Arguments = new object [] {"Rick, Mark, Griffin, Si, Choy, Aleks"};
     vkr.Prepare ();
     string actual = vkr.Invoke () as string;
     Assert.IsNotNull (actual);
     Assert.AreEqual ("Hi Rick, Mark, Griffin, Si, Choy, Aleks", actual);
 }
        public void Invoke()
        {
            ArgumentConvertingMethodInvoker vkr = new ArgumentConvertingMethodInvoker();

            vkr.TargetObject = new Voker();
            vkr.TargetMethod = "Hi";
            vkr.Arguments    = new object [] { "Rick, Mark, Griffin, Si, Choy, Aleks" };
            vkr.Prepare();
            string actual = vkr.Invoke() as string;

            Assert.IsNotNull(actual);
            Assert.AreEqual("Hi Rick, Mark, Griffin, Si, Choy, Aleks", actual);
        }
 /// <summary>
 /// invoke the method converting the <paramref name="args"/> if necessary to the appropriate type
 /// </summary>
 /// <param name="args">the arguments for the method</param>
 /// <returns>the return value of the method</returns>
 public object InvokeMethod(params object[] args)
 {
     ArgumentConvertingMethodInvoker invoker = new ArgumentConvertingMethodInvoker();
     invoker.TargetObject = _obj;
     invoker.TargetMethod = _methodName;
     invoker.Arguments = args;
     invoker.Prepare();
     //invoker.getPreparedMethod().setAccessible(true);
     if(_methodValidator != null) {
         _methodValidator.Validate(invoker.GetPreparedMethod());
     }
     return invoker.Invoke();
 }
		public void InvokeAllNamedArgumentsWithConversion () 
		{
			ArgumentConvertingMethodInvoker vkr = new ArgumentConvertingMethodInvoker ();
			Voker instance = new Voker ();
			vkr.TargetObject = instance;
			vkr.TargetMethod = "HiEverybody";
			// CSV string should be converted to string []
			vkr.AddNamedArgument("nameS", new object [] {"Rick, Mark, Griffin, Federico, Choy, Aleks"});
			vkr.Prepare ();
			string actual = vkr.Invoke () as string;
			Assert.IsNotNull (actual);
			Assert.AreEqual ("Hi ya'll", actual);
			Assert.IsNotNull (instance.developers);
		}
        /// <summary>
        /// 
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public object InvokeMethod(params object[] args)
        {
            ParameterInfo[] pi = _method.GetParameters();
            if(pi.Length != args.Length) {
                throw new ArgumentException("Wrong number of arguments. Expected types " + ArrayUtils.ToString(pi) + ", but received values " + ArrayUtils.ToString(args) + ".");
            }

            ArgumentConvertingMethodInvoker helper = new ArgumentConvertingMethodInvoker();
            helper.TargetObject = _obj;
            helper.TargetMethod = _method.Name;
            helper.Arguments = args;
            helper.Prepare();
            return helper.Invoke();
        }
        public void InvokeWithRegisteredConversion()
        {
            ArgumentConvertingMethodInvoker vkr = new ArgumentConvertingMethodInvoker();

            // see if custom registration filters thru...
            vkr.RegisterCustomConverter(typeof(Voker), new VokerConverter());
            vkr.TargetType   = typeof(Voker);
            vkr.TargetMethod = "HiVoker";
            // arg should be converted to Voker
            vkr.Arguments = new object [] { "Lebowski" };
            vkr.Prepare();
            string actual = vkr.Invoke() as string;

            Assert.IsNotNull(actual);
            Assert.AreEqual("Hi Lebowski", actual);
        }
        public void InvokeAllNamedArgumentsWithConversion()
        {
            ArgumentConvertingMethodInvoker vkr = new ArgumentConvertingMethodInvoker();
            Voker instance = new Voker();

            vkr.TargetObject = instance;
            vkr.TargetMethod = "HiEverybody";
            // CSV string should be converted to string []
            vkr.AddNamedArgument("nameS", new object [] { "Rick, Mark, Griffin, Federico, Choy, Aleks" });
            vkr.Prepare();
            string actual = vkr.Invoke() as string;

            Assert.IsNotNull(actual);
            Assert.AreEqual("Hi ya'll", actual);
            Assert.IsNotNull(instance.developers);
        }
 public void InvokeWithRegisteredConversion () 
 {
     ArgumentConvertingMethodInvoker vkr = new ArgumentConvertingMethodInvoker ();
     // see if custom registration filters thru...
     vkr.RegisterCustomConverter (typeof (Voker), new VokerConverter ());
     vkr.TargetType = typeof (Voker);
     vkr.TargetMethod = "HiVoker";
     // arg should be converted to Voker
     vkr.Arguments = new object [] {"Lebowski"};
     vkr.Prepare ();
     string actual = vkr.Invoke () as string;
     Assert.IsNotNull (actual);
     Assert.AreEqual ("Hi Lebowski", actual);
 }