コード例 #1
0
        public bool ValidateLine(Canvas.Canvas existingCanvas, string[] args)
        {
            List <Point> points = LinePoints(args);
            Point        point1 = points[0];
            Point        point2 = points[1];

            if (canvasOpp.IsPointOutOfBounds(point1, existingCanvas) || canvasOpp.IsPointOutOfBounds(point2, existingCanvas))
            {
                Console.WriteLine("Point(s) for the line are out of Canvas.");
                return(false);
            }
            else
            {
                return(true);
            }
        }
コード例 #2
0
        public bool ValidateRectangle(Canvas.Canvas existingCanvas, string[] args)
        {
            Rectangle rect = GetRectangleObjectsFromInput(args);

            if (canvasOpp.IsPointOutOfBounds(rect.TopLeft, existingCanvas) ||
                canvasOpp.IsPointOutOfBounds(rect.TopRight, existingCanvas) ||
                canvasOpp.IsPointOutOfBounds(rect.BottomLeft, existingCanvas) ||
                canvasOpp.IsPointOutOfBounds(rect.BottomRight, existingCanvas))
            {
                Console.WriteLine("Point(s) for the Rectangle are out of Canvas.");
                return(false);
            }
            else
            {
                return(true);
            }
        }
コード例 #3
0
        public void Should_CheckPoint_OutOfBound()
        {
            Random rnd    = new Random();
            int    width  = rnd.Next(1, 25);
            int    height = rnd.Next(1, 25);

            string[] args = new string[2] {
                width.ToString(), height.ToString()
            };
            var   canvas = _canvasOpp.DrawCanvas(args);
            Point p      = new Point(Convert.ToUInt32(rnd.Next(26, 100)), Convert.ToUInt32(rnd.Next(26, 100)));
            bool  result = _canvasOpp.IsPointOutOfBounds(p, canvas);

            result.ShouldBeSameAs(true);
        }
コード例 #4
0
 private bool ChechIfToBeFilled(Point point, List <Point> pointsFilled, Queue <Point> pointsToFill, Canvas.Canvas existingCanvas)
 {
     return(!pointsFilled.Contains(point) && !pointsToFill.Contains(point) && !canvasOpp.IsPointOutOfBounds(point, existingCanvas));
 }