示例#1
0
        /// <summary>
        /// Adds a new player to the game.
        /// </summary>
        public void AddPlayer(Player player)
        {
            if (Players.Count > 9)
                throw new Exception("Too many players already in the game.");
            if (Started)
                throw (new Exception("Can't join game that has already started."));

            Players.Add(player);
        }
示例#2
0
        public void AddPlayer_AddsNewPlayerToTheGame()
        {
            var id = "{E6AB01BE-E623-492C-8390-01786604DD14}";
            var name = "Bob";
            var newPlayer = new Player(id, name);

            _gameState.AddPlayer(newPlayer);

            Assert.That(_gameState.Players.Contains(newPlayer), Is.True);
            Assert.AreEqual(_gameState.Players.First().Id, id);
            Assert.AreEqual(_gameState.Players.First().Name, name);
        }