Create IJobExecutionContext object

僤鯓⒐⒋嵵緔 提交于 2020-01-06 15:08:00

问题


How to create IJobExecutionContext class instance for testing purposes? Like

IJobExecutionContext context = new ... ???

回答1:


You can use 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;

Good quickstart here: https://github.com/Moq/moq4/wiki/Quickstart




回答2:


JobExecutionContextImpl provides an implementation for IJobExecutionContext. see https://github.com/quartznet/quartznet/blob/master/src/Quartz/Impl/JobExecutionContextImpl.cs

Not sure if this is what you need for testing



来源:https://stackoverflow.com/questions/21502655/create-ijobexecutioncontext-object

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!