public void TestCalculateManhattanDistance(string moves, int expectedDistance) { Point start = new Point(0, 0); var sut = new PointCalculator(start, moves); var lastPoint = sut.Calculate().Last(); int actualDistance = ManhattanDistance.Calculate(start, lastPoint); Assert.Equal(expectedDistance, actualDistance); }
public void TestCalculateResultOfFirstPuzzle(string firstMoves, string secondMoves, int expectedDistance) { Point start = new Point(0, 0); var sut = new PointCalculator(start, firstMoves); var pointOfFirstMoves = sut.Calculate(); sut = new PointCalculator(start, secondMoves); var pointOfSecondMoves = sut.Calculate(); var minDistanceOfIntersectingPoints = pointOfFirstMoves.Intersect(pointOfSecondMoves) .Select(p => ManhattanDistance.Calculate(start, p)) .Min(); Assert.Equal(expectedDistance, minDistanceOfIntersectingPoints); }
public void TestCalculateManhattanDistanceBetweenTwoPoints(Point p1, Point p2, int expectedDistance) { var actual = ManhattanDistance.Calculate(p1, p2); Assert.Equal(expectedDistance, actual); }