コード例 #1
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())
コード例 #2
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)
コード例 #3
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())
コード例 #4
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)
コード例 #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())
コード例 #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())
コード例 #7
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())