public async Task WhenGettingAccountFromFairWayBank() { var provider = new FairWayBankAccountProvider(new FairWayBankClient(new OptionsWrapper <FairWayBankConfiguration>(new FairWayBankConfiguration { BaseUrl = "https://fairwaybank-bizfitech.azurewebsites.net/api/v1/" })), new MapperConfiguration(x => x.AddProfile <FairWayBankAccountToAccountProfile>()).CreateMapper()); _result = await provider.TryGetAccount("12345678", CancellationToken.None); }
public async Task WhenGettingAccount() { var accountNumber = "12345678"; var stubHttpMessageHandler = new StubHttpMessageHandlerBuilder().WithResponse(new Uri($"https://test.local/accounts/{accountNumber}"), _response, HttpStatusCode.NotFound) .Build(); var httpClient = new HttpClient(stubHttpMessageHandler) { BaseAddress = new Uri("https://test.local") }; var mapper = Substitute.For <IMapper>(); var bizfiBankAccountProvider = new FairWayBankAccountProvider(httpClient, mapper); _result = await bizfiBankAccountProvider.TryGetAccount(accountNumber, new CancellationToken()); }
public async Task WhenGettingAccount() { var accountNumber = "12345678"; _expected = new Account(); var stubHttpMessageHandler = new StubHttpMessageHandlerBuilder().WithResponse(new Uri($"https://test.local/accounts/{accountNumber}"), _accountResponse) .WithResponse(new Uri($"https://test.local/accounts/{accountNumber}/balance"), _balanceResponse) .Build(); var client = new HttpClient(stubHttpMessageHandler); var httpClient = client; httpClient.BaseAddress = new Uri("https://test.local"); _mapper = Substitute.For <IMapper>(); _mapper.Map <Account>(Arg.Any <FairWayTest.Api.Infrastructure.AccountProviders.FairWayBank.Responses.Account>()).Returns(_expected); _mapper.Map(Arg.Any <FairWayTest.Api.Infrastructure.AccountProviders.FairWayBank.Responses.Balance>(), _expected).Returns(_expected); _fairWayBankAccountProvider = new FairWayBankAccountProvider(httpClient, _mapper); _result = await _fairWayBankAccountProvider.TryGetAccount(accountNumber, new CancellationToken()); }