Ejemplo n.º 1
0
    def test_sell_shares(self):
        player = Player('Mike', 200)
        player.buy_shares(company_name='NYC', price=50, quantity=4)
        self.assertEqual(player.cash, 0)
        self.assertEqual(player.NYC, 4)

        player.sell_shares(company_name='NYC', price=100, quantity=3)
        self.assertEqual(player.cash, 300)
        self.assertEqual(player.NYC, 1)
Ejemplo n.º 2
0
    def test_sell_shares_not_owned_company(self):
        player = Player('Guadalupe', 200)
        player.buy_shares(company_name='NYC', price=50, quantity=1)

        with self.assertRaises(ValueError):
            player.sell_shares(company_name='PRR', price=100, quantity=1)
Ejemplo n.º 3
0
    def test_sell_more_shares_than_owned(self):
        player = Player('Fry', 200)
        player.buy_shares(company_name='GT', price=50, quantity=1)

        with self.assertRaises(ValueError):
            player.sell_shares(company_name='GT', price=100, quantity=2)