public void ZeroLastDividendCalculatePERatioReturnNullTest() { var stock = TestData.GetTestCommonStock(); stock.LastDividend = 0; var stockService = new StocksService(); const double marketPrice = 100; double? expected = null; var actual = stockService.GetPERatio(stock, marketPrice); Assert.AreEqual(expected, actual); }
static void GivenMarketPriceAsInputCalculateProfitEarningRatio(double marketPrice) { foreach (var stock in _stockService._stockRepository.GetAll()) { double ProfitToEarningsRatio = _stockService.GetPERatio(stock.Symbol, marketPrice); Console.WriteLine("------"); Console.WriteLine(stock + " " + "The P/E Ratio is " + ProfitToEarningsRatio); } Console.WriteLine("Completed P/E Ratio"); Console.WriteLine("------------------------------------"); Console.WriteLine(); }
public void GetPERatioTest() { var stock = TestData.GetTestCommonStock(); var stockService = new StocksService(); const double marketPrice = 989; const double lastDividend = 2.54; const double expectedValue = marketPrice / lastDividend; var actualValue = stockService.GetPERatio(stock, marketPrice); Assert.AreEqual(expectedValue, actualValue); }