Exemplo n.º 1
0
        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());
        }
Exemplo n.º 2
0
 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");
 }
Exemplo n.º 3
0
        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");
        }
Exemplo n.º 4
0
        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");
        }
Exemplo n.º 5
0
        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");
        }
Exemplo n.º 6
0
        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");
        }
Exemplo n.º 7
0
 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());
 }
Exemplo n.º 8
0
 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");
 }