Exemplo n.º 1
0
 public ActionResult Create(CreatePlayerViewModel player)
 {
     var newPlayer = new Player(player.Name);
     Players.Add(newPlayer);
     PlayersData.PersistPlayer(newPlayer);
     return Redirect("~/Players");
 }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
Arquivo: Games.cs Projeto: MSIH/ELO
 public static IEnumerable<Game> ByPlayer(Player player)
 {
     return _games.Where(game => game.Winner == player.Name || game.Loser == player.Name);
 }
Exemplo n.º 4
0
        public void CanPersistAndRetrievePlayer()
        {
            var player = new Player("Test", DateTime.UtcNow);
            var playerString = player.Serialize();
            var deserializedPlayer = Player.Deserialize(playerString);

            Assert.AreEqual(player, deserializedPlayer);
        }
Exemplo n.º 5
0
        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});
        }
Exemplo n.º 6
0
Arquivo: Player.cs Projeto: MSIH/ELO
 protected bool Equals(Player other)
 {
     return CreatedTime.Equals(other.CreatedTime) && string.Equals(Name, other.Name);
 }
Exemplo n.º 7
0
 public ActionResult Create(Player player)
 {
     Players.Add(Player.CreateInitial(player.Name, false));
     PlayersData.PersistPlayer(player);
     return Redirect("/Players");
 }
Exemplo n.º 8
0
 public static void PersistPlayer(Player player)
 {
     var playerEntity = new PlayerEntity(account, player.Name, player.IsRetired);
     var table = GetTable("players");
     WritePlayer(table, playerEntity);
 }
Exemplo n.º 9
0
 public static void PersistPlayer(Player player)
 {
     File.AppendAllText(_path, player.Serialize() + "\n");
 }
Exemplo n.º 10
0
 public static void Add(Player player)
 {
     _players.Add(player.Name, player);
 }
Exemplo n.º 11
0
 public static Player CreateInitial(string name, bool isRetired)
 {
     var player = new Player { Name = name, IsRetired = isRetired };
     player.AddRating(InitialRating);
     return player;
 }