Exemplo n.º 1
0
        public void PositionHelperGrid_ShouldRespectBounds()
        {
            // Arrange
            var rect       = new Rectangle(0, 0, 1920, 1080);
            var pointCount = 50;

            // Act
            var grid         = PositionHelper.CalculateGrid(rect, pointCount);
            var badPositions = new List <Position>();

            foreach (var position in grid)
            {
                if (position.Vector.X <rect.X | position.Vector.X> rect.Width)
                {
                    badPositions.Add(position);
                }
                if (position.Vector.Y <rect.Y | position.Vector.Y> rect.Height)
                {
                    badPositions.Add(position);
                }
            }

            // Assert
            Assert.AreEqual(0, badPositions.Count);
        }
Exemplo n.º 2
0
        public void PositionHelperGrid_ShouldContainNoZeroVectors()
        {
            // Arrange
            var rect       = new Rectangle(0, 0, 500, 400);
            var pointCount = 50;
            var zero       = new Position(0, 0);

            // Act
            var grid   = PositionHelper.CalculateGrid(rect, pointCount);
            var zeroes = from position in grid where position.Equals(zero) select position;

            // Assert
            // check no zero vectors
            Assert.AreEqual(0, zeroes.Count());
        }