Ejemplo n.º 1
0
        public AccountApiTest()
        {
            var httpClient       = new HttpClient();
            RevolutApiClient api = new RevolutApiClient(httpClient, Config.ENDPOINT, Config.TOKEN);

            _accountClient = new AccountApiClient(api);
        }
        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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        public async Task ItShouldReturnTheEntireListOfAccounts()
        {
            AccountApiClient.Setup(x => x.GetPageOfAccounts(It.IsAny <int>(), 10, null))
            .ReturnsAsync(_pagedApiResponseViewModel);

            AccountApiClient
            .Setup(x => x.GetAccount(It.IsAny <string>()))
            .ReturnsAsync(new AccountDetailViewModel());

            _sut = new Services.AccountRepository(
                AccountApiClient.Object,
                PayeSchemeObfuscator.Object,
                DatetimeService.Object,
                Logger.Object,
                HashingService.Object);

            var actual = await _sut.FindAllDetails(10, 1);

            AccountApiClient.Verify(x => x.GetPageOfAccounts(It.IsAny <int>(), It.IsAny <int>(), null), Times.Once);
            AccountApiClient.Verify(x => x.GetAccount(It.IsAny <string>()), Times.Exactly(2));
            Assert.IsNotNull(actual);
            var list = actual.ToList();

            CollectionAssert.IsNotEmpty(list);
            Assert.AreEqual(2, list.Count());
        }
Ejemplo n.º 5
0
        public async Task ItShouldReturnTheAccountAndTheTeamMembers()
        {
            var id = "123";

            AccountApiClient.Setup(x => x.GetResource <AccountDetailViewModel>($"/api/accounts/{id}"))
            .ReturnsAsync(new AccountDetailViewModel()
            {
            });


            AccountApiClient.Setup(x => x.GetAccountUsers(It.IsAny <string>())).ReturnsAsync(new List <TeamMemberViewModel>()
            {
                new TeamMemberViewModel()
                {
                    Status = InvitationStatus.Accepted, Role = "Role",
                    Email  = "*****@*****.**", Name = "Name1", CanReceiveNotifications = true, UserRef = ""
                },
                new TeamMemberViewModel()
                {
                    Status = InvitationStatus.Accepted, Role = "Role",
                    Email  = "*****@*****.**", Name = "Name2", CanReceiveNotifications = true, UserRef = ""
                }
            });

            var actual = await _sut.Get(id, AccountFieldsSelection.TeamMembers);

            Logger.Verify(x => x.Debug(It.IsAny <string>()), Times.Exactly(2));

            Assert.IsNotNull(actual);
            Assert.IsNull(actual.PayeSchemes);
            Assert.IsNull(actual.LegalEntities);
            Assert.IsNotEmpty(actual.TeamMembers);
            Assert.IsNull(actual.Transactions);
        }
        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);
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
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 async Task ItShouldReturnTheAccountAndTheTeamMembers()
        {
            var id = "123";

            AccountApiClient.Setup(x => x.GetResource <AccountDetailViewModel>($"/api/accounts/{id}"))
            .ReturnsAsync(new AccountDetailViewModel()
            {
            });

            var fixture = new Fixture();

            AccountApiClient.Setup(x => x.GetAccountUsers(It.IsAny <string>())).ReturnsAsync(new List <TeamMemberViewModel>()
            {
                fixture.Create <TeamMemberViewModel>(),
                fixture.Create <TeamMemberViewModel>()
            });

            var actual = await _sut.Get(id, AccountFieldsSelection.TeamMembers);

            Logger.Verify(x => x.Debug(It.IsAny <string>()), Times.Exactly(2));

            Assert.IsNotNull(actual);
            Assert.IsNull(actual.PayeSchemes);
            Assert.IsNull(actual.LegalEntities);
            Assert.IsNotEmpty(actual.TeamMembers);
            Assert.IsNull(actual.Transactions);
        }
