forked from nus-cs2103-AY2324S2/tp
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feat/phoneValidator
- Loading branch information
Showing
13 changed files
with
458 additions
and
34 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Part of the code is adpatated from original AB3 Code. All credits and thanks to the original | ||
// Part of the code is adapted from original AB3 Code. All credits and thanks to the original | ||
// CS2103T teaching team for this. | ||
package seedu.address.logic.commands; | ||
|
||
|
@@ -17,6 +17,17 @@ | |
import seedu.address.model.ModelManager; | ||
import seedu.address.model.UserPrefs; | ||
import seedu.address.model.amount.Amount; | ||
import seedu.address.model.attendance.Attendance; | ||
import seedu.address.model.attendance.Sessions; | ||
import seedu.address.model.cca.Cca; | ||
import seedu.address.model.person.Address; | ||
import seedu.address.model.person.Email; | ||
import seedu.address.model.person.Metadata; | ||
import seedu.address.model.person.Name; | ||
import seedu.address.model.person.Person; | ||
import seedu.address.model.person.Phone; | ||
import seedu.address.model.roles.Role; | ||
|
||
|
||
/** | ||
* Contains integration tests (interaction with the Model) and unit tests for | ||
|
@@ -42,6 +53,53 @@ public void testGetIndex() { | |
assertEquals(expectedIndex, oweCommand.getIndex()); | ||
} | ||
|
||
// The testGetAmount() is adapted from ChatGPT. (Reason: Quick add a simple test) | ||
@Test | ||
public void testGetAmount() { | ||
Amount expectedAmount = new Amount("100.0"); | ||
OweCommand oweCommand = new OweCommand(INDEX_FIRST_PERSON, expectedAmount); | ||
assertEquals(expectedAmount, oweCommand.getAmount()); | ||
} | ||
@Test | ||
public void testCreateOwedPerson() { | ||
// Arrange | ||
|
||
Person personToOwe = new Person(new Name("temp"), new Phone("94351252"), | ||
new Email("[email protected]"), new Address("secret"), Role.createRoleSet("member"), | ||
Cca.createCcaSet(), new Amount("100.0"), new Attendance("3"), new Sessions("5"), | ||
new Metadata("eating")); | ||
Amount amount = new Amount("100.0"); | ||
|
||
// Act | ||
Person owedPerson = OweCommand.createOwedPerson(personToOwe, amount); | ||
|
||
// Assert | ||
assertEquals(personToOwe.getName(), owedPerson.getName()); | ||
assertEquals(personToOwe.getPhone(), owedPerson.getPhone()); | ||
assertEquals(personToOwe.getEmail(), owedPerson.getEmail()); | ||
assertEquals(personToOwe.getAddress(), owedPerson.getAddress()); | ||
assertEquals(personToOwe.getRoles(), owedPerson.getRoles()); | ||
assertEquals(personToOwe.getCcas(), owedPerson.getCcas()); | ||
assertEquals(amount, owedPerson.getAmount()); | ||
assertEquals(personToOwe.getAtt(), owedPerson.getAtt()); | ||
assertEquals(personToOwe.getSess(), owedPerson.getSess()); | ||
assertEquals(personToOwe.getMetadata(), owedPerson.getMetadata()); | ||
} | ||
|
||
@Test | ||
public void testToString() { | ||
// Arrange | ||
Index index = Index.fromOneBased(5); | ||
Amount amount = new Amount("100.00"); | ||
OweCommand oweCommand = new OweCommand(index, amount); | ||
|
||
// Act | ||
String result = oweCommand.toString(); | ||
|
||
// Assert | ||
String expected = "OweCommand{ index: " + index + ", amount: " + amount + "}"; | ||
assertEquals(expected, result); | ||
} | ||
@Test | ||
public void equals() { | ||
Amount amount = new Amount("10.00"); | ||
|
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 |
---|---|---|
|
@@ -51,6 +51,9 @@ public void isValidEmail() { | |
assertFalse(Email.isValidEmail("[email protected]")); // domain name starts with a hyphen | ||
assertFalse(Email.isValidEmail("[email protected]")); // domain name ends with a hyphen | ||
assertFalse(Email.isValidEmail("[email protected]")); // top level domain has less than two chars | ||
assertFalse(Email.isValidEmail("something@org.")); // should return false | ||
assertFalse(Email.isValidEmail("something@gov.")); // should return false | ||
assertFalse(Email.isValidEmail("something@net.")); // should return false | ||
|
||
// valid email | ||
assertTrue(Email.isValidEmail("[email protected]")); // underscore in local part | ||
|
@@ -64,6 +67,9 @@ public void isValidEmail() { | |
assertTrue(Email.isValidEmail("[email protected]")); // long domain name | ||
assertTrue(Email.isValidEmail("[email protected]")); // long local part | ||
assertTrue(Email.isValidEmail("[email protected]")); // more than one period in domain | ||
assertTrue(Email.isValidEmail("[email protected]")); // test org website | ||
assertTrue(Email.isValidEmail("[email protected]")); // test gov website | ||
assertTrue(Email.isValidEmail("[email protected]")); // test net website | ||
} | ||
|
||
@Test | ||
|
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