Example #1
0
        public void Arrange()
        {
            _userId = "ABC123";

            _configuration = new AccountApiConfiguration
            {
                ApiBaseUrl = "http://some-url/"
            };

            _uri = $"/api/user/{_userId}/accounts";
            var absoluteUri = _configuration.ApiBaseUrl.TrimEnd('/') + _uri;

            _accountViewModel = new AccountDetailViewModel
            {
                HashedAccountId = "123ABC",
                AccountId       = 123,
                DasAccountName  = "Test Account",
                DateRegistered  = DateTime.Now.AddDays(-30),
            };

            var accounts = new List <AccountDetailViewModel> {
                _accountViewModel
            };

            _httpClient = new Mock <SecureHttpClient>();
            _httpClient.Setup(c => c.GetAsync(absoluteUri))
            .Returns(Task.FromResult(JsonConvert.SerializeObject(accounts)));

            _apiClient = new AccountApiClient(_configuration, _httpClient.Object);
        }
Example #2
0
        private void RegisterServices(IServiceCollection services)
        {
            var commitmentsClientApiConfiguration = new CommitmentsClientApiConfiguration();

            Configuration.GetSection(nameof(CommitmentsClientApiConfiguration)).Bind(commitmentsClientApiConfiguration);
            services.AddSingleton(commitmentsClientApiConfiguration);
            services.AddSingleton <ICommitmentsApiClientFactory, CommitmentsApiClientFactory>();
            services.AddTransient(x => x.GetService <ICommitmentsApiClientFactory>().CreateClient());
            services.AddTransient <CommitmentsService>();

            var accountsApiConfiguration = new AccountApiConfiguration();

            Configuration.GetSection(nameof(AccountApiConfiguration)).Bind(accountsApiConfiguration);
            services.AddSingleton <IAccountApiConfiguration>(accountsApiConfiguration);
            services.AddTransient <IAccountApiClient, AccountApiClient>();
            services.AddTransient <EmployerService>();

            var roatpApiConfiguration = new RoatpApiClientSettings();

            Configuration.GetSection(nameof(RoatpApiClientSettings)).Bind(roatpApiConfiguration);
            services.AddSingleton(roatpApiConfiguration);
            services.AddSingleton <IRoatpApiHttpClientFactory, RoatpApiHttpClientFactory>();
            services.AddTransient(x => x.GetService <IRoatpApiHttpClientFactory>().CreateClient());

            services.AddTransient <IRoatpService, RoatpService>();
            services.AddTransient <ProviderService>();
            services.AddTransient <DataLockService>();
            services.AddTransient <LearnerReportProvider>();
            services.AddTransient <ITimeProvider, TimeProvider>();
        }
        public void Arrange()
        {
            _configuration = new AccountApiConfiguration
            {
                ApiBaseUrl = "http://some-url/"
            };

            _httpClient = new Mock <SecureHttpClient>();
            _httpClient.Setup(c => c.GetAsync(It.IsAny <string>()))
            .Returns(Task.FromResult(
                         JsonConvert.SerializeObject(new PagedApiResponseViewModel <AccountWithBalanceViewModel>
            {
                Page       = 1,
                TotalPages = 1,
                Data       = new List <AccountWithBalanceViewModel>
                {
                    new AccountWithBalanceViewModel
                    {
                        AccountId     = 1,
                        AccountHashId = "1",
                        AccountName   = "Account 1",
                        Balance       = 1234567.89m,
                        Href          = "/api/accounts/1"
                    }
                }
            })));

            _apiClient = new AccountApiClient(_configuration, _httpClient.Object);
        }
        public void Arrange()
        {
            _configuration = new AccountApiConfiguration
            {
                ApiBaseUrl = "http://some-url/"
            };

            _uri = "/api/accounts/ABC123";
            var absoluteUri = _configuration.ApiBaseUrl.TrimEnd('/') + _uri;

            _expectedAccount = new AccountDetailViewModel
            {
                AccountId       = 123,
                HashedAccountId = "1",
                DasAccountName  = "Account 1",
                DateRegistered  = DateTime.Now.AddYears(-1),
                OwnerEmail      = "*****@*****.**",
                LegalEntities   = new ResourceList(new[] { new ResourceViewModel {
                                                               Id = "1", Href = "/api/legalentities/test1"
                                                           } }),
                PayeSchemes = new ResourceList(new[] { new ResourceViewModel {
                                                           Id = "1", Href = "/api/payeschemes/test1"
                                                       } })
            };

            _httpClient = new Mock <SecureHttpClient>();
            _httpClient.Setup(c => c.GetAsync(absoluteUri)).Returns(Task.FromResult(JsonConvert.SerializeObject(_expectedAccount)));

            _apiClient = new AccountApiClient(_configuration, _httpClient.Object);
        }
