Skip to content

Commit

Permalink
Add eventFromCSV_validCsvEntry_success test to Event
Browse files Browse the repository at this point in the history
  • Loading branch information
camille-readbean committed Feb 5, 2024
1 parent 481d00a commit 6249c85
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/test/java/me/ruibin/leto/tasklist/EventTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void eventFromCommand_validCommand_success () {
public void eventFromCommand_commandWithBadFormat_failure() {
LocalDate startDate = LocalDate.now().plusDays(10);
LocalDate endDate = LocalDate.now().plusDays(20);
String command = MessageFormat.format("event H4(K1nG cOnv@nt!0n /from {0} \to {1}",
String command = MessageFormat.format("event H4(K1nG cOnv@nt!0n /from {0} /to {1}",
startDate.format(DateTimeFormatter.ofPattern("d MMMM yyyy")),
endDate);
try {
Expand All @@ -40,9 +40,26 @@ public void eventFromCommand_commandWithBadFormat_failure() {
}
}

@Test
public void eventFromCSV_validCsvEntry_success() {
LocalDate startDate = LocalDate.now().plusDays(10);
LocalDate endDate = LocalDate.now().plusDays(20);
String entry = MessageFormat.format("E,Y, H4(K1nG cOnv@nt!0n,,{0},{1}",
startDate,
endDate);
String pattern = "[E][X] H4(K1nG cOnv@nt!0n (from: {0} to: {1}) 10 days to the event";
String correctOutput = MessageFormat.format(pattern, startDate, endDate);
try {
Event produced = Event.eventFromCsv(entry);
assertEquals(produced.toString(), correctOutput);
} catch (Exception e) {
fail(e);
}
}

@Test
public void eventFromCsv_badCsvEntry_failure() {
String entry = "D,N,SUBMIT.Paper #CS320,,,";
String entry = "E,N,event H4(K1nG cOnv@nt!0n,,,";
try {
Event produced = Event.eventFromCsv(entry);
} catch (Exception e) {
Expand Down

0 comments on commit 6249c85

Please sign in to comment.