public void ReturnsCorrectEightNeighbours() { var cell = new XYCellLocation(1, 1); var expectedNeighbours = new[] { new XYCellLocation(0, 0), new XYCellLocation(1, 0), new XYCellLocation(2, 0), new XYCellLocation(0, 1), new XYCellLocation(2, 1), new XYCellLocation(0, 2), new XYCellLocation(1, 2), new XYCellLocation(2, 2) }; Assert.That( cell.Neighbours(), Is.EquivalentTo(expectedNeighbours)); }
private static XYCellLocation LocationAt(int x, int y) { XYCellLocation location; var key = new Tuple<int, int>(x, y); if (!_locationCache.TryGetValue(key, out location)) { location = new XYCellLocation(x, y); _locationCache.Add(key, location); } return location; }
protected bool Equals(XYCellLocation other) { return X == other.X && Y == other.Y; }