Skip to content

Commit

Permalink
test: 종목과 매입이력의 연간 예상 배당금 합계 테스트 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
yonghwankim-dev committed Oct 17, 2024
1 parent b5ed669 commit 135b92f
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1209,4 +1209,23 @@ void calTotalInvestment_givenPurchaseHistories_whenCalTotalInvestment_thenReturn
assertThat(actual).isEqualByComparingTo(expected);
}

@DisplayName("종목과 매입이력들이 주어졌을때 연간 예상되는 배당금 합계를 계산한다")
@Test
void calAnnualExpectedDividend_givenStockAndPurchaseHistories_whenCalAnnualExpectedDividend_thenReturnSumOfDividend() {
Portfolio portfolio = createPortfolio(createMember());
Stock stock = createSamsungStock();
long currentPrice = 50_000L;
currentPriceRepository.savePrice(stock, currentPrice);
createStockDividendWith(stock).forEach(stock::addStockDividend);
PortfolioHolding holding = createPortfolioHolding(portfolio, stock);
PurchaseHistory history = createPurchaseHistory(null, LocalDateTime.now(), Count.from(3), Money.won(40000L),
"메모", holding);
holding.addPurchaseHistory(history);
portfolio.addHolding(holding);
// when
Expression actual = calculator.calAnnualExpectedDividend(stock, List.of(history));
// then
Expression expected = Money.won(1083);
assertThat(actual).isEqualByComparingTo(expected);
}
}

0 comments on commit 135b92f

Please sign in to comment.