Ejemplo n.º 10
0
        public async Task ItShouldReturnAnEmptyListIfGetAccountsThrowsAnHttpRequestException()
        {
            AccountApiClient
            .Setup(x => x.GetPageOfAccounts(It.IsAny <int>(), 10, null))
            .ReturnsAsync(_pagedApiResponseViewModel);

            var e = new HttpRequestException("Some exception message");

            AccountApiClient
            .Setup(x => x.GetAccount(It.IsAny <string>()))
            .ThrowsAsync(e);

            _sut = new Services.AccountRepository(
                AccountApiClient.Object,
                PayeSchemeObfuscator.Object,
                DatetimeService.Object,
                Logger.Object,
                HashingService.Object);

            var actual = await _sut.FindAllDetails(10, 1);

            AccountApiClient.Verify(x => x.GetPageOfAccounts(It.IsAny <int>(), It.IsAny <int>(), null), Times.AtLeastOnce);
            AccountApiClient.Verify(x => x.GetAccount(It.IsAny <string>()), Times.AtLeastOnce);
            Logger.Verify(x => x.Error(e, $"Exception while retrieving details for account ID {_accountWithBalanceViewModels.First().AccountHashId}"));
            Assert.IsNotNull(actual);
            CollectionAssert.IsEmpty(actual.ToList());
        }
        public ProcessFullyApprovedCohortCommandFixture SetApprenticeshipEmployerType(ApprenticeshipEmployerType apprenticeshipEmployerType)
        {
            AccountApiClient.Setup(c => c.GetAccount(Command.AccountId))
            .ReturnsAsync(new AccountDetailViewModel
            {
                ApprenticeshipEmployerType = apprenticeshipEmployerType.ToString()
            });

            return(this);
        }
Ejemplo n.º 12
0
        public AccountApiTest()
        {
            tokenManager = new TokenManager($"{Environment.CurrentDirectory}\\Certificats\\token.json");
            memoryCache  = new MemoryCacheFactory().CreateInstance(token = tokenManager.LoadToken());
            var config     = new ConfigTest();
            var httpClient = new HttpClient();
            var api        = new RevolutApiClient(config, token.AccessToken, httpClient, memoryCache);

            _accountClient = new AccountApiClient(api);
        }
Ejemplo n.º 13
0
        public Task <Tuple <PerformanceCounter, bool> > FindAndDeleteAccount(ClientConnectionInfo adminConnectionInfo, string login)
        {
            var accountApi = new AccountApiClient(adminConnectionInfo.Context);

            return(DoPerformanceMeasureAction(async() =>
            {
                var acount = accountApi.GetByLoginAsync(login).Result;
                var delResult = await accountApi.DeleteAsync(acount.UserId);
                return delResult;
            }, adminConnectionInfo.Context.BaseUri.ToString()));
        }
        public void Arrange()
        {
            Configuration = new AccountApiConfiguration
            {
                ApiBaseUrl = "http://some-url/"
            };

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

            ApiClient = new AccountApiClient(Configuration, HttpClient.Object);
        }
        public async Task ItShouldReturnTheMatchingAccountWithOutLegalEntitiesThatAreOutOfScope(
            EmployerAgreementStatus scope)
        {
            var id = "123";

            var accountResponse = new AccountDetailViewModel
            {
                LegalEntities = new ResourceList(
                    new List <ResourceViewModel>
                {
                    new ResourceViewModel {
                        Href = "https://tempuri.org/legalEntity/{id}", Id = "ABC"
                    }
                })
            };

            AccountApiClient.Setup(x => x.GetResource <AccountDetailViewModel>($"/api/accounts/{id}"))
            .ReturnsAsync(accountResponse);

            var legalEntityResponse = new LegalEntityViewModel
            {
                AgreementStatus = scope
            };

            var legalEntity = accountResponse.LegalEntities[0];

            AccountApiClient.Setup(x => x.GetResource <LegalEntityViewModel>(legalEntity.Href))
            .ReturnsAsync(legalEntityResponse);

            var actual = await _sut.Get(id, AccountFieldsSelection.Organisations);


            Logger.Verify(
                x => x.Debug(
                    $"{nameof(IAccountApiClient)}.{nameof(IAccountApiClient.GetResource)}<{nameof(AccountDetailViewModel)}>(\"/api/accounts/{id}\");"),
                Times.Once);
            Logger.Verify(
                x => x.Debug(
                    $"{nameof(IAccountApiClient)}.{nameof(IAccountApiClient.GetResource)}<{nameof(LegalEntityViewModel)}>(\"{legalEntity.Href}\");"),
                Times.Once);

            AccountApiClient.Verify(x => x.GetResource <LegalEntityViewModel>(It.IsAny <string>()),
                                    Times.Exactly(accountResponse.LegalEntities.Count));

            Assert.IsNotNull(actual);
            Assert.IsNotNull(actual.LegalEntities);
            Assert.AreEqual(0, actual.LegalEntities.Count());

            Assert.IsNull(actual.PayeSchemes);
            Assert.IsNull(actual.Transactions);
            Assert.IsNull(actual.TeamMembers);
        }
