问题
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