Ejemplo n.º 1
0
        public void TestRemovePlayerByID()
        {
            IHangmanRepository repository = HangmanRepositoryFactory.CreateRepository();
            int         playerID          = repository.GetPlayerID("player1");
            GamesResult gamesResult;

            if (playerID == 0)
            {
                //Add player
                repository.AddPlayer("player1", "password");
                playerID = repository.GetPlayerID("player1");
            }

            gamesResult = repository.GetGamesResultForPlayer(playerID);
            if (gamesResult.NumberOfGames == 0)
            {
                int wordID = repository.GetWords(1)[0];
                repository.RecordGame(playerID, wordID, 3, 3, true);
                gamesResult = repository.GetGamesResultForPlayer(playerID);
            }
            Assert.IsTrue(gamesResult.NumberOfGames > 0);
            Assert.IsTrue(gamesResult.NumberOfSuccess > 0);

            Assert.IsTrue(playerID > 0);

            repository.RemovePlayerByID(playerID);

            int id2 = repository.GetPlayerID("player1");

            gamesResult = repository.GetGamesResultForPlayer(playerID);
            Assert.IsTrue(id2 == 0);
            Assert.IsTrue(gamesResult.NumberOfGames == 0);
        }
Ejemplo n.º 2
0
        public static GamesResult GetGamesResult(string username)
        {
            IHangmanRepository repository = HangmanRepositoryFactory.CreateRepository();
            int         playerID          = repository.GetPlayerID(username);
            GamesResult result            = repository.GetGamesResultForPlayer(playerID);

            return(result);
        }