Ejemplo n.º 1
0
    def test_create_velocity_with_two_positions(self):
        start_position = Position()
        end_position = Position(4, 3)

        velocity = Velocity(start_position, end_position)

        self.assertIsNotNone(velocity)
Ejemplo n.º 2
0
    def test_magnitude_of_velocity_is_given_by_pythagoras_theorem(self):
        start_position = Position()
        end_position = Position(4, 3)

        velocity = Velocity(start_position, end_position)

        self.assertEquals(5, velocity.magnitude())
Ejemplo n.º 3
0
    def test_angle_of_velocity_is_determined_by_the_arctangent(self):
        start_position = Position()
        end_posotion = Position(3, 4)

        velocity = Velocity(start_position, end_posotion)
        self.assertTrue(velocity.angle() > 45)
        self.assertTrue(velocity.angle() < 90)
Ejemplo n.º 4
0
    def test_angle_of_velocity_is_45_if_x_and_y_of_end_position_are_the_same(
            self):
        start_position = Position()
        end_position = Position(2, 2)

        velocity = Velocity(start_position, end_position)

        self.assertEquals(45, velocity.angle())
Ejemplo n.º 5
0
    def test_position_changes_when_projectile_is_shoot(self):

        initial_position = Position()
        projectile = Projectile(Position())
        velocity = Velocity(Position(), Position(3, 5))

        projectile.shoot(velocity)

        self.assertTrue(isinstance(projectile.position()))
        self.assertNotEquals(initial_position(), projectile.position())
Ejemplo n.º 6
0
    def test_magnitude_is_zero_if_start_and_end_positions_are_the_same(self):
        position = Position(1, 1)
        velocity = Velocity(position, position)

        self.assertEquals(0, velocity.magnitude())
Ejemplo n.º 7
0
 def test_position_with_no_params_corresponds_to_origin(self):
     position = Position()
     self.assertEqual(0,position.x())
     self.assertEqual(0, position.y())
Ejemplo n.º 8
0
 def test_position_can_be_created_with_no_params(self):
     position = Position()
     self.assertTrue(position != None)
Ejemplo n.º 9
0
 def test_positions_with_same_coordinates_are_equal(self):
     first_post = Position(1, 2)
     second_post = Position(1, 2)
     self.assertEqual(first_post, second_post)
Ejemplo n.º 10
0
 def test_distance_is_greater_that_zero_if_possition_are_differente(self):
     first_position = Position()
     second_position = Position(1,1)
     self.assertTrue(first_position.distance_to(second_position)>0)
Ejemplo n.º 11
0
 def test_distance_to_same_possition_is_zero(self):
     position = Position(1, 3)
     self.assertEqual(0, position.distance_to(position))
Ejemplo n.º 12
0
 def test_position_can_be_created_with_x_and_y_params(self):
     position = Position(2,3)
     self.assertEqual(2, position.x())
     self.assertEqual(3, position.y())
Ejemplo n.º 13
0
 def test_projectile_is_create_with_inital_position(self):
     projectile = Projectile(Position(5,25))
     self.assertTrue(isinstance(projectile,Projectile))
Ejemplo n.º 14
0
 def test_projectile_shot_with_a_given_angle_follows_a_parabolic_path(self):
     projectile = Projectile(Position(0, 3))
     velocity = Velocity(Position(0, 3), Position(4, 6))
     projectile.shoot(velocity)
     self.assertEquals(Position(3, 0), projectile.position())