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 InitializePlayer() { // 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); // Assert Investment investment = engine.GetCurrentInvestmentForPlayer(player.Name); Assert.That(investment.Symbol, Is.EqualTo(randomSymbol)); Assert.That(investment.PlayerName, Is.EqualTo(player.GetType().Name)); Assert.That(investment.PurchaseDate, Is.GreaterThan(DateTime.Today)); Assert.That(investment.PurchasePrice, Is.EqualTo(quote.LastTradePrice.Value)); }