Exemple #1
0
 /// <summary>
 /// Method validating rectangles according to specifications:
 /// DeltaX and DeltaY are positive integers
 /// </summary>
 /// <param name="rectangle">A valid rectangle</param>
 public static void Validate(InputRectangle rectangle)
 {
     if (rectangle.DeltaX <= 0 || rectangle.DeltaY <= 0)
     {
         throw new ArgumentOutOfRangeException("Rectangles should all have positive width and height");
     }
 }
        public void ValidRectangleTest()
        {
            InputRectangle rectangle = new InputRectangle()
            {
                X      = 10,
                Y      = 20,
                DeltaX = 100,
                DeltaY = 100
            };

            Assert.DoesNotThrow(() => RectangleValidator.Validate(rectangle));
        }
        public void RectangleWithNegativeWidthAndNegativeHeightTest()
        {
            InputRectangle rectangle = new InputRectangle()
            {
                X      = 10,
                Y      = 20,
                DeltaX = -100,
                DeltaY = -100
            };

            Assert.Throws <ArgumentOutOfRangeException>(() => RectangleValidator.Validate(rectangle));
        }