Пример #1
0
        public GridSize Parse(String text)
        {
            if (text == null)
            {
                throw new ArgumentNullException("text");
            }
            if (String.IsNullOrWhiteSpace(text))
            {
                throw new ArgumentException("Parameter cannot be empty or whitespace", "text");
            }

            var segments = text.Split(' ');

            if (segments.Length < 2)
            {
                throw new TooFewSegmentsException();
            }
            if (segments.Length > 2)
            {
                throw new TooManySegmentsException();
            }

            var width  = GetDimensionValue(segments[0], s => new InvalidWidthException(s));
            var height = GetDimensionValue(segments[1], s => new InvalidHeightException(s));

            return(GridSize.From(width, height));
        }
 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()
         }))
     }
                       ));
 }
        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 void should_have_correct_dimensions()
        {
            var expected = GridSize.From(5, 6);

            Assert.That(_gridSize, Is.EqualTo(expected));
        }