Ejemplo n.º 1
0
        public void Line5_to_RoverCommandListBuilder()
        {
            IRoverCommandParser roverCommandParser = new RoverCommandParser(plateauBuilder, roverBuilder, roverCommandListBuilder);

            roverCommandParser.Parse(arguments.ToString());

            roverCommandListBuilder.Received().Init(Arg.Any <Rover>(), "RMLMR");
        }
Ejemplo n.º 2
0
        public void Line1_to_plateauBuilder()
        {
            IRoverCommandParser roverCommandParser = new RoverCommandParser(plateauBuilder, roverBuilder, roverCommandListBuilder);

            roverCommandParser.Parse(arguments.ToString());

            plateauBuilder.Received().Init("5 5");
        }
Ejemplo n.º 3
0
        public void Line4_to_RoverBuilder()
        {
            IRoverCommandParser roverCommandParser = new RoverCommandParser(plateauBuilder, roverBuilder, roverCommandListBuilder);

            roverCommandParser.Parse(arguments.ToString());

            roverBuilder.Received().Init("2 2 S", Arg.Any <Plateau>());
        }
        public void ShouldThrowExceptionWhenParseInvalidInput()
        {
            var parser = new RoverCommandParser();

            var result = Record.Exception(() => parser.Parse("ABCD"));

            result.ShouldBeType<ParserException>();
        }
        public void GetCommands_LRM_LeftRightMoveCombinedList()
        {
            var parser      = new RoverCommandParser("LRM");
            var commandList = parser.GetCommands();

            Assert.Equal(3, commandList.Count);
            Assert.True(commandList[0] is RoverTurnLeftCommand);
            Assert.True(commandList[1] is RoverTurnRightCommand);
            Assert.True(commandList[2] is RoverMoveForwardCommand);
        }
        public void GetCommands_L_LeftCommand()
        {
            var parser = new RoverCommandParser()
            {
                Commands = "L"
            };
            var commandList = parser.GetCommands();

            Assert.Single(commandList);
            Assert.True(commandList[0] is RoverTurnLeftCommand);
        }
        public void GetCommands_M_MoveCommand()
        {
            var parser = new RoverCommandParser()
            {
                Commands = "M"
            };
            var commandList = parser.GetCommands();

            Assert.Single(commandList);
            Assert.True(commandList[0] is RoverMoveForwardCommand);
        }
        public void ShouldParseValidInput()
        {
            var parser = new RoverCommandParser();
            var expected = new List<IRoverCommand>() { new TurnLeftCommand(), new TurnRightCommand(), new MoveFowardCommand(), new TurnRightCommand(), new TurnLeftCommand() };

            var result = parser.Parse("LRMRL").ToList();

            result[0].ShouldBeType(expected[0].GetType());
            result[1].ShouldBeType(expected[1].GetType());
            result[2].ShouldBeType(expected[2].GetType());
            result[3].ShouldBeType(expected[3].GetType());
            result[4].ShouldBeType(expected[4].GetType());
        }