public void CommandHandler_GivenCommands_ReturnCorrectRoverPosition(string[] input, string expectedRoverPosition)
        {
            CommandHandlerService commandHandlerService = new CommandHandlerService();

            List <Rover> rovers = commandHandlerService.ParseCommands(input);

            Assert.Equal(rovers.First().GetRoverPositionDetailedString(), expectedRoverPosition);
        }
        public void CommandHandler_GivenCommandParameters_ReturnCorrectRoverPositions(string[] input, string[] expectedRoverPositions)
        {
            Application.CommandHandlerService commandHandlerService = new CommandHandlerService();

            List <Rover> rovers = commandHandlerService.ParseCommands(input);


            Assert.Equal(rovers.Select(c => c.GetRoverPositionDetailedString()).ToArray(), expectedRoverPositions);
        }
        public void CommandHandler_GivenWrongPleateuCommands_ReturnInvalidOperationException()
        {
            CommandHandlerService commandHandlerService = new CommandHandlerService();
            var input = new string[] { "5 5", "5 5 N", "MM" };

            Action act = () => commandHandlerService.ParseCommands(input);

            Assert.Throws <InvalidOperationException>(act);
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Debug()
                         .WriteTo.Console(restrictedToMinimumLevel: LogEventLevel.Debug)
                         .CreateLogger();

            try
            {
                var commandText         = @"5 5
                                    1 2 N
                                    LMLMLMLMM
                                    3 3 E
                                    MMRMMRMRRM";
                CommandHandlerService s = new CommandHandlerService();

                Console.WriteLine(s.ParseCommands(commandText.Split(Environment.NewLine)).Select(c => c.GetRoverPositionDetailedString()).ToArray());
            }
            catch (Exception)
            {
                throw;
            }
        }