public async Task UpdateJobStatus_ApiResponseSuccess_Runs() { //Arrange IJobsApiClient jobsApiClient = Substitute.For <IJobsApiClient>(); JobManagementResiliencePolicies policies = new JobManagementResiliencePolicies { JobsApiClient = Policy.NoOpAsync() }; IMessengerService messengerService = Substitute.For <IMessengerService>(); ILogger logger = Substitute.For <ILogger>(); ApiResponse <JobLog> jobLogApiResponse = new ApiResponse <JobLog>(HttpStatusCode.OK, new JobLog()); jobsApiClient .AddJobLog(Arg.Any <string>(), Arg.Any <JobLogUpdateModel>()) .Returns(jobLogApiResponse); JobLogUpdateModel updateModel = new JobLogUpdateModel(); JobManagement jobManagement = new JobManagement(jobsApiClient, logger, policies, messengerService); string jobId = "3456"; //Act await jobManagement.UpdateJobStatus(jobId, updateModel); //Assert await jobsApiClient .Received(1) .AddJobLog(jobId, updateModel); logger .Received(0) .Write(Arg.Any <LogEventLevel>(), Arg.Any <string>()); }
public async Task UpdateJobStatusInternal_ApiResponseFailure_Logs(ApiResponse <JobLog> jobLogApiResponse) { //Arrange IJobsApiClient jobsApiClient = Substitute.For <IJobsApiClient>(); JobManagementResiliencePolicies policies = new JobManagementResiliencePolicies { JobsApiClient = Policy.NoOpAsync() }; IMessengerService messengerService = Substitute.For <IMessengerService>(); ILogger logger = Substitute.For <ILogger>(); jobsApiClient .AddJobLog(Arg.Any <string>(), Arg.Any <JobLogUpdateModel>()) .Returns(jobLogApiResponse); JobLogUpdateModel updateModel = new JobLogUpdateModel(); JobManagement jobManagement = new JobManagement(jobsApiClient, logger, policies, messengerService); string jobId = "3456"; //Act await jobManagement.UpdateJobStatus(jobId, updateModel); //Assert await jobsApiClient .Received(1) .AddJobLog(jobId, updateModel); logger .Received(1) .Write(LogEventLevel.Error, $"Failed to add a job log for job id '{jobId}'"); }