Esempio n. 1
0
  @Test
  public void testSubmittignWord() throws Exception {
    System.out.println("TEST: submitting word");

    InputStream r = this.getClass().getClassLoader().getResourceAsStream("english-dictionary.txt");
    Dictionary dict = new Dictionary(r);

    HashMap dictionary = new HashMap();
    ArrayList<String> wordList = new ArrayList<>();

    try {
      BufferedReader bf =
          new BufferedReader(
              new InputStreamReader(
                  this.getClass()
                      .getClassLoader()
                      .getResourceAsStream(("english-dictionary.txt"))));
      String word;

      while ((word = bf.readLine()) != null) {
        dictionary.put(word, word);
      }

      Container.getInstance().setDictionary(dictionary);
      Container.getInstance().setWordList(wordList);

      OnePlayer.submitWord("I");
      OnePlayer.submitWord("three");
      OnePlayer.submitWord("tree");
      OnePlayer.submitWord("tree");
      System.out.println(wordList.toString());
    } catch (Exception e) {
      System.out.println("");
      System.out.println(e);
    }

    assertTrue(
        "The user can not submit the same word more than one time, the expected array size is 2",
        wordList.size() == 2);
  }