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));
        }
Esempio n. 2
0
 public static Game Play(Game game, string playerName, int points)
 {
     if (game == null)
         game = new Game();
     var rumples = new Player { Name = playerName };
     game.AddPlayer(rumples);
     var card = new Card { Player = rumples, Points = points };
     game.Play(card);
     return game;
 }
        public void CanGetGameInProgress()
        {
            var gameRepository = new GameRepository(null);
            const int storyId = 0;
            var game = gameRepository.Get(-1, storyId);

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

            game = gameRepository.Get(-1, storyId);
            Assert.That(game.Players, Has.Count.EqualTo(1));
        }
Esempio n. 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));
        }
Esempio n. 5
0
 public void AddPlayer(Player player)
 {
     Players.Add(player);
 }