Skip to content

Commit

Permalink
A-JUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
ameliatjy committed Aug 26, 2020
1 parent c11ca87 commit 4397a8a
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/test/java/DeadlineTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import org.junit.jupiter.api.Test;

import java.time.LocalDateTime;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class DeadlineTest {

@Test
public void testStringConversion() {
assertEquals("[D][not done] return book (by: 12 June 2019 6:00 PM)",
new Deadline("return book", false,
LocalDateTime.of(2019, 6, 12, 18, 0)).toString());
}
}
15 changes: 15 additions & 0 deletions src/test/java/EventTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import org.junit.jupiter.api.Test;

import java.time.LocalDateTime;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class EventTest {

@Test
public void testStringConversion() {
assertEquals("[E][not done] dance auditions (at: 30 September 2020 11:30 AM)",
new Event("dance auditions", false,
LocalDateTime.of(2020, 9, 30, 11, 30)).toString());
}
}
24 changes: 24 additions & 0 deletions src/test/java/ParserTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import org.junit.jupiter.api.Test;

import java.time.LocalDateTime;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class ParserTest {
@Test
public void processMsg_invalidCommand_exceptionThrown() {
try {
Parser p = new Parser(new TaskList());
p.processMsg("test");
} catch (Exception e) {
assertEquals("Specified action is not recognised.", e.getMessage());
}
}

@Test
public void processDate_validDate_success() throws DukeException {
Parser p = new Parser(new TaskList());
LocalDateTime test = p.processDate("5/2/2020 1821");
assertEquals(LocalDateTime.of(2020, 2, 5, 18, 21), test);
}
}
18 changes: 18 additions & 0 deletions src/test/java/TaskTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class TaskTest {
@Test
public void testStringConversion() {
assertEquals("[not done] read book", new Task("read book", false).toString());
}

@Test
public void markAsComplete_incompleteTask_success() {
Task testTask = new Task("read book", false);
testTask.markAsComplete();
assertTrue(testTask.getStatus());
}
}
11 changes: 11 additions & 0 deletions src/test/java/TodoTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class TodoTest {

@Test
public void testStringConversion() {
assertEquals("[T][not done] read book", new Todo("read book", false).toString());
}
}

0 comments on commit 4397a8a

Please sign in to comment.