def test_accelerate_race_car_multiple_times_when_nitro_available_and_update_current_speed( ): # Arrange race_car = RaceCar(color='Red', max_speed=100, acceleration=15, tyre_friction=15) current_speed_value = 85 race_car.start_engine() race_car.accelerate() race_car.accelerate() race_car.accelerate() race_car.accelerate() race_car.accelerate() race_car.apply_brakes() race_car.apply_brakes() race_car.apply_brakes() # Act race_car.accelerate() race_car.accelerate() race_car.accelerate() # Assert assert race_car.current_speed == current_speed_value
def test_apply_breake_racecar_current_equals_to_half_max_speed_returns_nitro_zero(): # Arrange racecar = RaceCar(color="Red", max_speed=30, acceleration=15, tyre_friction=7) racecar.start_engine() racecar.accelerate() # Act racecar.apply_brakes() # Assert assert racecar.nitro == 0
def test_accelerate_racecar_more_than_max_limit_with_nitro_returns_current_speed(): # Arrange racecar = RaceCar(color="Red", max_speed=25, acceleration=10, tyre_friction=7) racecar.start_engine() racecar.accelerate() racecar.accelerate() racecar.apply_brakes() # Act racecar.accelerate() # Assert assert racecar.current_speed == 25
def test_apply_brakes_to_race_car_and_update_current_speed(): # Arrange race_car = RaceCar(color='Red', max_speed=100, acceleration=10, tyre_friction=10) current_speed_value = 0 race_car.start_engine() race_car.accelerate() # Act race_car.apply_brakes() # Assert assert race_car.current_speed == current_speed_value
def test_apply_brakes_when_race_car_current_speed_is_more_than_tyre_friction_and_update_current_speed( ): # Arrange race_car = RaceCar(color='Red', max_speed=4, acceleration=4, tyre_friction=3) current_speed_value = 1 race_car.start_engine() race_car.accelerate() # Act race_car.apply_brakes() # Assert assert race_car.current_speed == current_speed_value
def test_apply_brakes_to_race_car_when_current_speed_not_more_than_half_the_max_speed_and_nitro_value( ): # Arrange race_car = RaceCar(color='Red', max_speed=100, acceleration=20, tyre_friction=10) current_speed_value = 0 race_car.start_engine() race_car.accelerate() race_car.accelerate() nitro_value = 0 # Act race_car.apply_brakes() # Assert assert race_car.nitro == nitro_value
def test_apply_break_when_current_speed_is_less_than_max_speed_returns_current_speed(): # Arrange racecar1 = RaceCar(color="None", max_speed=100, acceleration=10, tyre_friction=1) racecar1.start_engine() racecar1.accelerate() racecar1.accelerate() racecar1.accelerate() racecar1.accelerate() racecar1.accelerate() racecar1.accelerate() racecar1.accelerate() racecar1.accelerate() racecar1.apply_brakes() # Act racecar1.accelerate() # Assert assert racecar1.current_speed == 92
def test_accelerate_race_car_when_nitro_available_and_update_current_speed(): import math # Arrange color = 'Red' max_speed = 20 acceleration = 6 tyre_friction = 3 race_car = RaceCar(color=color, max_speed=max_speed, acceleration=acceleration, tyre_friction=tyre_friction) current_speed_value = math.ceil((2 * acceleration - tyre_friction) + (0.3) * acceleration + acceleration) race_car.start_engine() race_car.accelerate() race_car.accelerate() race_car.apply_brakes() # Act race_car.accelerate() # Assert assert race_car.current_speed == current_speed_value