public async Task UpdateSuccess_ShallSave() { var inferenceRequest = new InferenceRequest(); inferenceRequest.JobId = Guid.NewGuid().ToString(); inferenceRequest.PayloadId = Guid.NewGuid().ToString(); inferenceRequest.TransactionId = Guid.NewGuid().ToString(); var store = new InferenceRequestRepository(_logger.Object, _jobsApi.Object, _inferenceRequestRepository.Object); await store.Update(inferenceRequest, InferenceRequestStatus.Fail); _logger.VerifyLogging($"Updating inference request.", LogLevel.Debug, Times.Once()); _logger.VerifyLogging($"Inference request updated.", LogLevel.Information, Times.Once()); _inferenceRequestRepository.Verify(p => p.SaveChangesAsync(It.IsAny <CancellationToken>()), Times.Once()); }
public async Task UpdateSuccess_ShallRetryOnFailure() { var inferenceRequest = new InferenceRequest(); inferenceRequest.JobId = Guid.NewGuid().ToString(); inferenceRequest.PayloadId = Guid.NewGuid().ToString(); inferenceRequest.TransactionId = Guid.NewGuid().ToString(); _inferenceRequestRepository.Setup(p => p.SaveChangesAsync(It.IsAny <CancellationToken>())).Throws(new Exception("error")); var store = new InferenceRequestRepository(_logger.Object, _jobsApi.Object, _inferenceRequestRepository.Object); await Assert.ThrowsAsync <Exception>(() => store.Update(inferenceRequest, InferenceRequestStatus.Success)); _logger.VerifyLoggingMessageBeginsWith($"Error while updating inference request", LogLevel.Error, Times.Exactly(3)); _inferenceRequestRepository.Verify(p => p.SaveChangesAsync(It.IsAny <CancellationToken>()), Times.AtLeast(3)); }