public void FindForItem_FirstDestinationIsWalkableAndUnoccupied_ReturnsFirstDestination() { var checkedPosition = new Position(1, 1); IGrid gip = Mock.Of <IGrid>(p => p.IsWalkable(checkedPosition) == true); IEntityDetector entityDetector = Mock.Of <IEntityDetector>(d => d.DetectEntities(checkedPosition) == Enumerable.Empty <GameEntity>()); var finder = new FirstPlaceInAreaFinder(gip, entityDetector, new RandomNumberGenerator(93432)); Position?result = finder.FindForItem(checkedPosition); result.Should().Be(checkedPosition); }
public void FindForItem_NoNeighboursAndFirstDestinationIsUnoccupiedButWalkable_ReturnsFailure() { var checkedPosition = new Position(1, 1); IGrid gip = Mock.Of <IGrid>(p => p.IsWalkable(It.IsAny <Position>()) == false); IEntityDetector entityDetector = Mock.Of <IEntityDetector>(d => d.DetectEntities(checkedPosition) == Enumerable.Empty <GameEntity>()); var finder = new FirstPlaceInAreaFinder(gip, entityDetector, new RandomNumberGenerator(93432)); Position?result = finder.FindForItem(checkedPosition); result.Should().BeNull(); }
public void FindForItem_FirstDestinationAndMostNeighboursAreNotEligibleButOneNeighbourIs_ReturnsNeighbour() { var checkedPosition = new Position(1, 1); var eligibleNeighbour = new Position(2, 1); IGrid gip = Mock.Of <IGrid>(p => p.IsWalkable( It.Is <Position>(v => PositionUtilities.Neighbours8(checkedPosition).Contains(v)) ) == false && p.IsWalkable(eligibleNeighbour) == true); IEntityDetector entityDetector = Mock.Of <IEntityDetector>(d => d.DetectEntities(checkedPosition) == Enumerable.Empty <GameEntity>()); var finder = new FirstPlaceInAreaFinder(gip, entityDetector, new RandomNumberGenerator(93432)); Position?result = finder.FindForItem(checkedPosition); result.Should().Be(eligibleNeighbour); }