public void SetUp() { mocker = AutoMock.GetStrict(); eventCacheMock = mocker.Mock <IDataCache <CalculatedRequiredLevyAmount> >(); monthEndCacheMock = mocker.Mock <IDataCache <bool> >(); levyAccountCacheMock = mocker.Mock <IDataCache <LevyAccountModel> >(); levyAccountRepositoryMock = mocker.Mock <ILevyFundingSourceRepository>(); processorMock = mocker.Mock <IPaymentProcessor>(); levyBalanceServiceMock = mocker.Mock <ILevyBalanceService>(); paymentLoggerMock = new Mock <IPaymentLogger>(MockBehavior.Loose); employerProviderPrioritiesMock = mocker.Mock <IDataCache <List <EmployerProviderPriorityModel> > >(); refundSortKeysCacheMock = mocker.Mock <IDataCache <List <string> > >(); transferPaymentSortKeysCacheMock = mocker.Mock <IDataCache <List <TransferPaymentSortKeyModel> > >(); requiredPaymentSortKeysCacheMock = mocker.Mock <IDataCache <List <RequiredPaymentSortKeyModel> > >(); generateSortedPaymentKeysMock = mocker.Mock <IGenerateSortedPaymentKeys>(); service = mocker.Create <RequiredLevyAmountFundingSourceService>( new NamedParameter("mapper", mapper), new NamedParameter("paymentLogger", paymentLoggerMock.Object) ); monthEndCacheMock.Setup(x => x.AddOrReplace(It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <CancellationToken>())) .Returns(Task.CompletedTask); levyAccountCacheMock.Setup(c => c.AddOrReplace(CacheKeys.LevyBalanceKey, It.IsAny <LevyAccountModel>(), It.IsAny <CancellationToken>())) .Returns(Task.CompletedTask); levyBalanceServiceMock.SetupGet(svc => svc.RemainingBalance).Returns(100); levyBalanceServiceMock.SetupGet(svc => svc.RemainingTransferAllowance).Returns(50); }
protected override async Task OnActivateAsync() { using (var operation = telemetry.StartOperation("LevyFundedService.OnActivateAsync", $"{Id}_{Guid.NewGuid():N}")) { var stopwatch = Stopwatch.StartNew(); //TODO: Use DI actorCache = new ActorReliableCollectionCache <bool>(StateManager); employerProviderPriorities = new ReliableCollectionCache <List <EmployerProviderPriorityModel> >(StateManager); requiredPaymentsCache = new ReliableCollectionCache <CalculatedRequiredLevyAmount>(StateManager); monthEndCache = new ReliableCollectionCache <bool>(StateManager); levyAccountCache = new ReliableCollectionCache <LevyAccountModel>(StateManager); refundSortKeysCache = new ReliableCollectionCache <List <string> >(StateManager); transferPaymentSortKeysCache = new ReliableCollectionCache <List <TransferPaymentSortKeyModel> >(StateManager); requiredPaymentSortKeysCache = new ReliableCollectionCache <List <RequiredPaymentSortKeyModel> >(StateManager); generateSortedPaymentKeys = new GenerateSortedPaymentKeys( employerProviderPriorities, refundSortKeysCache, transferPaymentSortKeysCache, requiredPaymentSortKeysCache ); fundingSourceService = new RequiredLevyAmountFundingSourceService( lifetimeScope.Resolve <IPaymentProcessor>(), lifetimeScope.Resolve <IMapper>(), requiredPaymentsCache, lifetimeScope.Resolve <ILevyFundingSourceRepository>(), lifetimeScope.Resolve <ILevyBalanceService>(), lifetimeScope.Resolve <IPaymentLogger>(), monthEndCache, levyAccountCache, employerProviderPriorities, refundSortKeysCache, transferPaymentSortKeysCache, requiredPaymentSortKeysCache, generateSortedPaymentKeys ); await Initialise().ConfigureAwait(false); await base.OnActivateAsync().ConfigureAwait(false); TrackInfrastructureEvent("LevyFundedService.OnActivateAsync", stopwatch); telemetry.StopOperation(operation); } }