-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
571 additions
and
550 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package todolist.common.stubs; | ||
|
||
//import java.util.ArrayList; | ||
// | ||
//import todolist.MainApp; | ||
//import todolist.model.Category; | ||
//import todolist.model.Reminder; | ||
//import todolist.ui.TaskWrapper; | ||
|
||
public class CommandHandlerStub { | ||
|
||
// private static String status = "200: Okay"; | ||
// private static ArrayList<Category> categoriesToDisplay = new ArrayList<Category>(); | ||
// private static Category currentCategory = new Category("SAMPLE CATEGORY"); | ||
// private static ArrayList<TaskWrapper> tasksToDisplay = new ArrayList<TaskWrapper>(); | ||
// private static ArrayList<Reminder> remindersToTrack = new ArrayList<Reminder>(); | ||
// private static String currentSearch = ""; | ||
// private static Page page = Page.Home; | ||
|
||
// private MainApp main = null; | ||
|
||
// public CommandHandlerStub(MainApp main) { | ||
// this.main = main; | ||
// } | ||
|
||
// public void execute(Command command) { | ||
|
||
// Feedback feedback= new Feedback(status, page, | ||
// categoriesToDisplay, currentCategory, | ||
// tasksToDisplay, | ||
// remindersToTrack, currentSearch); | ||
|
||
// ... Do something | ||
|
||
// ArrayList<TaskWrapper> tasksToDisplay = new ArrayList<TaskWrapper>(); | ||
|
||
// tasksToDisplay.add(new TaskWrapper("Do UI Handler (CHANGED)", | ||
// LocalDateTime.now(), LocalDateTime.now().plusHours(3), | ||
// new Category("CS2103T Project (CHANGED)"), new | ||
// Reminder(LocalDateTime.now().plusHours(3)))); | ||
// tasksToDisplay.add(new TaskWrapper("Setup Trello (THIS ALSO CHANGED)", | ||
// LocalDateTime.now(), LocalDateTime.now().plusHours(3), | ||
// new Category("CS2103T Project (CHANGED)"), new | ||
// Reminder(LocalDateTime.now().plusHours(3)))); | ||
// tasksToDisplay.add(new TaskWrapper("Prepare CV (CHANGED)", | ||
// LocalDateTime.now(), LocalDateTime.now().plusHours(3), | ||
// new Category("Personal (CHANGED)"), new Priority(1), new | ||
// Reminder(LocalDateTime.now().plusHours(3)))); | ||
// tasksToDisplay.add(new TaskWrapper("Buy leather shoes (CHANGED)", | ||
// LocalDateTime.now(), LocalDateTime.now().plusHours(3), | ||
// new Category("Personal (CHANGED)"), new Priority(1), new | ||
// Reminder(LocalDateTime.now().plusHours(3)))); | ||
// tasksToDisplay.add(new TaskWrapper("Send emails (CHANGED)", | ||
// LocalDateTime.now(), LocalDateTime.now().plusHours(3), | ||
// new Category("18th MC (CHANGED)"), new Priority(1), new | ||
// Reminder(LocalDateTime.now().plusHours(3)))); | ||
|
||
// Call my functions ... | ||
|
||
// main.setDisplayTasks(tasksToDisplay); | ||
|
||
// return feedback; | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
package todolist.common.tests; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import java.time.LocalDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
import java.time.temporal.ChronoUnit; | ||
|
||
import org.junit.Test; | ||
|
||
import todolist.MainApp; | ||
import todolist.logic.Logic; | ||
import todolist.logic.MainAppStub; | ||
import todolist.model.Name; | ||
import todolist.model.Task; | ||
|
||
public class LogicTest { | ||
|
||
private MainApp mainAppStub = new MainAppStub(); | ||
|
||
private Logic logic = new Logic(mainAppStub); | ||
|
||
public void testProcess() { | ||
boolean expected = true; | ||
|
||
Name name = new Name("title"); | ||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); | ||
LocalDateTime start = LocalDateTime.parse("2017-01-01" + " " + "14:00", formatter); | ||
LocalDateTime end = start.plus(Long.parseLong("1"), ChronoUnit.DAYS); | ||
Task newEvent = new Task(name, start, end, null, null, false, false, null); | ||
|
||
logic.process("add event title 2017-01-01 14:00 1 day"); | ||
|
||
Boolean isEqual = logic.dataBase.taskList.get(0).getName().getName().equals(newEvent.getName().getName()); | ||
|
||
assertEquals(isEqual, expected); | ||
} | ||
|
||
@Test | ||
public void testStepForward() { | ||
int original = logic.checkStep(); | ||
logic.stepForward(1); | ||
assertEquals(logic.checkStep(), original + 1); | ||
} | ||
|
||
public void testAddRecurringEvent() { | ||
fail("Not yet implemented"); | ||
} | ||
|
||
public void testAddRecurringDeadline() { | ||
fail("Not yet implemented"); | ||
} | ||
|
||
@Test | ||
public void testAddEvent() { | ||
Name name = new Name("title"); | ||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); | ||
LocalDateTime start = LocalDateTime.parse("1970-01-01" + " " + "12:00", formatter); | ||
LocalDateTime end = start.plus(Long.parseLong("1"), ChronoUnit.DAYS); | ||
Task newEvent = new Task(name, start, end, null, null, false, false, null); | ||
|
||
logic.addEvent("title", "1970-01-01", "12:00", "1", "day"); | ||
Boolean isEqual = logic.dataBase.taskList.get(0).getName().getName().equals(newEvent.getName().getName()); | ||
assert(isEqual); | ||
} | ||
|
||
@Test | ||
public void testAddDeadline() { | ||
Name name = new Name("title"); | ||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); | ||
LocalDateTime end = LocalDateTime.parse("1970-01-01" + " " + "12:00", formatter); | ||
Task newEvent = new Task(name, null, end, null, null, false, false, null); | ||
|
||
logic.addDeadline("title", "1970-01-01", "12:00"); | ||
Boolean isEqual = logic.dataBase.taskList.get(0).getName().getName().equals(newEvent.getName().getName()); | ||
assert(isEqual); | ||
} | ||
|
||
@Test | ||
public void testAddTask() { | ||
Name name = new Name("title"); | ||
Task newEvent = new Task(name, null, null, null, null, false, false, null); | ||
logic.addTask("title"); | ||
Boolean isEqual = logic.dataBase.taskList.get(0).getName().getName().equals(newEvent.getName().getName()); | ||
assert(isEqual); | ||
} | ||
|
||
@Test | ||
public void testDone() { | ||
logic.addTask("title"); | ||
logic.done("title"); | ||
Name name = new Name("title"); | ||
Task newEvent = new Task(name, null, null, null, null, true, false, null); | ||
Boolean isEqual = logic.dataBase.taskList.get(0).getName().getName().equals(newEvent.getName().getName()); | ||
assert(isEqual); | ||
} | ||
|
||
@Test | ||
public void testUndone() { | ||
logic.addTask("title"); | ||
logic.done("title"); | ||
logic.undone("title"); | ||
Name name = new Name("title"); | ||
Task newEvent = new Task(name, null, null, null, null, false, false, null); | ||
logic.addTask("title"); | ||
Boolean isEqual = logic.dataBase.taskList.get(0).getName().getName().equals(newEvent.getName().getName()); | ||
assert(isEqual); | ||
} | ||
|
||
public void testEdit() { | ||
fail("Not yet implemented"); | ||
} | ||
|
||
public void testDelete() { | ||
fail("Not yet implemented"); | ||
} | ||
|
||
public void testSearch() { | ||
fail("Not yet implemented"); | ||
} | ||
|
||
public void testLabel() { | ||
fail("Not yet implemented"); | ||
} | ||
|
||
public void testSetRecurring() { | ||
fail("Not yet implemented"); | ||
} | ||
|
||
public void testPostpone() { | ||
fail("Not yet implemented"); | ||
} | ||
|
||
public void testForward() { | ||
fail("Not yet implemented"); | ||
} | ||
|
||
public void testAddRemind() { | ||
fail("Not yet implemented"); | ||
} | ||
|
||
public void testAddRemindBef() { | ||
fail("Not yet implemented"); | ||
} | ||
|
||
public void testRemindBef() { | ||
fail("Not yet implemented"); | ||
} | ||
|
||
public void testRemind() { | ||
fail("Not yet implemented"); | ||
} | ||
|
||
public void testExit() { | ||
fail("Not yet implemented"); | ||
} | ||
|
||
public void testUndo() { | ||
fail("Not yet implemented"); | ||
} | ||
|
||
public void testRedo() { | ||
fail("Not yet implemented"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package todolist.common.tests; | ||
|
||
public class MainParserTest { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package todolist.common.tests; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import todolist.model.TokenizedCommand; | ||
import todolist.parser.NormalCommandParser; | ||
|
||
public class NormalCommandParserTest { | ||
NormalCommandParser normalCommandParser = null; | ||
|
||
@Before | ||
public void initNormalCommandParser() { | ||
normalCommandParser = new NormalCommandParser(); | ||
} | ||
|
||
@Test | ||
public void testParse() { | ||
|
||
final String testCase = " add event CS2103T-Tutorial 2016-03-23 13:00 1 hour"; | ||
final String expectedAction = "add"; | ||
final int expectedArgsSize = 7; | ||
String[] expectedArgs = new String[expectedArgsSize]; | ||
expectedArgs[0] = "add"; | ||
expectedArgs[1] = "event"; | ||
expectedArgs[2] = "CS2103T-Tutorial"; | ||
expectedArgs[3] = "2016-03-23"; | ||
expectedArgs[4] = "13:00"; | ||
expectedArgs[5] = "1"; | ||
expectedArgs[6] = "hour"; | ||
|
||
TokenizedCommand output = normalCommandParser.parse(testCase); | ||
|
||
// assertEquals(expectedAction, output.getAction()); | ||
assertEquals(expectedArgsSize, output.getArgs().length); | ||
|
||
for (int i = 0; i < output.getArgs().length; ++i) { | ||
String arg = output.getArgs()[i]; | ||
assertEquals(expectedArgs[i], arg); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package todolist.common.tests; | ||
|
||
public class UIHandlerTest { | ||
|
||
} |
Oops, something went wrong.