public void TestMethodInvoker_PrivateMethod() { InvocationCountingJob job = new InvocationCountingJob(); MethodInvoker mi = new MethodInvoker(); mi.TargetObject = job; mi.TargetMethod = "PrivateMethod"; mi.Prepare(); methodInvokingJob.MethodInvoker = mi; methodInvokingJob.Execute(CreateMinimalJobExecutionContext()); }
public void TestMethodInvoker_MethodSetCorrectly() { InvocationCountingJob job = new InvocationCountingJob(); MethodInvoker mi = new MethodInvoker(); mi.TargetObject = job; mi.TargetMethod = "Invoke"; mi.Prepare(); methodInvokingJob.MethodInvoker = mi; methodInvokingJob.Execute(CreateMinimalJobExecutionContext()); Assert.AreEqual(1, job.CounterValue, "Job was not invoked once"); }
public void TestMethodInvoker_ShouldSetResultToExecutionContext() { InvocationCountingJob job = new InvocationCountingJob(); MethodInvoker mi = new MethodInvoker(); mi.TargetObject = job; mi.TargetMethod = "InvokeWithReturnValue"; mi.Prepare(); methodInvokingJob.MethodInvoker = mi; IJobExecutionContext context = CreateMinimalJobExecutionContext(); methodInvokingJob.Execute(context); Assert.AreEqual(InvocationCountingJob.DefaultReturnValue, context.Result, "result value was not set to context"); }
public void TestMethodInvoker_MethodSetCorrectlyThrowsException() { InvocationCountingJob job = new InvocationCountingJob(); MethodInvoker mi = new MethodInvoker(); mi.TargetObject = job; mi.TargetMethod = "InvokeAndThrowException"; mi.Prepare(); methodInvokingJob.MethodInvoker = mi; try { methodInvokingJob.Execute(CreateMinimalJobExecutionContext()); Assert.Fail("Successful invoke when method threw exception"); } catch (JobMethodInvocationFailedException) { // ok } Assert.AreEqual(1, job.CounterValue, "Job was not invoked once"); }