Example #5
0
        public void Arrange()
        {
            _configuration = new AccountApiConfiguration
            {
                ApiBaseUrl = "http://some-url/"
            };

            _uri = "/api/accounts/ABC123/legalentities/123";
            var absoluteUri = _configuration.ApiBaseUrl.TrimEnd('/') + _uri;

            _expectedLegalEntity = new LegalEntityViewModel
            {
                LegalEntityId   = 123,
                Code            = "Code",
                Name            = "Name",
                DateOfInception = DateTime.Now.AddYears(-1),
                Source          = "Source",
                Address         = "An address",
                Status          = "Status"
            };

            _httpClient = new Mock <SecureHttpClient>();
            _httpClient.Setup(c => c.GetAsync(absoluteUri)).Returns(Task.FromResult(JsonConvert.SerializeObject(_expectedLegalEntity)));

            _apiClient = new AccountApiClient(_configuration, _httpClient.Object);
        }
Example #6
0
        public void Arrange()
        {
            _accountId = "ABC123";

            _configuration = new AccountApiConfiguration
            {
                ApiBaseUrl = "http://some-url/"
            };

            _uri = $"/api/accounts/{_accountId}/users";
            var absoluteUri = _configuration.ApiBaseUrl.TrimEnd('/') + _uri;

            _teamMember = new TeamMemberViewModel
            {
                Name    = "Name",
                UserRef = "2163",
                Email   = "*****@*****.**",
                Role    = "Viewer"
            };

            var members = new List <TeamMemberViewModel> {
                _teamMember
            };

            _httpClient = new Mock <SecureHttpClient>();
            _httpClient.Setup(c => c.GetAsync(absoluteUri))
            .Returns(Task.FromResult(JsonConvert.SerializeObject(members)));

            _apiClient = new AccountApiClient(_configuration, _httpClient.Object);
        }
        public void Arrange()
        {
            Configuration = new AccountApiConfiguration
            {
                ApiBaseUrl = "http://some-url/"
            };

            HttpClient = new Mock <SecureHttpClient>();
            HttpClientSetup();

            ApiClient = new AccountApiClient(Configuration, HttpClient.Object);
        }
Example #8
0
        public void Arrange()
        {
            _configuration = new AccountApiConfiguration
            {
                ApiBaseUrl = "http://some-url/"
            };

            _uri = "/api/accounts/ABC123/payeschemes/ABC%F123";
            var absoluteUri = _configuration.ApiBaseUrl.TrimEnd('/') + _uri;

            _expectedPayeScheme = new PayeSchemeViewModel
            {
                Ref  = "ABC/123",
                Name = "Name"
            };

            _httpClient = new Mock <SecureHttpClient>();
            _httpClient.Setup(c => c.GetAsync(absoluteUri)).Returns(Task.FromResult(JsonConvert.SerializeObject(_expectedPayeScheme)));

            _apiClient = new AccountApiClient(_configuration, _httpClient.Object);
        }
