diff options
author | clarkohw <66530369+clarkohw@users.noreply.github.com> | 2021-04-19 03:02:50 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-19 03:02:50 -0400 |
commit | 534d0cc5070287b221fa77f5dd564dd4544b5780 (patch) | |
tree | 7a6c356cca51f4fa4b549c693e168f6fc61302b3 /src/test/java/edu/brown/cs/student/ProfitCalculationTest.java | |
parent | 0466db8b9051cb6300f274f0bba480d1020c63cf (diff) | |
parent | ab4621b0e245043ef60db13e509fdb0c5b4cfc64 (diff) |
Merge pull request #13 from cs0320-2021/profit-testing
Profit testing
Diffstat (limited to 'src/test/java/edu/brown/cs/student/ProfitCalculationTest.java')
-rw-r--r-- | src/test/java/edu/brown/cs/student/ProfitCalculationTest.java | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/test/java/edu/brown/cs/student/ProfitCalculationTest.java b/src/test/java/edu/brown/cs/student/ProfitCalculationTest.java index 256afed..a4baa53 100644 --- a/src/test/java/edu/brown/cs/student/ProfitCalculationTest.java +++ b/src/test/java/edu/brown/cs/student/ProfitCalculationTest.java @@ -12,6 +12,7 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import java.time.LocalDate; import java.util.List; import java.sql.Date; import java.time.Instant; @@ -35,7 +36,7 @@ public class ProfitCalculationTest { @Before public void setUp() { try { - db = new DatabaseQuerier("data/testing/test_trades.sqlite3"); + db = new DatabaseQuerier("data/lil_mock.sqlite3"); } catch (Exception e) { System.out.println("DBQuerier Test, couldn't connect to db???"); } @@ -47,16 +48,28 @@ public class ProfitCalculationTest { } @Test - public void testEmptyDB() { + public void testBasicTrades() { setUp(); ProfitCalculation profitCalculation = - new ProfitCalculation(DatabaseQuerier.getConn(), "CAKEBREAD STEVEN", new Date(1518010558000l), - new Date(1718010556000l)); + new ProfitCalculation(DatabaseQuerier.getConn(), "Don", new Date(1518010558000l), + new Date(1618698807000l)); + //price of GME at end time is 154.69 List<StockHolding> trade = profitCalculation.getHoldingsList(); - double gain = trade.get(0).getUnrealizedGain(); - assertEquals(294800.0, gain, .01); + //buy with no sell + assertEquals(trade.get(0).getUnrealizedGain(), 3842.25, .25); + assertEquals(trade.get(0).getRealizedGain(), 0, .01); + } + public void checkAPICalls() { + ProfitCalculation profitCalculation = + new ProfitCalculation(DatabaseQuerier.getConn(), "Don", new Date(1618234200000l), + new Date(1618814264000l)); + + //check sp500 calculation. 411.28 to 417.30 + assertEquals(profitCalculation.compareToSP500(), .01464, .001); + + } }
\ No newline at end of file |