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)); }
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); }
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); }
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; }
public static bool IsInside(int pointX, int pointY, Square square) { return square.IsInside(new Point(pointX, pointY)); }