public void Test_open_should_return_total_stocks_quantity() { StockHistory history = new StockHistory(); Quote quote = new Quote(2, 4); Broker broker = new Broker(50); Investment investment = new Investment(history, broker); DateTime openDate = new DateTime(2020, 2, 10); DateTime closeDate = new DateTime(2020, 4, 10); DateTime februaryBuyDate = new DateTime(2020, 2, 28); DateTime marchBuyDate = new DateTime(2020, 3, 27); double stocksQuantity = 10; double amount = 20; history.Add(februaryBuyDate, quote); history.Add(marchBuyDate, quote); Assert.AreEqual(stocksQuantity, investment.Open(openDate, closeDate, amount)); }
public void Test_limit_date_to_buy_stocks() { InvestmentDateCalculator investmentDate = new InvestmentDateCalculator(); StockHistory history = new StockHistory(); DateTime referenceDate = new DateTime(2017, 12, 23); DateTime limitDate = new DateTime(2017, 12, 28); history.Add(limitDate, new Quote(1, 2)); Assert.AreEqual(limitDate, investmentDate.GetBuyDate(referenceDate, history, limitDate)); }
public void Test_if_return_the_next_quote_day() { InvestmentDateCalculator investmentDate = new InvestmentDateCalculator(); StockHistory history = new StockHistory(); Quote quote = new Quote(2, 1); DateTime referenceDate = new DateTime(2020, 1, 1); DateTime buyDate = new DateTime(2020, 1, 31); DateTime limitDate = new DateTime(2020, 2, 1); history.Add(buyDate, quote); Assert.AreEqual(buyDate, investmentDate.GetBuyDate(referenceDate, history, limitDate)); }
public void Test_if_28_is_the_buy_date_of_february_2020() { InvestmentDateCalculator investmentDate = new InvestmentDateCalculator(); StockHistory history = new StockHistory(); Quote quote = new Quote(2, 4); DateTime referenceDate = new DateTime(2020, 2, 1); DateTime buyDate = new DateTime(2020, 2, 28); DateTime limitDate = new DateTime(2020, 2, 29); history.Add(buyDate, quote); Assert.AreEqual(buyDate, investmentDate.GetBuyDate(referenceDate, history, limitDate)); }
public void Test_should_true_quote_exists_in_a_day() { StockHistory history = new StockHistory(); Quote quote = new Quote(2, 4); DateTime date = new DateTime(2010, 2, 24); DateTime sameDate = new DateTime(2010, 2, 24); DateTime dateNotExist = new DateTime(2020, 8, 9); history.Add(date, quote); Assert.IsTrue(history.HasQuoteOnDate(date)); Assert.IsTrue(history.HasQuoteOnDate(sameDate)); Assert.IsFalse(history.HasQuoteOnDate(dateNotExist)); }
public void Test_close_should_return_total_investment_amount() { StockHistory history = new StockHistory(); Quote quote = new Quote(1, 2); Broker broker = new Broker(0); Investment investment = new Investment(history, broker); DateTime closeDate = new DateTime(2020, 3, 1); Wallet wallet = new Wallet(); wallet.AddStocks(10); double totalPrice = 20; history.Add(closeDate, quote); Assert.AreEqual(totalPrice, investment.Close(wallet, closeDate)); }