Example #1
0
#pragma warning restore xUnit1010 // The value is not convertible to the method parameter type
        public void RotateLeftCommand_ValidPlateauValidRoverAndValidInstructions_ShouldBeEqualGivenResult(int width, int height, int xPosition, int yPosition, Directions direction, Directions result)
        {
            _plateauService = new PlateauService();
            _roverService   = new RoverService(_explorationFactoryMock);

            BaseModels <PlateauModel> basePlateauModel = _plateauService.Create(width, height);

            basePlateauModel.Data.Width.Should().Equals(width);
            basePlateauModel.Data.Height.Should().Equals(height);

            RoverLocationModel roverLocation = new RoverLocationModel()
            {
                Direction = direction,
                XPosition = xPosition,
                YPosition = yPosition
            };

            BaseModels <RoverModel> baseRoverModel = _roverService.Initalize(basePlateauModel.Data, roverLocation);

            _explorationCommandMock = new RotateLeftCommand();

            _explorationCommandMock.Explore(_roverService.GetCurrentRover().Data.Location);

            _roverService.GetCurrentRover().Data.Location.Direction.Should().Be(result);
            Console.WriteLine(result);
            Console.ReadLine();
        }
Example #2
0
        static void Main(string[] args)
        {
            ServiceProvider serviceProvider = new ServiceCollection()
                                              .AddSingleton <IExplorationFactory, ExplorationFactory>()
                                              .AddSingleton <IExplorationCommand, RotateRightCommand>()
                                              .AddSingleton <IExplorationCommand, RotateLeftCommand>()
                                              .AddSingleton <IExplorationCommand, MoveForwardCommand>()
                                              .AddSingleton <IPlateauService, PlateauService>()
                                              .AddSingleton <IRoverService, RoverService>()
                                              .AddSingleton <IInstructionService, InstructionService>()
                                              .BuildServiceProvider();


            IPlateauService     plateauService     = serviceProvider.GetService <IPlateauService>();
            IRoverService       roverService       = serviceProvider.GetService <IRoverService>();
            IInstructionService instructionService = serviceProvider.GetService <IInstructionService>();

            List <RoverModel> rovers = new List <RoverModel>();

            BaseModels <PlateauModel> basePlateauModel = plateauService.Create(5, 5);

            Console.WriteLine("5 5");
            RoverLocationModel firstRoverLocation = new RoverLocationModel()
            {
                XPosition = 1,
                YPosition = 2,
                Direction = Directions.North
            };

            Console.WriteLine("1 2 N");
            BaseModels <RoverModel> baseRoverModel = roverService.Initalize(basePlateauModel.Data, firstRoverLocation);

            rovers.Add(baseRoverModel.Data);
            Console.WriteLine("LMLMLMLMM");
            BaseModels <List <Instruction> > baseInstructionModel = instructionService.GetInstructions("LMLMLMLMM");

            foreach (Instruction instruction in baseInstructionModel.Data)
            {
                roverService.ExplorePlateau(instruction);
            }
            Console.WriteLine("3 3 E");
            RoverLocationModel secondRoverLocation = new RoverLocationModel()
            {
                XPosition = 3,
                YPosition = 3,
                Direction = Directions.East
            };

            baseRoverModel = roverService.Initalize(basePlateauModel.Data, secondRoverLocation);
            rovers.Add(baseRoverModel.Data);
            Console.WriteLine("MMRMMRMRRM");
            baseInstructionModel = instructionService.GetInstructions("MMRMMRMRRM");

            foreach (Instruction instruction in baseInstructionModel.Data)
            {
                roverService.ExplorePlateau(instruction);
            }
            Console.ReadLine();
        }
 public void Execute()
 {
     _plateauService.Create(_width, _height);
 }