Ejemplo n.º 1
0
  /**
   * End to end case representing a user logging in and selling a stock.
   *
   * @throws Exception
   */
  @Test
  public void loginSellStockTest() throws Exception {
    // Log-in
    manager.loginUser("mfav", "123");
    User u = manager.findActiveUser("mfav");

    // Purchase stock
    u.purchaseStock(StockLookup.loadStock("NFLX"), 5);

    // Sell stock
    u.sellStock(StockLookup.loadStock("NFLX"), 5);

    // Ensure stock is not account
    Assert.assertFalse(u.getStockShares().containsKey("NFLX"));
  }
Ejemplo n.º 2
0
  /**
   * End to end case representing a user logging in and buying a stock.
   *
   * @throws Exception
   */
  @Test
  public void loginPurchaseStockTest() throws Exception {
    // Log-in
    manager.loginUser("mfav", "123");
    User u = manager.findActiveUser("mfav");

    // Purchase stock
    u.purchaseStock(StockLookup.loadStock("NFLX"), 5);

    // Ensure stock is in account
    Assert.assertEquals(5, (int) u.getStockShares().get("NFLX"));
  }