public void NoConstraints_ReturnsCorrectFullLine() { Position start = new Position(1, 1); Position end = new Position(4, 3); var creator = new BresenhamLineCreator(); IList <Position> result = creator.GetRasterLine(start.x, start.y, end.x, end.y); result.Should().BeEquivalentTo(new[] { new Position(1, 1), new Position(2, 2), new Position(3, 2), new Position(4, 3) }, options => options.WithStrictOrdering()); }
public void LineWithObstacleAndLimitAndLimitIsAfterObstacle_ReturnsLineTerminatedOnObstacle() { Position start = new Position(1, 1); Position end = new Position(4, 3); var creator = new BresenhamLineCreator(); Position blocker = new Position(2, 2); IList <Position> result = creator.GetRasterLine(start.x, start.y, end.x, end.y, 500, position => position != blocker, true); result.Should().BeEquivalentTo(new[] { new Position(1, 1), new Position(2, 2) }, options => options.WithStrictOrdering()); }
public void LineWithObstacleAndDoesNotAllowFinishOnBlocker_ReturnsLineFinishingBeforeBlocker() { Position start = new Position(1, 1); Position end = new Position(4, 3); var creator = new BresenhamLineCreator(); Position blocker = new Position(2, 2); IList <Position> result = creator.GetRasterLine(start.x, start.y, end.x, end.y, position => position != blocker, false); result.Should().BeEquivalentTo(new[] { new Position(1, 1) }, options => options.WithStrictOrdering()); }
public void LineWithLimitZero_ReturnsEmptyLine() { Position start = new Position(1, 1); Position end = new Position(4, 3); var creator = new BresenhamLineCreator(); int limit = 0; IList <Position> result = creator.GetRasterLine(start.x, start.y, end.x, end.y, limit); result.Should().BeEquivalentTo(new Position[] {}, options => options.WithStrictOrdering()); }
public void LineWithPositiveLimit_ReturnsLineWithProperLength() { Position start = new Position(1, 1); Position end = new Position(4, 3); var creator = new BresenhamLineCreator(); int limit = 3; IList <Position> result = creator.GetRasterLine(start.x, start.y, end.x, end.y, limit); result.Should().BeEquivalentTo(new[] { new Position(1, 1), new Position(2, 2), new Position(3, 2) }, options => options.WithStrictOrdering()); }