Exemple #1
0
        public Game CreateGame()
        {
            Set set = _repository.CreateSet();

            if (!_repository.CreateCards(set))
            {
                return(null);
            }

            Random random = new Random();
            int    gameId = random.Next(1000, 9999);

            while (_repository.GetGame(gameId) != null)
            {
                gameId = random.Next(1000, 9999);
            }

            if (!_repository.AddGame(gameId, set))
            {
                return(null);
            }

            return(_repository.GetGames().Find(g => g.GameId == gameId));
        }
Exemple #2
0
        public void PlayCardTest()
        {
            string playerId = "PlayCardTestPlayer";
            var    player   = _repository.CreatePlayer(playerId);

            Set set = _repository.CreateSet();

            _repository.CreateCards(set);
            var cards  = set.Cards as List <Card>;
            var card   = cards[0];
            var cardId = card.CardId;

            player.Hand.Add(card);
            _repository.SaveChanges();

            // Act
            var playedCard = _service.PlayCard(playerId, cardId);

            // Assert
            Assert.Equal(card, playedCard);
            Assert.DoesNotContain(card, player.Hand);
            Assert.Null(card.PlayerId);
            Assert.Null(card.Player);
        }