Exemplo n.º 1
0
        public void IsInsideTests()
        {
            var square = new Square(2, 2, 2);

            var pointIn = new Point(1, 1);
            var pointOn = new Point(3, 2);
            var pointOut = new Point(3, 4);

            Assert.IsTrue(square.IsInside(pointIn));
            Assert.IsTrue(square.IsInside(pointOn));
            Assert.IsFalse(square.IsInside(pointOut));
        }
Exemplo n.º 2
0
        public void BottomRightTest()
        {
            // Arrange
            var square = new Square(2, 2, 2);
            var expectedBottomRight = new Point(3, 1);

            // Act
            var actualBottomRight = square.BottomRight;

            // Assert
            Assert.AreEqual(expectedBottomRight, actualBottomRight);
        }
Exemplo n.º 3
0
        public void TopLeftTest()
        {
            // Arrange
            var square = new Square(2, 2, 2);
            var expectedTopLeft = new Point(1, 3);

            // Act
            var actualTopLeft = square.TopLeft;

            // Assert
            Assert.AreEqual(expectedTopLeft, actualTopLeft);
        }
Exemplo n.º 4
0
        public List<Address> FindNearbyAddresses(Address address, int squareSize)
        {
            var nearbyAddresses = new List<Address>();
            var searchSquare = new Square(address.Easting, address.Northing, squareSize);

            using (var context = new GridSearchDb())
            {
                nearbyAddresses = context.Addresses
                    .AsEnumerable()
                    .Where(a => Square.IsInside(a.Easting, a.Northing, searchSquare))
                    .ToList();
            }

            nearbyAddresses.RemoveAll(a => a.Equals(address)); // exclude original address from search

            return nearbyAddresses;
        }
Exemplo n.º 5
0
 public static bool IsInside(int pointX, int pointY, Square square)
 {
     return square.IsInside(new Point(pointX, pointY));
 }