The issue comes from the fact that you arrange the getter of the Job property, by applying the following:
Mock.Arrange(() => manager.Job.Submit()).MustBeCalled();
In order to prevent this, you will need to arrange the above against the returned object directly, as our auto mocking feature (recursive mocks) goes through the chain and applies non-null object return for the manager.Job
Here is a possible approach for this:
var arg1 = 2000999;
var arg2 = 12345;
var arg3 = 9999;
var arg4 =
var manager = Mock.Create<Manager>(Behavior.CallOriginal);
(MyStaticClass), Behavior.Strict, StaticConstructor.Mocked);
var job =
JobType = JobType.Complete,
MediaId = arg1
Mock.Arrange(() => MyStaticClass.CreateCompleteJob(arg1, arg2, arg3, arg4))
Mock.Arrange(() => job.Submit()).MustBeCalled();
manager.RunCompleteJob(arg1, arg2, arg3, arg4);
Here, we create a Job
object, that later on will be returned for the CreateCompleteJob
call. Having this, we can directly arrange and assert against that object.
Further, we are aware that there are cases where this is not very intuitive (just as yours), so we definitely consider improvements for future JustMock releases.
I hope this helps.
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.