Skip to content

Commit

Permalink
update collate
Browse files Browse the repository at this point in the history
  • Loading branch information
tjonganthony committed Nov 8, 2016
1 parent abde360 commit e78bfa8
Show file tree
Hide file tree
Showing 3 changed files with 239 additions and 168 deletions.
1 change: 1 addition & 0 deletions collated/test/A0121501E.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@
expectedTM.addTask(toBeUnmarkedCopy);

model.addTask(toBeUnmarked);
logic.execute("list-all");
assertCommandBehavior("unmark 1",
String.format(UnmarkCommand.MESSAGE_SUCCESS, toBeUnmarked),
expectedTM,
Expand Down
234 changes: 234 additions & 0 deletions collated/test/A0126539Y.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
# A0126539Y
###### /java/seedu/priorityq/logic/commands/LoadCommandTest.java
``` java
public class LoadCommandTest {

@Test(expected = IllegalValueException.class)
public void nullLocation() throws Exception {
new LoadCommand(null);
}

@Test(expected = IllegalValueException.class)
public void emptyStringLocation() throws Exception {
new LoadCommand("");
}

@Test(expected = InvalidPathException.class)
public void invalidLocation() throws Exception{
new LoadCommand("invalid.json");
}
}
```
###### /java/seedu/priorityq/logic/commands/SaveCommandTest.java
``` java
public class SaveCommandTest {

@Test(expected = IllegalValueException.class)
public void nullLocation() throws Exception {
new SaveCommand(null);
}

@Test(expected = IllegalValueException.class)
public void emptyStringLocation() throws Exception {
new SaveCommand("");
}

@Test(expected = InvalidPathException.class)
public void invalidLocation() throws Exception{
new SaveCommand("invalid.json");
}

@Test
public void saveCommand() {
try {
new SaveCommand("data/newLocation.xml");
} catch (Exception e) {
fail();
}
}
}
```
###### /java/seedu/priorityq/model/entry/EventTest.java
``` java
@Test
public void inheritanceTest() {
assertTrue(testEvent instanceof Entry);
}

@Test
public void entryConstructor() {
assertTrue(testEvent.equals(new Event((Entry)testEvent)));

Entry task = new Task(title, null, tags, false, description, lastModifiedTime);
assertFalse(new Task(task).equals(testEvent));
}

@Test(expected = IllegalArgumentException.class)
public void startDateAfterEnd() {
new Event(title, endTime.plusMinutes(1), endTime, tags, isMarked, description, -1, lastModifiedTime);
}

@Test
public void getAsTextEqualToString() {
assertEquals(testEvent.getAsText(), testEvent.toString());
}

@Test
public void hashCodeTests() {
Event copy = new Event(testEvent);
assertNotEquals(testEvent.hashCode(), copy.hashCode());

// test consistency
assertEquals(testEvent.hashCode(), testEvent.hashCode());
assertEquals(testEvent.hashCode(), testEvent.hashCode());

copy.setDescription("another description");
assertNotEquals(testEvent.hashCode(), copy.hashCode());
}

@Test
public void equals() throws Exception {
// test null
assertFalse(testEvent.equals(null));

// test other instance
assertFalse(testEvent.equals(new Object()));

// test reflexivity
assertTrue(testEvent.equals(testEvent));


// test symmetricity
Event copy = new Event(testEvent);
assertTrue(testEvent.equals(copy));
assertTrue(copy.equals(testEvent));

// test transitivity
Event copy2 = new Event(testEvent);
assertTrue(copy.equals(copy2));
assertTrue(testEvent.equals(copy2));

copy.setTitle(new Title("some other title"));
assertFalse(testEvent.equals(copy));
}

@Test
public void testRecurrence() throws InterruptedException {
Event recurrenceBase = new Event(title, startTime, endTime, tags, isMarked, description, DAY_IN_MILLIS, lastModifiedTime);
Event copy;
LocalDateTime start;
LocalDateTime end;

copy = new Event(recurrenceBase);
start = LocalDateTime.now().minusDays(1).plusMinutes(1);
end = start.plusMinutes(5);
copy.setStartTime(start);
copy.setEndTime(end);
copy = new Event(copy);
assertEquals(copy.getStartTime(), start.plusDays(1));
assertEquals(copy.getEndTime(), end.plusDays(1));


copy = new Event(recurrenceBase);
start = LocalDateTime.now().minusDays(5).plusMinutes(1);
end = start.plusMinutes(5);
copy.setStartTime(start);
copy.setEndTime(end);
copy = new Event(copy);
System.out.println(copy.getStartTime());
System.out.println(start.plusDays(6));
assertEquals(copy.getStartTime(), start.plusDays(5));
assertEquals(copy.getEndTime(), end.plusDays(5));
}

@Test
public void getTimeObjectProperty() {
testEvent.startTimeObjectProperty().equals(testEvent.startTime);
testEvent.endTimeObjectProperty().equals(testEvent.endTime);
testEvent.recursionObjectProperty().equals(testEvent.recursion);
}
```
###### /java/seedu/priorityq/model/entry/TaskTest.java
``` java
@Test
public void inheritanceTest() {
assertTrue(floating instanceof Entry);
}

@Test
public void simpleConstructor() {
new Task(title, uniqueTagList);
}

@Test
public void constructor_nullDeadline() {
new Task(title, null, uniqueTagList, false, description, lastModifiedTime);
}

@Test
public void entryConstructor() {
assertTrue(floating.equals(new Task((Entry)floating)));
assertTrue(withDeadline.equals(new Task((Entry)withDeadline)));

Entry event = new Event(title, LocalDateTime.MIN, LocalDateTime.MAX, uniqueTagList, false, description, 0, lastModifiedTime);
assertFalse(new Task(event).equals(event));
}

@Test
public void getAsTextEqualToString() {
assertEquals(floating.getAsText(), floating.toString());
}

@Test
public void hashCodeTests() {
Task copy = new Task(floating);
assertNotEquals(floating.hashCode(), copy.hashCode());
Task deadlineCopy = new Task(withDeadline);
assertNotEquals(withDeadline.hashCode(), deadlineCopy.hashCode());

assertNotEquals(floating.hashCode(), withDeadline.hashCode());

// test consistency
assertEquals(floating.hashCode(), floating.hashCode());
assertEquals(floating.hashCode(), floating.hashCode());

copy.setDescription("new description");
assertNotEquals(floating.hashCode(), copy.hashCode());
}

@Test
public void equals() throws Exception {
// test null
assertFalse(floating.equals(null));
assertFalse(withDeadline.equals(null));

// test other instance
assertFalse(floating.equals(new Object()));
assertFalse(withDeadline.equals(new Object()));

// test reflexivity
assertTrue(withDeadline.equals(withDeadline));
assertTrue(floating.equals(floating));


// test symmetricity
Task copy = new Task(floating);
assertTrue(floating.equals(copy));
assertTrue(copy.equals(floating));

Task copyDeadline = new Task(withDeadline);
assertTrue(withDeadline.equals(copyDeadline));
assertTrue(copyDeadline.equals(withDeadline));

// test transitivity
Task copy2 = new Task(title, null, uniqueTagList, false, description, lastModifiedTime);
assertTrue(copy.equals(copy2));
assertTrue(floating.equals(copy2));


copy.setTitle(new Title("some other title"));
assertFalse(withDeadline.equals(copy));
copy2.mark();
assertFalse(withDeadline.equals(copy2));
}
```
Loading

0 comments on commit e78bfa8

Please sign in to comment.