Ejemplo n.º 16
0
        public async Task ThenTheAgreementIsReturned()
        {
            var expectedAgreement = new EmployerAgreementView();

            var agreementHref = $"/api/accounts/2385/agreements/123456";

            AccountApiClient.Setup(x => x.GetResource <EmployerAgreementView>(agreementHref)).ReturnsAsync(expectedAgreement);

            var result = await AccountGateway.GetEmployerAgreement(agreementHref);

            result.Should().Be(expectedAgreement);
            AccountApiClient.Verify(x => x.GetResource <EmployerAgreementView>(agreementHref), Times.Once);
        }
Ejemplo n.º 17
0
        public async Task ThenThePayeSchemeIsReturned()
        {
            var expectedPayeScheme = new PayeSchemeViewModel();

            var payeSchemeHref = $"/api/accounts/2385/payeschemes/123456";

            AccountApiClient.Setup(x => x.GetResource <PayeSchemeViewModel>(payeSchemeHref)).ReturnsAsync(expectedPayeScheme);

            var result = await AccountGateway.GetPayeScheme(payeSchemeHref);

            result.Should().Be(expectedPayeScheme);
            AccountApiClient.Verify(x => x.GetResource <PayeSchemeViewModel>(payeSchemeHref), Times.Once);
        }
Ejemplo n.º 18
0
        public async Task ThenTheLegalEntityIsReturned()
        {
            var expectedLegalEntity = new LegalEntityViewModel();

            var legalEntityHref = $"/api/accounts/2385/legalentities/123456";

            AccountApiClient.Setup(x => x.GetResource <LegalEntityViewModel>(legalEntityHref)).ReturnsAsync(expectedLegalEntity);

            var result = await AccountGateway.GetLegalEntity(legalEntityHref);

            result.Should().Be(expectedLegalEntity);
            AccountApiClient.Verify(x => x.GetResource <LegalEntityViewModel>(legalEntityHref), Times.Once);
        }
Ejemplo n.º 19
0
        public async Task ThenTheLevyDeclarationsAreReturned()
        {
            var expectedLevyDeclarations = new AccountResourceList <LevyDeclarationViewModel>(new List <LevyDeclarationViewModel>());

            var levyHref = $"/api/accounts/2385/levy/";

            AccountApiClient.Setup(x => x.GetResource <AccountResourceList <LevyDeclarationViewModel> >(levyHref)).ReturnsAsync(expectedLevyDeclarations);

            var result = await AccountGateway.GetLevyDeclarations(levyHref);

            result.Should().BeSameAs(expectedLevyDeclarations);
            AccountApiClient.Verify(x => x.GetResource <AccountResourceList <LevyDeclarationViewModel> >(levyHref), Times.Once);
        }
Ejemplo n.º 20
0
        public async Task ThenTheAccountDetailsAreReturned()
        {
            var expectedAccountInformation = new AccountDetailViewModelBuilder().Build();

            var accountHref = $"/api/accounts/2385";

            AccountApiClient.Setup(x => x.GetResource <AccountDetailViewModel>(accountHref)).ReturnsAsync(expectedAccountInformation);

            var result = await AccountGateway.GetAccount(accountHref);

            result.Should().Be(expectedAccountInformation);
            AccountApiClient.Verify(x => x.GetResource <AccountDetailViewModel>(accountHref), Times.Once);
        }
