Пример #1
0
  /** Test if the "Clear" works in TextBuddy.java */
  @Test
  public void testClear() {
    TextBuddy textBuddy = new TextBuddy("clear.txt");
    String fileName = textBuddy.getFileName();
    String command = textBuddy.executeCommand("clear", "", fileName);
    String expectedOutput = "all content deleted from " + fileName;

    assertEquals(true, command.equals(expectedOutput));
  }
Пример #2
0
  /** Test if the "Add" works in TextBuddy.java */
  @Test
  public void testAdd() {
    TextBuddy textBuddy = new TextBuddy("add.txt");
    String fileName = textBuddy.getFileName();
    String addLine = "hello my world";
    String command = textBuddy.executeCommand("add", addLine, fileName);
    String expectedOutput = "added to " + fileName + ": \"" + "hello my world" + "\"";

    assertEquals(true, command.equals(expectedOutput));
  }
Пример #3
0
  /** Test if the "Delete" works in TextBuddy.java */
  @Test
  public void testDelete() {
    TextBuddy textBuddy = new TextBuddy("delete.txt");
    String fileName = textBuddy.getFileName();
    String numLine = "2";
    String command = textBuddy.executeCommand("delete", numLine, fileName);
    String deletedLine = "deleted from " + fileName + ": \"" + "why delete me" + "\"";

    assertEquals(true, command.equals(deletedLine));
  }