Skip to content

Commit

Permalink
Merge pull request #58 from HUANGXUANKUN/master
Browse files Browse the repository at this point in the history
Update JUnit Tests for newly implemented recurringTask, periodTask and rescheduleCommand
  • Loading branch information
HUANGXUANKUN authored Oct 2, 2019
2 parents fb7bc53 + 7e61da9 commit b82e8ec
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 17 deletions.
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,23 @@ src/main/resources/docs/
*.iml
bin/
data/duke.txt
build/test-results/test/binary/results.bin
build/test-results/test/binary/output.bin.idx
build/test-results/test/binary/output.bin
build/test-results/test/TEST-duke.task.PeriodTaskTest.xml
build/scriptsShadow/duke.bat
build/scriptsShadow/duke
build/scripts/duke.bat
build/scripts/duke
build/reports/tests/test/packages/duke.task.html
build/distributions/duke-0.1.0.tar
build/distributions/duke-shadow-0.1.0.tar
build/distributions/duke-0.1.0.zip
build/reports/tests/test/classes/duke.task.PeriodTaskTest.html
build/libs/duke-0.1.0.jar
build/reports/tests/test/index.html
build/reports/tests/test/css/base-style.css
build/distributions/duke-shadow-0.1.0.zip
build/libs/mid-v1.1.jar
build/reports/tests/test/css/style.css
build/reports/tests/test/js/report.js
13 changes: 5 additions & 8 deletions src/test/java/duke/core/ParserTest.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
package duke.core;

