GetRandomInRect() public method

Returns random position in rect, centered on this position.
public GetRandomInRect ( int width, int height, Random rnd ) : Position
width int
height int
rnd System.Random
return Position
Ejemplo n.º 1
0
		public void GetRandomInRect()
		{
			var rnd = new Random(Environment.TickCount);
			var pos = new Position(10, 10);

			for (int i = 0; i < 10000; ++i)
			{
				var rndPos = pos.GetRandomInRect(10, 10, rnd);
				Assert.InRange(pos.X, 0, 20);
				Assert.InRange(pos.Y, 0, 20);
			}
		}