创建IJobExecutionContext对象

时间:2014-02-01 19:41:19

标签: c# .net quartz.net

如何为测试目的创建IJobExecutionContext类实例?像

IJobExecutionContext context = new ... ???

2 个答案:

答案 0 :(得分:1)

你可以使用Moq。 https://github.com/Moq/moq4

IJobExecutionContext mockJobExecutionContext= new Mock<IJobExecutionContext>();
mockJobExecutionContext.Setup(
   // ... do method setup here
);
mockJobExecutionContext.SetupProperty(x=>x.JobInstance);
var jobExecutionContext = mockJobExecutionContext.Object;

快速入门:https://github.com/Moq/moq4/wiki/Quickstart

答案 1 :(得分:0)

JobExecutionContextImpl为IJobExecutionContext提供了一个实现。见https://github.com/quartznet/quartznet/blob/master/src/Quartz/Impl/JobExecutionContextImpl.cs

不确定这是否是测试所需的内容