/// <summary> /// Create rectangle from center coordinates and height / width /// </summary> /// <param name="y">center row</param> /// <param name="x">center column</param> /// <param name="rows">total height</param> /// <param name="columns">total width</param> /// <returns>a new rectangle</returns> public static Rectangle FromCenter(int y, int x, int rows, int columns) { EvenException.Check(nameof(rows), rows); EvenException.Check(nameof(columns), columns); OutOfRangeException.Check(nameof(rows), rows, 1); OutOfRangeException.Check(nameof(columns), columns, 1); var relHeight = (rows - 1) / 2; var relWidth = (columns - 1) / 2; var top = y - relHeight; var left = x - relWidth; var region = new Rectangle(left, top, columns, rows); return(region); }
public void EvenException_ThrowsException() { Assert.Catch <EvenException>(() => EvenException.Check("", 2)); }
public void EvenException_Ok() { EvenException.Check("", 1); Assert.Pass(); }