public void GivenNoStocksCalculateAllShareIndexReturnZero() { var stocks = new List <Stock>(); IStockService stockService = new StockService(stocks); const int expected = 0; var actual = stockService.CalculateAllShareIndex(); Assert.AreEqual(expected, actual); }
public void GivenAListOfStocksCalculateAllShareIndex() { var stocks = TestData.GetListOfEasyGeometricCalcStocks(); IStockService stockService = new StockService(stocks); const int marketPriceOne = 100; const int marketPriceTwo = 200; const int stockCount = 2; double expectedValue = marketPriceOne * marketPriceTwo; expectedValue = Math.Pow(expectedValue, 1.0 / stockCount); var actualValue = stockService.CalculateAllShareIndex(); Assert.AreEqual(expectedValue, actualValue); }