def testValidateRectangle(self): r1 = Rectangle(1, 1, 4, 1, 4, 3, 1, 3) Validator.validateRectangle(r1, "Rectangle unexpectedly invalid") self.assertRaises( ShapeException, Validator.validateRectangle, "(1, 1, 4, 1, 4, 3, 1, 3)", "String \'(1, 1, 4, 1, 4, 3, 4, 3)\' is not a valid rectangle") self.assertRaises(ShapeException, Validator.validateRectangle, Point(1, 1), "Point is not a valid rectangle")
def __constructWithLines(self, line1, line2, line3, line4): try: self.__line1 = line1 self.__line2 = line2 self.__line3 = line3 self.__line4 = line4 Validator.validateRectangle(value=self, errorMessage="Invalid Rectangle") return True except ShapeException: return False
def __constructWithPoints(self, point1, point2, point3, point4): try: self.__line1 = Line(point1, point2) self.__line2 = Line(point2, point3) self.__line3 = Line(point3, point4) self.__line4 = Line(point4, point1) Validator.validateRectangle(value=self, errorMessage="Invalid Rectangle") return True except ShapeException: return False
def __constructWithCoords(self, x1, y1, x2, y2, x3, y3, x4, y4): try: self.__line1 = Line(x1, y1, x2, y2) self.__line2 = Line(x2, y2, x3, y3) self.__line3 = Line(x3, y3, x4, y4) self.__line4 = Line(x4, y4, x1, y1) Validator.validateRectangle(value=self, errorMessage="Invalid Rectangle") return True except ShapeException: return False