public ActionResult Index() { List<PlayerViewModel> players = new List<PlayerViewModel>(); StockEngine engine = new YahooStockEngine(); // Chris Player player = new Chris(); Investment investment = engine.GetCurrentInvestmentForPlayer(player.Name); Quote quote = engine.GetCurrentQuoteForPlayer(player.Name); PlayerViewModel model = new PlayerViewModel(investment, quote, player); players.Add(model); // Fiona player = new Fiona(); investment = engine.GetCurrentInvestmentForPlayer(player.Name); quote = engine.GetCurrentQuoteForPlayer(player.Name); model = new PlayerViewModel(investment, quote, player); players.Add(model); // Wilson player = new Wilson(); investment = engine.GetCurrentInvestmentForPlayer(player.Name); quote = engine.GetCurrentQuoteForPlayer(player.Name); model = new PlayerViewModel(investment, quote, player); players.Add(model); // Katherine player = new Katherine(); investment = engine.GetCurrentInvestmentForPlayer(player.Name); quote = engine.GetCurrentQuoteForPlayer(player.Name); model = new PlayerViewModel(investment, quote, player); players.Add(model); // Jon player = new Jon(); investment = engine.GetCurrentInvestmentForPlayer(player.Name); quote = engine.GetCurrentQuoteForPlayer(player.Name); model = new PlayerViewModel(investment, quote, player); players.Add(model); return View(players); }
public void GetCurrentQuoteForPlayer() { // Arrange StockEngine engine = new YahooStockEngine(); IEnumerable<string> symbols = engine.LoadSymbolsFromTextFile("aim.txt"); string randomSymbol = engine.PickRandomSymbol(symbols); Quote quote = engine.LookupPrice(randomSymbol); decimal walletSize = 400; // £400 Player player = new Chris(); // Act engine.InsertQuote(quote); engine.InitializePlayer(player, quote, walletSize); Quote currentQuote = engine.GetCurrentQuoteForPlayer(player.Name); // Assert Assert.That(currentQuote.Id, Is.EqualTo(quote.Id)); Assert.That(currentQuote.Symbol, Is.EqualTo(quote.Symbol)); Assert.That(currentQuote.LastTradePrice, Is.EqualTo(quote.LastTradePrice)); }