public async Task TestStoreEmployerProviderPriority() { // arrange var employerChangedProviderPriority = new EmployerChangedProviderPriority { EmployerAccountId = 1, OrderedProviders = new List <long> { 1, 2, 3 } }; levyAccountRepositoryMock .Setup(x => x.ReplaceEmployerProviderPriorities( employerChangedProviderPriority.EmployerAccountId, It.Is <List <EmployerProviderPriorityModel> >(o => o.Count == 3 && o[0].EmployerAccountId == 1 && o[0].Order == 1 && o[0].Ukprn == 1), CancellationToken.None)) .Returns(Task.CompletedTask).Verifiable(); employerProviderPrioritiesMock .Setup(x => x.AddOrReplace(CacheKeys.EmployerPaymentPriorities, It.Is <List <EmployerProviderPriorityModel> >(o => o.Count == 3 && o[0].EmployerAccountId == 1 && o[0].Order == 1 && o[0].Ukprn == 1), CancellationToken.None)) .Returns(Task.CompletedTask).Verifiable(); // act await service.StoreEmployerProviderPriority(employerChangedProviderPriority); // assert in tear down }
public async Task HandleEmployerProviderPriorityChange(EmployerChangedProviderPriority message) { try { using (var operation = telemetry.StartOperation("LevyFundedService.HandleEmployerProviderPriorityChange", message.EventId.ToString())) { var stopwatch = Stopwatch.StartNew(); paymentLogger.LogDebug($"Storing EmployerChangedProviderPriority event for {Id}, Account Id: {message.EmployerAccountId}"); await fundingSourceService.StoreEmployerProviderPriority(message).ConfigureAwait(false); paymentLogger.LogInfo($"Finished Storing EmployerChangedProviderPriority event for {Id}, Account Id: {message.EmployerAccountId}"); TrackInfrastructureEvent("LevyFundedService.HandleEmployerProviderPriorityChange", stopwatch); telemetry.StopOperation(operation); } } catch (Exception ex) { paymentLogger.LogError($"Error while handling EmployerChangedProviderPriority event for {Id}, Account Id: {message.EmployerAccountId} Error:{ex.Message}", ex); throw; } }