コード例 #1
0
  @Test
  public void testInvalidCommand() {

    // Boundary case: wrong command
    Command command = parser.build("delete 1-5");
    Assert.assertTrue(command instanceof InvalidCommand);
    command = parser.build("add hello");
    Assert.assertTrue(command instanceof InvalidCommand);
    command = parser.build("add hello 3words");
    Assert.assertTrue(command instanceof InvalidCommand);

    // Boundary case: insufficient arguments
    command = parser.build("rename");
    Assert.assertTrue(command instanceof InvalidCommand);
    command = parser.build("rename oneword");
    Assert.assertTrue(command instanceof InvalidCommand);
    command = parser.build("rename 1");
    Assert.assertTrue(command instanceof InvalidCommand);

    // Boundary case: empty string
    command = parser.build("");
    Assert.assertTrue(command instanceof InvalidCommand);

    // Boundary case: null
    command = parser.build(null);
    Assert.assertTrue(command instanceof InvalidCommand);
  }
コード例 #2
0
  @Test
  public void testValidCommand() {
    Command command = parser.build("rename 1 happy");
    Assert.assertTrue(command instanceof RenameTaskCommand);
    RenameTaskCommand renameCommand = (RenameTaskCommand) command;
    assertSameFields(renameCommand, 1, "happy");

    command = parser.build("rename 123 12345");
    Assert.assertTrue(command instanceof RenameTaskCommand);
    renameCommand = (RenameTaskCommand) command;
    assertSameFields(renameCommand, 123, "12345");

    command = parser.build("rename 100232132 2 or more words");
    Assert.assertTrue(command instanceof RenameTaskCommand);
    renameCommand = (RenameTaskCommand) command;
    assertSameFields(renameCommand, 100232132, "2 or more words");
  }