Example #1
0
 public ActionResult Create(CreatePlayerViewModel player)
 {
     var newPlayer = new Player(player.Name);
     Players.Add(newPlayer);
     PlayersData.PersistPlayer(newPlayer);
     return Redirect("~/Players");
 }
Example #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));
        }
Example #3
0
File: Games.cs Project: MSIH/ELO
 public static IEnumerable<Game> ByPlayer(Player player)
 {
     return _games.Where(game => game.Winner == player.Name || game.Loser == player.Name);
 }
Example #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);
        }
Example #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});
        }
Example #6
0
File: Player.cs Project: MSIH/ELO
 protected bool Equals(Player other)
 {
     return CreatedTime.Equals(other.CreatedTime) && string.Equals(Name, other.Name);
 }
Example #7
0
 public ActionResult Create(Player player)
 {
     Players.Add(Player.CreateInitial(player.Name, false));
     PlayersData.PersistPlayer(player);
     return Redirect("/Players");
 }
Example #8
0
 public static void PersistPlayer(Player player)
 {
     var playerEntity = new PlayerEntity(account, player.Name, player.IsRetired);
     var table = GetTable("players");
     WritePlayer(table, playerEntity);
 }
Example #9
0
 public static void PersistPlayer(Player player)
 {
     File.AppendAllText(_path, player.Serialize() + "\n");
 }
Example #10
0
 public static void Add(Player player)
 {
     _players.Add(player.Name, player);
 }
Example #11
0
 public static Player CreateInitial(string name, bool isRetired)
 {
     var player = new Player { Name = name, IsRetired = isRetired };
     player.AddRating(InitialRating);
     return player;
 }