public void AddTransaction_CategoryPredecessor_AddsSecondTransactionToOriginalTransactions() { var firstEntryDescription = _fixture.Create <string>(); var firstEntryAmount = _fixture.Create <decimal>(); var firstEntryYearMonth = YearMonth.FromDateTime(_fixture.Create <DateTime>()); var firstEntryTransactionDirection = _fixture.Create <TransactionDirection>(); _sut.AddTransaction(firstEntryDescription, firstEntryAmount, firstEntryYearMonth, firstEntryTransactionDirection); var secondEntryDescription = _fixture.Create <string>(); var secondEntryAmount = _fixture.Create <decimal>(); var secondEntryYearMonth = YearMonth.FromDateTime(_fixture.Create <DateTime>()); var secondEntryTransactionDirection = _fixture.Create <TransactionDirection>(); _sut.AddTransaction(secondEntryDescription, secondEntryAmount, secondEntryYearMonth, secondEntryTransactionDirection); _sut.OriginalTransactions.Should().HaveCount(2); _sut.OriginalTransactions.Should().Contain(x => x.Description == firstEntryDescription && x.Amount == firstEntryAmount && x.TransactionDirection == firstEntryTransactionDirection && x.YearMonth == firstEntryYearMonth); _sut.OriginalTransactions.Should().Contain(x => x.Description == secondEntryDescription && x.Amount == secondEntryAmount && x.TransactionDirection == secondEntryTransactionDirection && x.YearMonth == secondEntryYearMonth); }
public void AddTransaction_CategoryPredecessor_AddsAmountToExistingTransactionPerMonthYear() { var expectedAmount = _fixture.Create <decimal>(); var expectedYearMonth = YearMonth.FromDateTime(_fixture.Create <DateTime>()); var expectedTransactionDirection = _fixture.Create <TransactionDirection>(); _sut.AddTransaction(_fixture.Create <string>(), expectedAmount, expectedYearMonth, expectedTransactionDirection); _sut.AddTransaction(_fixture.Create <string>(), expectedAmount, expectedYearMonth, expectedTransactionDirection); _sut.TransactionsPerMonthYear.Should().ContainSingle(); var transaction = _sut.TransactionsPerMonthYear.Single(); transaction.Amount.Should().Be(expectedAmount + expectedAmount); }
public void AddTransaction_NoPredecessor_AddsTransactionToOriginalTransactions() { var expectedDescription = _fixture.Create <string>(); var expectedAmount = _fixture.Create <decimal>(); var expectedYearMonth = YearMonth.FromDateTime(_fixture.Create <DateTime>()); var expectedTransactionDirection = _fixture.Create <TransactionDirection>(); _sut.AddTransaction(expectedDescription, expectedAmount, expectedYearMonth, expectedTransactionDirection); _sut.OriginalTransactions.Should().ContainSingle(); var transaction = _sut.OriginalTransactions.Single(); transaction.Description.Should().Be(expectedDescription); transaction.Amount.Should().Be(expectedAmount); transaction.YearMonth.Should().Be(expectedYearMonth); transaction.TransactionDirection.Should().Be(expectedTransactionDirection); }
public HouseholdBook CreateHouseholdBook() { var transactions = _transactionProvider.ProvideTransactions(); var householdBook = new HouseholdBook(); foreach (Banktransaction transaction in transactions.ToList()) { var category = _transactionCategorizer.DetermineCategory(transaction.Description); var householdPost = householdBook.RetrieveHouseholdPost(category); householdPost.AddTransaction(transaction.Description, transaction.Amount, YearMonth.FromDateTime(transaction.Date), transaction.TransactionDirection); transactions.Remove(transaction); } return(householdBook); }