Each story has one game
        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));
        }
Ejemplo n.º 2
0
 public Game Get(int projectId, int storyId)
 {
     return Games.GetOrAdd(storyId, _ =>
     {
         var game = new Game();
         game.Consensus += score => _pivotal.EstimateStory(projectId, storyId, score);
         return game;
     });
 }
Ejemplo n.º 3
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;
 }
Ejemplo n.º 4
0
        public void GameAnnouncesConcensus()
        {
            var game = new Game();
            var returnedScore = -1;
            game.Consensus +=  score =>
            {
                returnedScore = score;
            };

            Play(game, "Rumples", 1);
            Play(game, "HappyCat", 1);

            Assert.That(returnedScore, Is.EqualTo(1));
        }
Ejemplo n.º 5
0
 private static void EnsurePlayerExists(Game game, string playerName)
 {
     if (!game.Players.Any(p => p.Name == playerName))
         game.AddPlayer(new Player { Name = playerName });
 }
Ejemplo n.º 6
0
            public Helper()
            {
                _pivotalMock = new Mock<IPivotal>();
                _gameRepositoryMock = new Mock<IGameRepository>();
                _gameStarterMock = new Mock<IGameStarter>();

                _pivotalMock.Setup(p => p.GetStory(ProjectId, StoryId)).Returns(new PivotalStory { Id = StoryId, ProjectId = ProjectId });
                _pivotalMock.Setup(p => p.GetProject(ProjectId)).Returns(new PivotalProject { PointScale = "0,1,2,3" });

                Game = new Game();
                _gameRepositoryMock.Setup(g => g.Get(ProjectId, StoryId)).Returns(Game);
            }
Ejemplo n.º 7
0
 public void GameIsIncompleteWhenConstructed()
 {
     var game = new Game();
     Assert.That(game.IsComplete, Is.False);
 }
Ejemplo n.º 8
0
 public void CanAddUserToGame()
 {
     var game = new Game();
     game.AddPlayer(new Player {Name = "Rumples"});
     Assert.That(game.Players, Has.Count.EqualTo(1));
 }
Ejemplo n.º 9
0
 private static Game Play(Game game, string playerName, int score)
 {
     return OM.GameM.Play(game, playerName, score);
 }
Ejemplo n.º 10
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));
        }