Ejemplo n.º 21
0
        public async Task ItShouldReturnNullOnException()
        {
            var id = "123";

            AccountApiClient.Setup(x => x.GetResource <AccountDetailViewModel>($"/api/accounts/{id}"))
            .ThrowsAsync(new Exception());

            var actual = await _sut.Get(id, AccountFieldsSelection.PayeSchemes);

            Logger.Verify(x => x.Debug(It.IsAny <string>()), Times.Once);
            Logger.Verify(x => x.Error(It.IsAny <Exception>(), $"Account with id {id} not found"));

            Assert.IsNull(actual);
        }
Ejemplo n.º 22
0
 public AccountController(
     UserManager <ApplicationUser> userManager,
     SignInManager <ApplicationUser> signInManager,
     IEmailSender emailSender,
     ISmsSender smsSender,
     ILoggerFactory loggerFactory,
     IHostingEnvironment hostingEnvironment, AccountApiClient accountApiClient)
 {
     //_userManager = userManager;
     _signInManager      = signInManager;
     _emailSender        = emailSender;
     _smsSender          = smsSender;
     _logger             = loggerFactory.CreateLogger <AccountController>();
     _hostingEnvironment = hostingEnvironment;
     _accountApiClient   = accountApiClient;
 }
Ejemplo n.º 23
0
        public PaymentApiTest()
        {
            var httpClient       = new HttpClient();
            RevolutApiClient api = new RevolutApiClient(httpClient, Config.ENDPOINT, Config.TOKEN);

            _paymentClient = new PaymentApiClient(api);

            var httpClient2       = new HttpClient();
            RevolutApiClient api2 = new RevolutApiClient(httpClient2, Config.ENDPOINT, Config.TOKEN);

            _counterpartyApiClient = new CounterPartiesApiClient(api2);

            RevolutApiClient api3 = new RevolutApiClient(Config.ENDPOINT, Config.TOKEN);

            _accountApiClient = new AccountApiClient(api3);
        }
        public async Task ItShouldReturnJustTheAccount()
        {
            var id = "123";

            AccountApiClient.Setup(x => x.GetResource <AccountDetailViewModel>($"/api/accounts/{id}"))
            .ReturnsAsync(new AccountDetailViewModel());

            var actual = await _sut.Get(id, AccountFieldsSelection.None);

            Logger.Verify(x => x.Debug(It.IsAny <string>()), Times.Once);

            Assert.IsNotNull(actual);
            Assert.IsNull(actual.PayeSchemes);
            Assert.IsNull(actual.LegalEntities);
            Assert.IsNull(actual.TeamMembers);
            Assert.IsNull(actual.Transactions);
        }
Ejemplo n.º 25
0
        public async Task ItShouldThrowsAnExceptionWhenAccountHasNoResourceForPayeScheme()
        {
            //Arrange
            AccountApiClient.Setup(x => x.GetPageOfAccounts(It.IsAny <int>(), 10, null))
            .ReturnsAsync(_pagedApiResponseViewModel);

            AccountApiClient
            .Setup(x => x.GetAccount(It.IsAny <string>()))
            .ReturnsAsync(new AccountDetailViewModel
            {
                PayeSchemes = new ResourceList(new[] { new ResourceViewModel {
                                                           Id = "1", Href = "/api/payeschemes/test1"
                                                       } })
            });

            var e = new Exception("Some exception message");

            AccountApiClient.Setup(x => x.GetResource <PayeSchemeViewModel>(It.IsAny <string>()))
            .ThrowsAsync(e);

            var obscuredPayePayeScheme = "123/123456";

            PayeSchemeObfuscator.Setup(x => x.ObscurePayeScheme(It.IsAny <string>()))
            .Returns(obscuredPayePayeScheme);

            _sut = new Services.AccountRepository(
                AccountApiClient.Object,
                PayeSchemeObfuscator.Object,
                DatetimeService.Object,
                Logger.Object,
                HashingService.Object);

            //Act
            var actual = await _sut.FindAllDetails(10, 1);

            //Assert
            AccountApiClient.Verify(x => x.GetPageOfAccounts(It.IsAny <int>(), It.IsAny <int>(), null), Times.Once);
            AccountApiClient.Verify(x => x.GetAccount(It.IsAny <string>()), Times.Exactly(2));
            Logger.Verify(x => x.Error(e, $"Exception occured in Account API type of {nameof(PayeSchemeViewModel)} at /api/payeschemes/test1 id 1"));
            Assert.IsNotNull(actual);
            var list = actual.ToList();

            CollectionAssert.IsNotEmpty(list);
            Assert.AreEqual(2, list.Count());
        }
