Ejemplo n.º 1
0
        public void ItExists()
        {
            // Arrange
            IEnumerable <string> moves = new List <string> {
                "R8", "U5", "L5", "D3"
            };
            var path = new DayOne.Path(moves);

            // Act & Assert
            IEnumerable <(int, int)> points = path.Build();
        }
Ejemplo n.º 2
0
        public void GivenARightWithOneUnitFollowedByALeftWithOneUnitDirectionShouldExpectedCoordinates()
        {
            // Arrange
            IEnumerable <string> moves = new List <string> {
                "R1", "L1"
            };
            var path = new DayOne.Path(moves);

            // Act
            List <(int, int)> result = path.Build().ToList();

            // Assert
            Assert.NotNull(result);
            Assert.Equal(2, result.Count);
            Assert.Equal((0, 0), result[1]);
        }
Ejemplo n.º 3
0
        public void GivenALeftWithOneUnitDirectionShouldReturnExpectedCoordinates()
        {
            // Arrange
            IEnumerable <string> moves = new List <string> {
                "L1"
            };
            var path = new DayOne.Path(moves);

            // Act
            List <(int, int)> result = path.Build().ToList();

            // Assert
            Assert.NotNull(result);
            Assert.Single(result);
            Assert.Equal((-1, 0), result[0]);
        }
Ejemplo n.º 4
0
        public void GivenARightWithTwoUnitDirectionShouldReturnTwoElementInList()
        {
            // Arrange
            IEnumerable <string> moves = new List <string> {
                "R2"
            };
            var path = new DayOne.Path(moves);

            // Act
            List <(int, int)> result = path.Build().ToList();

            // Assert
            Assert.NotNull(result);
            Assert.Equal(2, result.Count());
            Assert.Equal((1, 0), result[0]);
        }
Ejemplo n.º 5
0
        public void GivenARightWithOneUnitDirectionShouldReturnOneElementInList()
        {
            // Arrange
            IEnumerable <string> moves = new List <string> {
                "R1"
            };
            var path = new DayOne.Path(moves);

            // Act
            IEnumerable <(int, int)> result = path.Build();

            // Assert
            Assert.NotNull(result);
            Assert.Single(result);
            Assert.Equal((1, 0), result.First());
        }
Ejemplo n.º 6
0
        public void ItExists()
        {
            // Arrange
            var pathOneMoves = new List <string> {
                "R8", "U5", "L5"
            };
            var pathTwoMoves = new List <string> {
                "U7", "R6", "D4"
            };

            var pathOne = new DayOne.Path(pathOneMoves);
            var pathTwo = new DayOne.Path(pathTwoMoves);

            var distance = new Distance(pathOne.Build(), pathTwo.Build());

            // Act & Assert
            int result = distance.GetDistanceFromNearestIntersection();
        }
Ejemplo n.º 7
0
        public void GivenOtherMultipleIntersectionsShouldReturnDistance()
        {
            // Arrange
            var pathOneMoves = new List <string> {
                "R98", "U47", "R26", "D63", "R33", "U87", "L62", "D20", "R33", "U53", "R51"
            };
            var pathTwoMoves = new List <string> {
                "U98", "R91", "D20", "R16", "D67", "R40", "U7", "R15", "U6", "R7"
            };

            var pathOne = new DayOne.Path(pathOneMoves);
            var pathTwo = new DayOne.Path(pathTwoMoves);

            var distance = new Distance(pathOne.Build(), pathTwo.Build());

            // Act
            int result = distance.GetDistanceFromNearestIntersection();

            // Assert
            Assert.Equal(135, result);
        }
Ejemplo n.º 8
0
        public void GivenMultipleIntersectionsShouldReturnDistance()
        {
            // Arrange
            var pathOneMoves = new List <string> {
                "R75", "D30", "R83", "U83", "L12", "D49", "R71", "U7", "L72"
            };
            var pathTwoMoves = new List <string> {
                "U62", "R66", "U55", "R34", "D71", "R55", "D58", "R83"
            };

            var pathOne = new DayOne.Path(pathOneMoves);
            var pathTwo = new DayOne.Path(pathTwoMoves);

            var distance = new Distance(pathOne.Build(), pathTwo.Build());

            // Act
            int result = distance.GetDistanceFromNearestIntersection();

            // Assert
            Assert.Equal(159, result);
        }
Ejemplo n.º 9
0
        public void GivenTwoIntersectionsShouldReturnDistance()
        {
            // Arrange
            var pathOneMoves = new List <string> {
                "R8", "U5", "L5", "D3"
            };
            var pathTwoMoves = new List <string> {
                "U7", "R6", "D4", "L4"
            };

            var pathOne = new DayOne.Path(pathOneMoves);
            var pathTwo = new DayOne.Path(pathTwoMoves);

            var distance = new Distance(pathOne.Build(), pathTwo.Build());

            // Act
            int result = distance.GetDistanceFromNearestIntersection();

            // Assert
            Assert.Equal(6, result);
        }