public ActionResult Create(CreatePlayerViewModel player) { var newPlayer = new Player(player.Name); Players.Add(newPlayer); PlayersData.PersistPlayer(newPlayer); return Redirect("~/Players"); }
public void CanRetrieveGamesPlayedByAParticularPlayer() { var game1 = new Game { Winner = "A", Loser = "B" }; var game2 = new Game { Winner = "A", Loser = "C" }; var game3 = new Game { Winner = "B", Loser = "C" }; Games.Initialise(new[] { game1, game2, game3 }); var expected = new List<Game> { game2, game3 }; var player = new Player("C"); Assert.AreEqual(expected, Games.ByPlayer(player)); }
public static IEnumerable<Game> ByPlayer(Player player) { return _games.Where(game => game.Winner == player.Name || game.Loser == player.Name); }
public void CanPersistAndRetrievePlayer() { var player = new Player("Test", DateTime.UtcNow); var playerString = player.Serialize(); var deserializedPlayer = Player.Deserialize(playerString); Assert.AreEqual(player, deserializedPlayer); }
private void InitialiseTestPlayers() { var peter = new Player("Peter", DateTime.MinValue); var frank = new Player("Frank", DateTime.MinValue); var richard = new Player("Richard", DateTime.MinValue); var bob = new Player("Bob", DateTime.MinValue); Players.Initialise(new[] {peter, frank, richard, bob}); }
protected bool Equals(Player other) { return CreatedTime.Equals(other.CreatedTime) && string.Equals(Name, other.Name); }
public ActionResult Create(Player player) { Players.Add(Player.CreateInitial(player.Name, false)); PlayersData.PersistPlayer(player); return Redirect("/Players"); }
public static void PersistPlayer(Player player) { var playerEntity = new PlayerEntity(account, player.Name, player.IsRetired); var table = GetTable("players"); WritePlayer(table, playerEntity); }
public static void PersistPlayer(Player player) { File.AppendAllText(_path, player.Serialize() + "\n"); }
public static void Add(Player player) { _players.Add(player.Name, player); }
public static Player CreateInitial(string name, bool isRetired) { var player = new Player { Name = name, IsRetired = isRetired }; player.AddRating(InitialRating); return player; }