Exemple #1
0
        public void ShouldParseCommandsFile()
        {
            IParser parser = new Parser();

            var result = parser.Read("Data/simple.txt");

            var expected = new ParserResult
            {
                WorldWidth = 25,
                WorldHeight = 25,
                Rovers = new List<Rover>
                {
                    new Rover(1, 2, Orientation.North),
                    new Rover(3, 3, Orientation.East)
                }
            };

            expected.Rovers[0].AddCommands(new List<Command>
            {
                Command.TurnLeft,
                Command.MoveForward,
                Command.TurnRight
            });

            expected.Rovers[1].AddCommands(new List<Command>
            {
                Command.MoveForward,
                Command.TurnLeft,
                Command.TurnRight,
            });

            AssExt.AreEqualByJson(result, expected);
        }
Exemple #2
0
        public World(ParserResult result)
        {
            worldWidth = result.WorldWidth;
            worldHeight = result.WorldHeight;

            rovers = new List<Rover>();

            for(int i = 0; i < result.Rovers.Count; i++)
            {
                var rover = result.Rovers[i];

                // Determine the highest amount of commands for the simulation loop.
                if (rover.Commands.Count > simulationCount)
                    simulationCount = rover.Commands.Count;

                rovers.Add(rover);
            }
        }
Exemple #3
0
 public Parser()
 {
     result = new ParserResult();
 }