AddPlayer() 공개 메소드

public AddPlayer ( Player player ) : void
player Player
리턴 void
        public void VoteMayCauseGameConsensus()
        {
            const int points = 0, projectId = 123, storyId = 456;

            var gameRepositoryMock = new Mock<IGameRepository>();
            var gameStarterMock = new Mock<IGameStarter>();

            gameStarterMock.Setup(o => o.Name).Returns("Rumples");

            var returnedScore = -1;
            var game = new Game();
            game.Consensus += score => returnedScore = score;

            var james = new Player { Name = "James" };
            game.AddPlayer(james);
            game.Play(new Card { Player = james, Points = points });

            var rumples = new Player { Name = "Rumples" };
            game.AddPlayer(rumples);

            gameRepositoryMock.Setup(g => g.Get(projectId, storyId)).Returns(game);

            var c = new StoryController(null, gameRepositoryMock.Object, gameStarterMock.Object);
            c.Vote(projectId, storyId, points);

            Assert.That(returnedScore, Is.EqualTo(points));
        }
예제 #2
0
 private static void EnsurePlayerExists(Game game, string playerName)
 {
     if (!game.Players.Any(p => p.Name == playerName))
         game.AddPlayer(new Player { Name = playerName });
 }
예제 #3
0
 public void CanAddUserToGame()
 {
     var game = new Game();
     game.AddPlayer(new Player {Name = "Rumples"});
     Assert.That(game.Players, Has.Count.EqualTo(1));
 }
예제 #4
0
        public void PlayerCanPlayACard()
        {
            var game = new Game();
            var player = new Player {Name = "Rumples"};
            game.AddPlayer(player);

            var card = new Card {Player = player, Points = 0};
            game.Play(card);

            var cards = game.GetCards();
            var result = cards.First();
            Assert.That(result.Player.Name, Is.EqualTo(player.Name));
            Assert.That(result.Points, Is.EqualTo(card.Points));
        }