Exemplo n.º 1
0
 static void CommandRover(Rover rover, ICommandConverter commandConverter)
 {
     commandConverter.Commands.ForEach(cc =>
     {
         var command = CommandManager.GetCommands().First(c => c.Code == cc);
         CommandManager.Apply(rover, command);
     });
 }
Exemplo n.º 2
0
        public void Should_MoveNorth_When_TargetTileIsExist()
        {
            int x = 5, y = 5;
            var planet    = new Planet().With(10, 20, "TestPlanet");
            var direction = directionManager.GetDirections().First(d => d.Code == "N");
            var location  = new Location().With(new Position(x, y), direction);
            var rover     = context.Resolve <Rover>();

            rover.Land(planet, location);

            var expectedLocationAfterMove = new Location().With(new Position(x, y + 1), direction);
            var command = commandManager.GetCommands().First(c => c.Code == "M");

            commandManager.Apply(rover, command);


            Assert.AreEqual(expectedLocationAfterMove.Position, rover.Location.Position);
            Assert.AreEqual(expectedLocationAfterMove.Direction, rover.Location.Direction);
        }