Example #9
0
        public void Arrange()
        {
            _configuration = new AccountApiConfiguration
            {
                ApiBaseUrl = "http://some-url/"
            };

            _uri = "/api/accounts/ABC123/payeschemes";
            var absoluteUri = _configuration.ApiBaseUrl.TrimEnd('/') + _uri;

            _payeSchemes = new List <ResourceViewModel>()
            {
                new ResourceViewModel {
                    Id = "1", Href = "/api/payeschemes/test1"
                }
            };

            _httpClient = new Mock <SecureHttpClient>();
            _httpClient.Setup(c => c.GetAsync(absoluteUri)).Returns(Task.FromResult(JsonConvert.SerializeObject(_payeSchemes)));

            _apiClient = new AccountApiClient(_configuration, _httpClient.Object);
        }
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterType <ValidateRequiredPaymentEvent>().AsImplementedInterfaces().InstancePerLifetimeScope();
            builder.RegisterType <CoInvestedFundingSourcePaymentEventMapper>().AsImplementedInterfaces().InstancePerLifetimeScope();
            builder.RegisterType <SfaFullyFundedPaymentProcessor>().AsImplementedInterfaces().InstancePerLifetimeScope();
            builder.RegisterType <SfaFullyFundedFundingSourcePaymentEventMapper>().AsImplementedInterfaces().InstancePerLifetimeScope();
            builder.RegisterType <IncentiveRequiredPaymentProcessor>().AsImplementedInterfaces().InstancePerLifetimeScope();
            builder.RegisterType <LevyFundingSourceRepository>().AsImplementedInterfaces().InstancePerLifetimeScope();
            builder.RegisterType <PaymentProcessor>().AsImplementedInterfaces().InstancePerLifetimeScope();
            builder.RegisterType <LevyPaymentProcessor>().As <ILevyPaymentProcessor>().InstancePerLifetimeScope();
            builder.RegisterType <TransferPaymentProcessor>().As <ITransferPaymentProcessor>().InstancePerLifetimeScope();
            builder.RegisterType <CoInvestedPaymentProcessor>().As <ICoInvestedPaymentProcessor>().InstancePerLifetimeScope();
            builder.RegisterType <EmployerCoInvestedPaymentProcessor>().As <IEmployerCoInvestedPaymentProcessor>().InstancePerLifetimeScope();
            builder.RegisterType <SfaCoInvestedPaymentProcessor>().As <ISfaCoInvestedPaymentProcessor>().InstancePerLifetimeScope();
            builder.RegisterType <LevyBalanceService>().AsImplementedInterfaces().InstancePerLifetimeScope();
            builder.RegisterType <ReliableCollectionCache <CalculatedRequiredLevyAmount> >().AsImplementedInterfaces().InstancePerLifetimeScope();
            builder.RegisterType <ReliableCollectionCache <List <string> > >().AsImplementedInterfaces().InstancePerLifetimeScope();
            builder.RegisterType <LevyMessageRoutingService>().AsImplementedInterfaces();
            builder.RegisterType <PeriodEndService>().AsImplementedInterfaces().InstancePerLifetimeScope();
            builder.RegisterType <LevyAccountBulkCopyConfiguration>().AsImplementedInterfaces().InstancePerLifetimeScope();
            builder.RegisterType <LevyAccountBulkCopyRepository>().AsImplementedInterfaces().InstancePerLifetimeScope();
            builder.RegisterType <FundingSourceEventGenerationService>().AsImplementedInterfaces().InstancePerLifetimeScope();
            builder.RegisterType <SubmissionCleanUpService>().AsImplementedInterfaces().InstancePerLifetimeScope();
            builder.RegisterType <CalculatedRequiredLevyAmountPrioritisationService>().AsImplementedInterfaces().InstancePerLifetimeScope();
            builder.RegisterType <FundingSourcePaymentEventBuilder>().AsImplementedInterfaces().InstancePerLifetimeScope();
            builder.RegisterType <EmployerProviderPriorityStorageService>().AsImplementedInterfaces().InstancePerLifetimeScope();

            builder.Register(c => new CoInvestedFundingSourceService
                             (
                                 new List <ICoInvestedPaymentProcessorOld>()
            {
                new SfaCoInvestedPaymentProcessor(c.Resolve <IValidateRequiredPaymentEvent>()),
                new EmployerCoInvestedPaymentProcessor(c.Resolve <IValidateRequiredPaymentEvent>())
            },
                                 c.Resolve <ICoInvestedFundingSourcePaymentEventMapper>()
                             )).As <ICoInvestedFundingSourceService>().InstancePerLifetimeScope();


            builder.Register((c, p) =>
            {
                var configHelper     = c.Resolve <IConfigurationHelper>();
                var accountApiConfig = new AccountApiConfiguration
                {
                    ApiBaseUrl    = configHelper.GetSetting("AccountApiBaseUrl"),
                    ClientId      = configHelper.GetSetting("AccountApiClientId"),
                    ClientSecret  = configHelper.GetSetting("AccountApiClientSecret"),
                    IdentifierUri = configHelper.GetSetting("AccountApiIdentifierUri"),
                    Tenant        = configHelper.GetSetting("AccountApiTenant")
                };

                return(accountApiConfig);
            })
            .As <IAccountApiConfiguration>()
            .InstancePerLifetimeScope();

            builder.RegisterType <AccountApiClient>().AsImplementedInterfaces().InstancePerLifetimeScope();

            builder.Register((c, p) =>
            {
                var configHelper                = c.Resolve <IConfigurationHelper>();
                var batchSize                   = configHelper.GetSettingOrDefault("BatchSize", 1000);
                var accountApiClient            = c.Resolve <IAccountApiClient>();
                var logger                      = c.Resolve <IPaymentLogger>();
                var bulkWriter                  = c.Resolve <ILevyAccountBulkCopyRepository>();
                var endpointInstanceFactory     = new EndpointInstanceFactory(CreateEndpointConfiguration(c));
                var levyFundingSourceRepository = c.Resolve <ILevyFundingSourceRepository>();

                return(new ManageLevyAccountBalanceService(accountApiClient, logger, bulkWriter, levyFundingSourceRepository, batchSize, endpointInstanceFactory));
            })
            .As <IManageLevyAccountBalanceService>()
            .InstancePerLifetimeScope();

            builder.RegisterType <ProcessLevyAccountBalanceService>().AsImplementedInterfaces().InstancePerLifetimeScope();

            builder.RegisterType <LevyTransactionBatchStorageService>().AsImplementedInterfaces()
            .InstancePerLifetimeScope();

            builder.Register((c, p) =>
            {
                var config = c.Resolve <IConfigurationHelper>();
                return(new FundingSourceDataContext(config.GetConnectionString("PaymentsConnectionString")));
            }).As <IFundingSourceDataContext>();

            builder.RegisterServiceFabricSupport();
        }