import duke.command.AddCommand;
import duke.command.Command;
import duke.command.DeleteCommand;
import duke.command.DoneCommand;
import duke.command.ExitCommand;
import duke.command.FindCommand;
import duke.command.ListCommand;
import duke.command.ViewCommand;
import duke.command.*;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertTrue;
Expand All @@ -28,6 +21,8 @@ public void commandTypeTest() throws DukeException {
Command c7 = Parser.parse("event Meeting /at 27/07/2020 1630");
Command c8 = Parser.parse("deadline event Homework ABC /by 27/07/2020 1630");
Command c9 = Parser.parse("view 16/09/2019");
Command c10 = Parser.parse("period periodTaskTest /from 27/07/2020 1630 /to 27/08/2020 1630");
Command c11 = Parser.parse("reschedule 1 27/07/2020 1630");

assertTrue(c1 instanceof ExitCommand, "The command type should be ");
assertTrue(c2 instanceof DoneCommand, "The command type should be 'DoneCommand'");
Expand All @@ -38,5 +33,7 @@ public void commandTypeTest() throws DukeException {
assertTrue(c7 instanceof AddCommand, "The command type should be 'AddCommand'");
assertTrue(c8 instanceof AddCommand, "The command type should be 'AddCommand'");
assertTrue(c9 instanceof ViewCommand, "The command type should be 'ViewCommand'");
assertTrue(c10 instanceof AddCommand, "The command type should be 'AddCommand'");
assertTrue(c11 instanceof RescheduleCommand, "The command type should be 'RescheduleCommand'");
}
}
6 changes: 3 additions & 3 deletions src/test/java/duke/task/DeadlineTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void deadlineStringTest() throws DukeException {
*/
@Test
public void writeFormatTest() throws DukeException {
assertEquals( "D | 0 | deadlineTest | 02/12/1996 1235 | false",new Deadline("deadlineTest", "02/12/1996 1235").writeTxt(), "The writeToFile format is not expected");
assertEquals( "D | 0 | deadlineTest | 02/12/1996 1235 | ONCE",new Deadline("deadlineTest", "02/12/1996 1235").writeTxt(), "The writeToFile format is not expected");
}

/**
Expand All @@ -48,12 +48,12 @@ public void deadlineTestCase() throws DukeException {
Deadline deadline = new Deadline("deadlineTest", "02/12/1996 1235");
assertFalse(deadline.isDone(), "The newly created deadline should not be done");
assertEquals( "[D][\u2718] deadlineTest (by: 2nd of December 1996, 12PM)",deadline.toString(), "The writeToFile format is not expected");
assertEquals( "D | 0 | deadlineTest | 02/12/1996 1235 | false",deadline.writeTxt(), "The writeToFile format is not expected");
assertEquals( "D | 0 | deadlineTest | 02/12/1996 1235 | ONCE",deadline.writeTxt(), "The writeToFile format is not expected");

// Mark the deadline as done and check its toString() and writeTxt()
deadline.markAsDone();
assertTrue(deadline.isDone(), "The deadline should be marked as done");
assertEquals("[D][\u2713] deadlineTest (by: 2nd of December 1996, 12PM)", deadline.toString(), "The deadline.toString() is not expected");
assertEquals( "D | 1 | deadlineTest | 02/12/1996 1235",deadline.writeTxt(), "The writeToFile format is not expected");
assertEquals( "D | 1 | deadlineTest | 02/12/1996 1235 | ONCE",deadline.writeTxt(), "The writeToFile format is not expected");
}
}
6 changes: 3 additions & 3 deletions src/test/java/duke/task/EventTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void EventStringTest() throws DukeException {
*/
@Test
public void writeFormatTest() throws DukeException {
assertEquals( "E | 0 | test | 02/12/1996 1235 | false",new Event("test", "02/12/1996 1235").writeTxt(), "The writeToFile format is not expected");
assertEquals( "E | 0 | test | 02/12/1996 1235 | ONCE",new Event("test", "02/12/1996 1235").writeTxt(), "The writeToFile format is not expected");
}

/**
Expand All @@ -48,12 +48,12 @@ public void eventTestCase() throws DukeException {
Event event = new Event("eventTest", "02/12/1996 1235");
assertFalse(event.isDone(), "The newly created event should not be done");
assertEquals( "[E][\u2718] eventTest (at: 2nd of December 1996, 12PM)",event.toString(), "The writeToFile format is not expected");
assertEquals( "E | 0 | eventTest | 02/12/1996 1235 | false",event.writeTxt(), "The writeToFile format is not expected");
assertEquals( "E | 0 | eventTest | 02/12/1996 1235 | ONCE",event.writeTxt(), "The writeToFile format is not expected");

// Mark the event as done and check its toString() and writeTxt()
event.markAsDone();
assertTrue(event.isDone(), "The event should be marked as done");
assertEquals("[E][\u2713] eventTest (at: 2nd of December 1996, 12PM)", event.toString(), "The event.toString() is not expected");
assertEquals( "E | 1 | eventTest | 02/12/1996 1235 | false",event.writeTxt(), "The writeToFile format is not expected");
assertEquals( "E | 1 | eventTest | 02/12/1996 1235 | ONCE",event.writeTxt(), "The writeToFile format is not expected");
}
}
6 changes: 3 additions & 3 deletions src/test/java/duke/task/TodoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void todoStringTest(){
*/
@Test
public void writeFormatTest() {
assertEquals( "T | 0 | todoTest | false",new Todo("todoTest").writeTxt(), "The writeToFile format is not expected");
assertEquals( "T | 0 | todoTest | ONCE",new Todo("todoTest").writeTxt(), "The writeToFile format is not expected");
}

/**
Expand All @@ -48,12 +48,12 @@ public void todoTestCase() throws DukeException {
Todo todo = new Todo("todoTest");
assertFalse(todo.isDone(), "The newly created todo should not be done");
assertEquals( "[T][\u2718] todoTest",todo.toString(), "The writeToFile format is not expected");
assertEquals( "T | 0 | todoTest | false",todo.writeTxt(), "The writeToFile format is not expected");
assertEquals( "T | 0 | todoTest | ONCE",todo.writeTxt(), "The writeToFile format is not expected");

// Mark the task as done and check its toString() and writeTxt()
todo.markAsDone();
assertTrue(todo.isDone(), "The todo should be marked as done");
assertEquals("[T][\u2713] todoTest", todo.toString(), "The todo.toString() is not expected");
assertEquals( "T | 1 | todoTest",todo.writeTxt(), "The writeToFile format is not expected");
assertEquals( "T | 1 | todoTest | ONCE",todo.writeTxt(), "The writeToFile format is not expected");
}
}

0 comments on commit b82e8ec

Please sign in to comment.