Skip to content

Commit

Permalink
Reorder tests
Browse files Browse the repository at this point in the history
  • Loading branch information
damithc committed Sep 8, 2016
1 parent 46aa748 commit 3dd030d
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions test/java/seedu/addressbook/logic/LogicTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,19 @@ public void setup() throws Exception {
logic = new Logic(saveFile, addressBook);
}

/**
* Confirms that the following three parts of the Logic object's state is as expected:<br>
* - the internal addressbook is same as {@code expectedAddressBook} <br>
* - the internal last shown list is the same as {@code expectedLastList} <br>
* - the storage file content matches data in {@code expectedAddressBook} <br>
*/
private void assertLogicObjectStateEquals(AddressBook expectedAddressBook, List<? extends ReadOnlyPerson> expectedLastList)
throws StorageFile.StorageOperationException {
assertEquals(expectedAddressBook, addressBook);
assertEquals( expectedLastList, logic.getLastShownList());
assertEquals(addressBook, saveFile.load());
@Test
public void constructor() {
//Constructor is called in the setup() method which executes before every test, no need to call it here again.

//Confirm the last shown list is empty
assertEquals(Collections.emptyList(), logic.getLastShownList());
}

@Test
public void execute_invalid() throws Exception {
String invalidCommand = " ";
assertNonMutatingCommandBehavior(invalidCommand,
String.format(MESSAGE_INVALID_COMMAND_FORMAT, HelpCommand.MESSAGE_USAGE));
}

/**
Expand All @@ -67,6 +69,19 @@ private void assertNonMutatingCommandBehavior(String inputCommand, String expect
assertLogicObjectStateEquals(AddressBook.empty(), Collections.emptyList());
}

/**
* Confirms that the following three parts of the Logic object's state is as expected:<br>
* - the internal addressbook is same as {@code expectedAddressBook} <br>
* - the internal last shown list is the same as {@code expectedLastList} <br>
* - the storage file content matches data in {@code expectedAddressBook} <br>
*/
private void assertLogicObjectStateEquals(AddressBook expectedAddressBook, List<? extends ReadOnlyPerson> expectedLastList)
throws StorageFile.StorageOperationException {
assertEquals(expectedAddressBook, addressBook);
assertEquals( expectedLastList, logic.getLastShownList());
assertEquals(addressBook, saveFile.load());
}

/**
* Executes the command and confirms that the result message is correct and both in-memory and persistent data
* have been updated as specified.
Expand All @@ -81,21 +96,6 @@ private void assertMutatingCommandBehavior(String inputCommand,
assertLogicObjectStateEquals(expectedAddressBook, expectedLastList);
}

@Test
public void constructor() {
//Constructor is called in the setup() method which executes before every test, no need to call it here again.

//Confirm the last shown list is empty
assertEquals(Collections.emptyList(), logic.getLastShownList());
}

@Test
public void execute_invalid() throws Exception {
String invalidCommand = " ";
assertNonMutatingCommandBehavior(invalidCommand,
String.format(MESSAGE_INVALID_COMMAND_FORMAT, HelpCommand.MESSAGE_USAGE));
}

@Test
public void execute_unknownCommandWord() throws Exception {
String unknownCommand = "uicfhmowqewca";
Expand Down

0 comments on commit 3dd030d

Please sign in to comment.