Skip to content

Commit

Permalink
Merge pull request #213 from bnjm2000/BenjaminNg-FixEventDelete
Browse files Browse the repository at this point in the history
  • Loading branch information
JoanneJo authored Nov 13, 2023
2 parents 8943405 + a47792c commit 2afc778
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public CommandResult execute(String statement, GenericList<Resource, Event> cont
throws IllegalArgumentException, IllegalStateException, SysLibException {
feedbackToUser = "";
String[] values = parseArgument(statement);
validateStatement(statement, values);
int index = parseCalendarInt(values[0], container);
System.out.println("This event is removed:");
System.out.println(container.getEventsList().get(index).toString());
Expand Down
16 changes: 15 additions & 1 deletion src/test/java/seedu/commands/events/EventDeleteCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,21 @@ public void eventDeleteCommandOutOfBounds() throws SysLibException {
}

@Test
public void eventDeleteCommandEmpty() throws SysLibException{
public void eventDeleteCommandEmpty(){
assertThrows(SysLibException.class, ()->eventDeleteCommand.execute("/id 0", parser.container));
}

@Test
public void eventDeleteDuplicateID() throws SysLibException{
eventAddCommand.execute("/t test1 /date 1 dec 2001 /desc testing 123", parser.container);
eventAddCommand.execute("/t test2 /date 2 dec 2001 /desc testing 456", parser.container);
assertThrows(IllegalArgumentException.class, ()->eventDeleteCommand.execute("/id 0 /id 1", parser.container));
}

@Test
public void eventDeleteInvalidArgument() throws SysLibException{
eventAddCommand.execute("/t test1 /date 1 dec 2001 /desc testing 123", parser.container);
eventAddCommand.execute("/t test2 /date 2 dec 2001 /desc testing 456", parser.container);
assertThrows(IllegalArgumentException.class, ()->eventDeleteCommand.execute("not /id 0", parser.container));
}
}

0 comments on commit 2afc778

Please sign in to comment.