forked from nus-cs2103-AY1920S1/addressbook-level3
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #225 from austinsantoso/branch-currencyForBudget
integrate currency with budget
- Loading branch information
Showing
6 changed files
with
98 additions
and
15 deletions.
There are no files selected for viewing
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
65 changes: 65 additions & 0 deletions
65
src/test/java/seedu/moneygowhere/logic/commands/BudgetCommandIntegrationTest.java
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,65 @@ | ||
package seedu.moneygowhere.logic.commands; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static seedu.moneygowhere.logic.commands.CommandTestUtil.assertCommandSuccess; | ||
import static seedu.moneygowhere.testutil.TypicalSpendings.getTypicalSpendingBook; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.moneygowhere.model.Model; | ||
import seedu.moneygowhere.model.ModelManager; | ||
import seedu.moneygowhere.model.UserPrefs; | ||
import seedu.moneygowhere.model.budget.Budget; | ||
import seedu.moneygowhere.model.currency.Currency; | ||
|
||
public class BudgetCommandIntegrationTest { | ||
|
||
private Model model; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
model = new ModelManager(getTypicalSpendingBook(), new UserPrefs()); | ||
} | ||
|
||
@Test | ||
public void execute_setNewBudget_success() { | ||
Budget budget = new Budget(10000); | ||
|
||
ModelManager expectedModel = new ModelManager(model.getSpendingBook(), new UserPrefs()); | ||
expectedModel.setBudget(budget); | ||
|
||
String expectedMessage = BudgetCommand.MESSAGE_SUCCESS + model.getCurrencyInUse().symbol + budget.toString(); | ||
|
||
assertCommandSuccess(new BudgetCommand(budget), model, expectedMessage, expectedModel); | ||
} | ||
|
||
@Test | ||
public void execute_setNewBudgetWithChangedCurrency_success() { | ||
Budget budget = new Budget(10000); | ||
|
||
ModelManager expectedModel = new ModelManager(model.getSpendingBook(), new UserPrefs()); | ||
expectedModel.setBudget(budget); | ||
|
||
Currency usdCurrency = null; | ||
for (Currency currency : model.getSpendingBook().getCurrencies()) { | ||
if (currency.name.equalsIgnoreCase("USD")) { | ||
usdCurrency = currency; | ||
} | ||
} | ||
|
||
assertNotNull(usdCurrency); | ||
|
||
double updatedAmount = budget.getAmount() / usdCurrency.rate; | ||
Budget newBudget = new Budget(updatedAmount); | ||
|
||
expectedModel.setCurrencyInUse(usdCurrency); | ||
expectedModel.setBudget(newBudget); | ||
|
||
model.setCurrencyInUse(usdCurrency); | ||
|
||
String expectedMessage = BudgetCommand.MESSAGE_SUCCESS + model.getCurrencyInUse().symbol + budget.toString(); | ||
|
||
assertCommandSuccess(new BudgetCommand(budget), model, expectedMessage, expectedModel); | ||
} | ||
} |
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