class TestPlayfield(object): SAMPLE_RECT = Rect(Vector2(5, 5), Vector2(100, 50)) def setup(self): self.playfield = Playfield(self.SAMPLE_RECT) def test_given_point_near_top_border_when_getting_distance_to_border_then_distance_is_returned(self): distance = self.playfield.distance_to_border(Vector2(50, 10)) assert_equals(round(distance), 10) def test_given_point_near_left_border_when_getting_distance_to_border_then_distance_is_returned(self): distance = self.playfield.distance_to_border(Vector2(5, 10)) assert_equals(round(distance), 5) def test_given_point_near_right_border_when_getting_distance_to_border_then_distance_is_returned(self): distance = self.playfield.distance_to_border(Vector2(90, 20)) assert_equals(round(distance), 10) def test_given_point_near_bottom_border_when_getting_distance_to_border_then_distance_is_returned(self): distance = self.playfield.distance_to_border(Vector2(75, 40)) assert_equals(round(distance), 10)
def setup(self): self.playfield = Playfield(self.SAMPLE_RECT)