Ejemplo n.º 1
0
 def test_buy_tank_valid_args_valid_credits_check_adding_tank_to_player(self):
     s=Shop()
     db_test_fill(s)
     p=player()
     p.resources.credits  =  1000000
     p.resources.gold     =  1000000
     s._Shop__buyTank(p,5555)
     self.assertEqual(player.inventoryPlanes, [5555], msg="we hope to see buyed tank in player inventoryPlanes list")
Ejemplo n.º 2
0
 def test_buy_tank_with_invalid_id_type_saved_result_False(self):
     s=Shop()
     db_test_fill(s)
     p=player()
     p.resources.credits=1000
     p.resources.gold=1000
     s._Shop__buyTank(p,"1101")
     self.assertFalse(p.saved_result, msg = "wrong tankID type - we waiting NO player.saveResources run")
Ejemplo n.º 3
0
 def test_buy_tank_no_enought_resources__result_empty_inventoryPlanes(self):
     s=Shop()
     db_test_fill(s)
     p=player()
     p.resources.credits=0
     p.resources.gold=0
     s._Shop__buyTank(p , 9999)
     self.assertEqual(p.inventoryPlanes, [], msg="if player have no enough resources he can not buy tank ")
Ejemplo n.º 4
0
 def test_buy_tank_negative_credits_result_no_actions(self):
     s=Shop()
     db_test_fill(s)
     s.db.tanks[999999999]= {'credits': -100, 'gold': 0}
     p=player()
     p.resources.credits=0
     p.resources.gold=0
     s._Shop__buyTank(p,999999999)
     self.assertEqual(p.resources.credits , 0, msg="user buy tank and get prize?")
Ejemplo n.º 5
0
 def test_buy_tank_double_buy_valid_args_valid_credits_result_one_buy(self):
     s=Shop()
     db_test_fill(s)
     p=player()
     p.resources.credits=1000
     p.resources.gold=0
     s._Shop__buyTank(p,500)
     s._Shop__buyTank(p,500)
     self.assertEqual(p.inventoryPlanes , [500], msg="we waiting one tank")
Ejemplo n.º 6
0
 def test_buy_tank_wrong_parameters_instance_result_exception(self):
     s=Shop()
     db_test_fill(s)
     try:
         s._Shop__buyTank("123" , "123")
         res=False
     except Exception,e:
         print e
         res=True
Ejemplo n.º 7
0
 def test_buy_tank_valid_args_valid_credits_result_correct_credits(self):
     s=Shop()
     db_test_fill(s)
     p=player()
     p.resources.credits=0
     p.resources.gold=0
     s._Shop__buyTank(p,9999)
     self.assertEqual(p.resources.credits , 0, msg="wrong credits charge, while player have no credits")
     self.assertEqual(p.resources.gold , 0, msg="wrong gold charge, while player have no gold")
Ejemplo n.º 8
0
 def test_buy_tank_valid_args_valid_credits_check_double_charge(self):
     s=Shop()
     db_test_fill(s)
     p=player()
     p.resources.credits  =  1000
     p.resources.gold     =  1000
     s._Shop__buyTank(p,500)
     self.assertEqual(p.resources.credits, 500, msg= " error charging credits while first buying tank")
     s._Shop__buyTank(p,500)
     self.assertEqual(p.resources.credits, 500, msg= " error charging credits while second buying tank")
Ejemplo n.º 9
0
 def test_buy_tank_valid_args_valid_credits_check_charge_value(self):
     s=Shop()
     db_test_fill(s)
     p=player()
     p.resources.credits  =  1000000
     p.resources.gold     =  1000000
     s._Shop__buyTank(p,5555)
     self.assertEqual(p.resources.credits, 1000000, msg="error charging credits while buying tank 5555")
     self.assertEqual(p.resources.gold,    1000000, msg="error charging gold while buying tank 5555")
     s._Shop__buyTank(p,0000)
     self.assertEqual(p.resources.credits, 1000000, msg="error charging credits while buying tank 0000")
     self.assertEqual(p.resources.gold,    1000000, msg="error charging gold while buying tank 0000")
     s._Shop__buyTank(p,6666)
     self.assertEqual(p.resources.credits, 1000000-6666, msg="error charging credits while buying tank 6666")
     self.assertEqual(p.resources.gold,    1000000-6666, msg="error charging gold while buying tank 6666")