Skip to content

Commit

Permalink
Merge pull request nus-cs2113-AY2021S1#57 from weisiong24/Feature2-Junit
Browse files Browse the repository at this point in the history
Feature2 junit
  • Loading branch information
yeapcl authored Oct 14, 2020
2 parents 401c86f + 45fd0b0 commit 5e76fb3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/seedu/duke/command/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void execute(UserList users, Ui ui, User nowUser/*, Storage storage*/) th
String[] timeInputs = parsedInputs[3].split("-", 2);

String day = parsedInputs[2].toLowerCase().trim();

assert timeInputs[0].length() == 4 : "Wrong Start time format specified";
assert day.length() == 3 : "Wrong format of day entered";

Expand All @@ -48,7 +48,7 @@ public void execute(UserList users, Ui ui, User nowUser/*, Storage storage*/) th

for (int i = 0; i < users.getTotalUserCount(); i++) {
if ((users.getUser(i + 1).getName().equals(nowUser.getName()))) {
Event newEvent = new Event(parsedInputs[1].trim(), parsedInputs[4].trim(),
Event newEvent = new Event(parsedInputs[1].trim(), parsedInputs[4].trim(),
timeInputs[0].trim(), timeInputs[1].trim());
ui.printEvent(newEvent, day);
users.getUser(i + 1).getTimetable().getTimetable(day).add(newEvent);
Expand Down
21 changes: 21 additions & 0 deletions src/test/java/seedu/duke/command/AddCommandTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package seedu.duke.command;

import org.junit.jupiter.api.Test;
import seedu.duke.task.Event;
import static org.junit.jupiter.api.Assertions.assertEquals;

class AddCommandTest {

String name = "CS2040C";
String location = "LT23";
String timeStart = "1600";
String timeEnd = "1900";

@Test
void testAddCommand() {
Event e = new Event(name, location,timeStart,timeEnd);

assertEquals("CS2040C LT23 1600-1900",e.toString());
}

}

0 comments on commit 5e76fb3

Please sign in to comment.