Пример #1
0
    def test_frac_payout(self):
        config = Configuration(base_bet=10, payout=1.5, loss_adder=50)
        account = Account(balance=100)
        simulation = Simulation(config=config, account=account)

        simulation.account.subtract(10)
        simulation.win_roll(simulation.account)
        self.assertEqual(
            simulation.account.get_balance(), 105,
            "Balance not properly increased with a payout of"
            " 1.5X")
Пример #2
0
    def test_balance_not_changed(self):
        account = Account(balance=100)
        config = Configuration(base_bet=10, payout=2, loss_adder=0)
        simulation = Simulation(config=config, account=account)

        simulation.lose_roll()
        # The balance should not be changed after a roll is lost, because the
        # account is charged only once before the roll and is not charged again
        # regardless of a win or loss.
        self.assertEqual(simulation.account.get_balance(), 100,
                         "Balance was changed when roll was lost.")
Пример #3
0
    def test_base_bet_2(self):
        config = Configuration(base_bet=2,
                               payout=2,
                               iterations=1,
                               loss_adder=100)
        account = Account(balance=10)
        simulation = Simulation(config=config, account=account, random_seed=12)
        sim_result = simulation.single_sim()

        self.assertEqual(
            sim_result.get_balances(), [10, 8, 12, 10, 6],
            "Incorrect sequence of balances in single simulation,"
            " base_bet=2")
Пример #4
0
    def test_base_bet_1(self):
        config = Configuration(base_bet=1,
                               payout=2,
                               iterations=1,
                               loss_adder=100)
        account = Account(balance=5)
        simulation = Simulation(config=config, account=account, random_seed=4)
        sim_result = simulation.single_sim()

        self.assertEqual(
            sim_result.get_balances(),
            [5, 6, 5, 7, 6, 4, 8, 9, 10, 11, 10, 8, 12, 13, 14, 13, 11, 7],
            "Incorrect sequence of balances in "
            "single simulation, base_bet=1")
Пример #5
0
 def test_positive(self):
     account = Account(balance=20)
     account.add(5)
     self.assertEqual(account.get_balance(), 25,
                      "The balance was not appropriately added to when a "
                      "positive integer of 5 was added")
Пример #6
0
 def test_float(self):
     account = Account(balance=20)
     account.subtract(5.5)
     self.assertEqual(account.get_balance(), 15,
                      "The balance was not appropriately subtracted from"
                      " when a float of 5.5 was subtracted")
Пример #7
0
 def test_zero(self):
     account = Account(balance=20)
     account.subtract(0)
     self.assertEqual(account.get_balance(), 20,
                      "The balance was did not remain the same when 0 was"
                      " subtracted")
Пример #8
0
 def test_negative(self):
     account = Account(balance=20)
     account.subtract(-5)
     self.assertEqual(account.get_balance(), 25,
                      "The balance was not appropriately subtracted from"
                      " to when a negative integer of -5 was subtracted")
Пример #9
0
 def test_positive(self):
     account = Account(balance=20)
     account.subtract(5)
     self.assertEqual(account.get_balance(), 15,
                      "The balance was not appropriately subtracted from"
                      " when a positive integer of 5 was subtracted")
Пример #10
0
 def test_float(self):
     account = Account(balance=20)
     account.add(5.5)
     self.assertEqual(account.get_balance(), 25,
                      "The balance was not appropriately added to when a "
                      "float of 5.5 was added")
Пример #11
0
 def test_negative(self):
     account = Account(balance=20)
     account.add(-5)
     self.assertEqual(account.get_balance(), 15,
                      "The balance was not appropriately added to when a "
                      "negative integer of -5 was added")
Пример #12
0
 def setUp(self):
     self.account = Account(balance=100)
     self.config = Configuration(base_bet=10, payout=2, iterations=200)
Пример #13
0
 def setUp(self):
     self.account = Account(balance=100)
Пример #14
0
 def setUp(self):
     # Account is not relevant to the test, but still necessary for setup
     self.account = Account(balance=50)
Пример #15
0
 def setUp(self):
     # Account is not relevant to rolls, but still necessary for setup
     self.account = Account(balance=100)