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));
        }
예제 #2
0
 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;
 }
예제 #3
0
 protected bool Equals(XYCellLocation other)
 {
     return X == other.X && Y == other.Y;
 }