Ejemplo n.º 26
0
        public async Task ItShouldReturnTheEntireListOfAccountsWhenAccountHasPayeScheme()
        {
            //Arrange
            AccountApiClient.Setup(x => x.GetPageOfAccounts(It.IsAny <int>(), 10, null))
            .ReturnsAsync(_pagedApiResponseViewModel);

            AccountApiClient
            .Setup(x => x.GetAccount(It.IsAny <string>()))
            .ReturnsAsync(new AccountDetailViewModel
            {
                PayeSchemes = new ResourceList(new[] { new ResourceViewModel {
                                                           Id = "1", Href = "/api/payeschemes/test1"
                                                       } })
            });

            AccountApiClient.Setup(x => x.GetResource <PayeSchemeViewModel>(It.IsAny <string>()))
            .ReturnsAsync(new PayeSchemeViewModel {
                Name = "Test", Ref = "123"
            });

            var obscuredPayePayeScheme = "123/123456";

            PayeSchemeObfuscator.Setup(x => x.ObscurePayeScheme(It.IsAny <string>()))
            .Returns(obscuredPayePayeScheme);

            _sut = new Services.AccountRepository(
                AccountApiClient.Object,
                PayeSchemeObfuscator.Object,
                DatetimeService.Object,
                Logger.Object,
                HashingService.Object);

            //Act
            var actual = await _sut.FindAllDetails(10, 1);

            //Assert
            AccountApiClient.Verify(x => x.GetPageOfAccounts(It.IsAny <int>(), It.IsAny <int>(), null), Times.Once);
            AccountApiClient.Verify(x => x.GetAccount(It.IsAny <string>()), Times.Exactly(2));
            Assert.IsNotNull(actual);
            var list = actual.ToList();

            CollectionAssert.IsNotEmpty(list);
            Assert.AreEqual(2, list.Count());
        }
Ejemplo n.º 27
0
        public async Task ItShouldReturnAZeroBalanceWhenTheClientThrowsAnException()
        {
            var id = "123";

            var exception = new Exception("Some exception");

            AccountApiClient
            .Setup(x => x.GetResource <AccountWithBalanceViewModel>($"/api/accounts/{id}"))
            .ThrowsAsync(exception);

            Logger.Setup(x => x.Debug(It.IsAny <string>()));
            Logger.Setup(x => x.Error(It.IsAny <Exception>(), It.IsAny <string>()));

            var actual = await _sut.GetAccountBalance(id);

            Logger.Verify(x => x.Debug(It.IsAny <string>()), Times.Never);
            Logger.Verify(x => x.Error(exception, $"Account Balance with id {id} not found"), Times.Once);

            Assert.AreEqual(0, actual);
        }
Ejemplo n.º 28
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);
        }
        public async Task ItShoudFailGracefullyAndLogErrorWhenClientThrowsExceptionOnGetResourceAccount()
        {
            var id = "123";


            AccountApiClient.Setup(x => x.GetResource <AccountDetailViewModel>($"/api/accounts/{id}"))
            .ThrowsAsync(new Exception());


            var actual = await _sut.Get(id, AccountFieldsSelection.Organisations);


            Logger.Verify(x => x.Debug(It.IsAny <string>()), Times.Once);
            Logger.Verify(x => x.Error(It.IsAny <Exception>(), It.IsAny <string>()), Times.Once);


            AccountApiClient.Verify(x => x.GetResource <AccountDetailViewModel>(It.IsAny <string>()), Times.Once);
            AccountApiClient.Verify(x => x.GetResource <LegalEntityViewModel>(It.IsAny <string>()), Times.Never);

            Assert.IsNull(actual);
        }
Ejemplo n.º 30
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);
        }
Ejemplo n.º 31
0
 internal AccountService(AccountApiClient apiClient)
 {
     this.apiClient = apiClient;
 }