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)
    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())
Example #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)
    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())
Example #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())
    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())
Example #7
0
 def test_position_with_no_params_corresponds_to_origin(self):
     position = Position()
     self.assertEqual(0,position.x())
     self.assertEqual(0, position.y())
Example #8
0
 def test_position_can_be_created_with_no_params(self):
     position = Position()
     self.assertTrue(position != None)
Example #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)
Example #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)
Example #11
0
 def test_distance_to_same_possition_is_zero(self):
     position = Position(1, 3)
     self.assertEqual(0, position.distance_to(position))
Example #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())
Example #13
0
 def test_projectile_is_create_with_inital_position(self):
     projectile = Projectile(Position(5,25))
     self.assertTrue(isinstance(projectile,Projectile))
Example #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())