public async Task When_requesting_transaction_import_for_user_with_multiple_accounts_all_account_transactions_are_imported_for_default_time_period() { // Arrange SetupDependencies(); TransactionsImporter target = BuildTarget(); SetupUserAccountTwo(); // Act var result = await target.ImportTransactionsAsync(user.Identifier); // Assert result.AccountsImported.Count.Should().Be(2); result.AccountsImported.First().TransactionsImported.Should().Be(15); result.AccountsImported.Skip(1).First().TransactionsImported.Should().Be(13); bankDataProvider.Verify(s => s.GetAccountTransactionsAsync(user, userAccountOne, now.Date.AddYears(-1).AddDays(1), now.Date), Times.Once); bankDataProvider.Verify(s => s.GetAccountTransactionsAsync(user, userAccountOne, now.Date.AddYears(-2).AddDays(1), now.Date.AddYears(-1)), Times.Once); bankDataProvider.Verify(s => s.GetAccountTransactionsAsync(user, userAccountOne, now.Date.AddYears(-3).AddDays(1), now.Date.AddYears(-2)), Times.Once); bankDataProvider.Verify(s => s.GetAccountTransactionsAsync(user, userAccountTwo, now.Date.AddYears(-1).AddDays(1), now.Date), Times.Once); bankDataProvider.Verify(s => s.GetAccountTransactionsAsync(user, userAccountTwo, now.Date.AddYears(-2).AddDays(1), now.Date.AddYears(-1)), Times.Once); bankDataProvider.Verify(s => s.GetAccountTransactionsAsync(user, userAccountTwo, now.Date.AddYears(-3).AddDays(1), now.Date.AddYears(-2)), Times.Once); transactionsStore.Verify(s => s.AddAccount(user, userAccountOne), Times.Once); transactionsStore.Verify(s => s.AddTransactions(userAccountOne, It.IsAny <IList <Transaction> >()), Times.Exactly(3)); transactionsStore.Verify(s => s.AddAccount(user, userAccountTwo), Times.Once); transactionsStore.Verify(s => s.AddTransactions(userAccountTwo, It.IsAny <IList <Transaction> >()), Times.Exactly(3)); }
public async Task When_requesting_transaction_correct_number_of_transactions_are_imported_for_default_period(int defaultPeriod, int transactionsImported) { // Arrange SetupDependencies(); dataImportOptions.Setup(o => o.CurrentValue).Returns(new DataImportOptions() { MaxHistoricalTransactionToRetrieveInYears = defaultPeriod }); TransactionsImporter target = BuildTarget(); // Act var result = await target.ImportTransactionsAsync(user.Identifier); // Assert result.AccountsImported.Count.Should().Be(1); result.AccountsImported.First().TransactionsImported.Should().Be(transactionsImported); }