Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nixonwidjaja committed Oct 22, 2023
1 parent bbccb47 commit 3643640
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/test/java/seedu/address/model/AddressBookListTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package seedu.address.model;

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

import org.junit.jupiter.api.Test;

public class AddressBookListTest {
private final AddressBookList addressBookList = new AddressBookList();

@Test
public void undo_success() {
addressBookList.add(new AddressBook());
addressBookList.add(new AddressBook());
assertEquals(addressBookList.undo(), new AddressBook());
}

@Test
public void undo_failure() {
assertThrows(IllegalArgumentException.class, () -> addressBookList.undo());
}

@Test
public void redo_success() {
addressBookList.add(new AddressBook());
addressBookList.add(new AddressBook());
addressBookList.undo();
assertEquals(addressBookList.redo(), new AddressBook());
}

@Test
public void redo_failure() {
assertThrows(IllegalArgumentException.class, () -> addressBookList.redo());
}
}
3 changes: 3 additions & 0 deletions src/test/java/seedu/address/model/ModelManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ public void hasPerson_personNotInAddressBook_returnsFalse() {
@Test
public void hasPerson_personInAddressBook_returnsTrue() {
modelManager.addPerson(ALICE);
modelManager.addCommandText("add Alice");
assertTrue(modelManager.hasPerson(ALICE));
assertTrue(modelManager.undo().equals("add Alice"));
assertTrue(modelManager.redo().equals("add Alice"));
}

@Test
Expand Down

0 comments on commit 3643640

Please sign in to comment.