コード例 #1
0
 public Arena Parse(string[] input)
 {
     Input = input;
     return(Arena.From(GridSize.From(5, 5),
                       new[]
     {
         Robot.From(Position.From(0, 0, CardinalCompassPoint.North()),
                    Route.From(new[]
         {
             RouteStep.RotateRight90Degrees(),
             RouteStep.MoveOneGridSpace(),
             RouteStep.RotateLeft90Degrees()
         }))
     }
                       ));
 }
コード例 #2
0
        public void should_have_correct_steps()
        {
            var expected = new[]
            {
                RouteStep.RotateLeft90Degrees(),
                RouteStep.RotateRight90Degrees(),
                RouteStep.MoveOneGridSpace(),
                RouteStep.RotateRight90Degrees(),
                RouteStep.RotateLeft90Degrees(),
                RouteStep.MoveOneGridSpace(),
                RouteStep.MoveOneGridSpace(),
                RouteStep.RotateRight90Degrees(),
                RouteStep.MoveOneGridSpace(),
                RouteStep.RotateLeft90Degrees(),
                RouteStep.MoveOneGridSpace()
            };
            var route = Route.From(expected);

            Assert.That(_route, Is.EqualTo(route));
        }
        public void should_have_correct_gridsize_and_robots()
        {
            var expected = Arena.From
                               (GridSize.From(5, 6),
                               new[]
            {
                Robot.From
                    (Position.From(0, 1, CardinalCompassPoint.North()),
                    Route.From(new[]
                {
                    RouteStep.RotateRight90Degrees(),
                    RouteStep.MoveOneGridSpace(),
                    RouteStep.RotateLeft90Degrees(),
                    RouteStep.MoveOneGridSpace(),
                    RouteStep.RotateRight90Degrees(),
                    RouteStep.MoveOneGridSpace(),
                    RouteStep.RotateLeft90Degrees(),
                    RouteStep.MoveOneGridSpace()
                }))
            });

            Assert.That(_arena, Is.EqualTo(expected));
        }
コード例 #4
0
 public RouteStep Resolve(char input)
 {
     return(input == 'L' ? RouteStep.RotateLeft90Degrees() : null);
 }