Ejemplo n.º 1
0
    def test_set_point_with_valid_coordinates(self):
        """
        Test that a point on the screen can be set with a value
        """
        test_screen = Screen(2, 2)
        test_screen.set_point(1, 1, "#")

        expected_point = "#"
        actual_point = test_screen.get_point(1, 1)

        self.assertEqual(expected_point, actual_point)
    def test_draw_line_horizontally_with_valid_coordinates(self):
        """
        A test that a horizontal line can be drawn
        """
        screen = Screen(3, 3)

        ScreenHelper.draw_line(screen, 0, 0, 0, 1, "#")

        expected_screen = Screen(3, 3)
        expected_screen.set_point(0, 0, "#")
        expected_screen.set_point(0, 1, "#")

        self.assertListEqual(screen.get_matrix(), expected_screen.get_matrix())
    def test_draw_line_diagonally_with_valid_coordinates(self):
        """
        A test that a diagonal line can be drawn
        """
        screen = Screen(4, 4)

        ScreenHelper.draw_line(screen, 1, 1, 2, 2, "#")

        expected_screen = Screen(4, 4)
        expected_screen.set_point(1, 1, "#")
        expected_screen.set_point(2, 2, "#")

        self.assertListEqual(screen.get_matrix(), expected_screen.get_matrix())
Ejemplo n.º 4
0
    def test_get_matrix(self):
        """
        Test that the screen returns the correct matrix
        """
        test_screen = Screen(2, 2)
        test_screen.set_point(0, 0, "1")
        test_screen.set_point(1, 0, "2")
        test_screen.set_point(0, 1, "3")
        test_screen.set_point(1, 1, "4")

        actual_matrix = test_screen.get_matrix()
        expected_matrix = [["1", "2"], ["3", "4"]]

        self.assertListEqual(expected_matrix, actual_matrix)