public void AddCardToHandTest() { var id = "TestPlayerCardAdd"; int gameId = 22; int cardId = 1111; var player = _repository.CreatePlayer(id); // create test player Set deck = new Set(); // create deck for test game Card card = new Card() // create a card and add it { CardId = cardId, }; deck.Cards.Add(card); _repository.AddGame(gameId, deck); // add game to database // Act _service.AddCardToHand(cardId, id); // Assert Assert.Contains(card, player.Hand); // card should be in player's hand }
public void GetUserIdTest() { string userId = "TestUser"; _repository.CreatePlayer(userId); var httpContext = _authRepository.CreateFakeContext(userId); // Act var response1 = _service.GetUserId(httpContext); // should return playerId httpContext (claim) was created with _repository.RemovePlayer(userId); var response2 = _service.GetUserId(httpContext); // should return null as player does not exist anymore // Assert Assert.Equal(userId, response1); // should have returned correct id Assert.Null(response2); // check for player's existence should have failed }
public Player CreatePlayer(string playerId) { Player player = _repository.CreatePlayer(playerId); return(player); }