public async Task Test_Cancel_Delivery_Job_With_No_Task_In_Progress() { string cancellationReason = "test cancellation reason"; var replaceOneResult = new ReplaceOneResult.Acknowledged(1, 1, null); var createdJob = GetDummyJob(OrderTypes.Delivery); var jobManagerMock = new Mock <IJobManager>(); jobManagerMock.Setup(x => x.UpdateJob(It.IsAny <Job>())) .ReturnsAsync(null); var userStoreMock = new Mock <IUserStore <User> >(); var jobRepository = new JobRepository(jobManagerMock.Object, new AccountManager(userStoreMock.Object), activitySubject, jobIndexingSubject); var result = await jobRepository.CancelJob(createdJob, cancellationReason); Assert.IsNotNull(result); Assert.AreEqual(JobState.CANCELLED, result.UpdatedValue.State); Assert.AreEqual(cancellationReason, result.UpdatedValue.CancellationReason); Assert.AreEqual(JobTaskState.CANCELLED, result.UpdatedValue.Tasks.First().State); }