public void TestWordByID() { IHangmanRepository repository = HangmanRepositoryFactory.CreateRepository(); string word = repository.GetWordByID(13)[0]; Assert.IsNotNull(word); Assert.AreEqual("Seattle", word); }
public Game(int categoryID, string username) { this.categoryID = categoryID; repository = HangmanRepositoryFactory.CreateRepository(); int[] wordIDs = repository.GetWords(categoryID); this.playerID = repository.GetPlayerID(username); Random rnd = new Random(); int n = rnd.Next(wordIDs.Length - 1); wordID = wordIDs[n]; string[] wordInfo = repository.GetWordByID(wordID); Word = wordInfo[0]; Description = wordInfo[1]; StringBuilder sb = new StringBuilder(); sb.Append(Word[0]); for (int i = 1; i < Word.Length - 1; i++) { sb.Append("_"); } sb.Append(Word[Word.Length - 1]); GuessedWord = sb.ToString(); sb.Clear(); sb.Append(GuessedWord[0]); for (int i = 1; i < GuessedWord.Length; i++) { sb.Append(" " + GuessedWord[i]); } DisplayWord = sb.ToString(); WrongChars = ""; WrongCharsCount = 0; Status = ""; }