コード例 #1
0
 public InstructionsController(IInstructionService instructionService,
                               IProductService productService, IInstructionPageService instructionPageService)
 {
     this.instructionService     = instructionService;
     this.productService         = productService;
     this.instructionPageService = instructionPageService;
 }
コード例 #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();
        }
コード例 #3
0
        public void GetInstructions_IsNotNullAndValidInstruction_ShouldReturnInstructionList_CountShouldEqualWithInstructionLength(string instruction)
        {
            _instructionService = new InstructionService();

            BaseModels <List <Instruction> > baseInstructionModel = _instructionService.GetInstructions(instruction);

            baseInstructionModel.Data.Count.Should().Equals(instruction.Length);
        }
コード例 #4
0
 public InstructionPagesController(IInstructionPageService instructionPageService, IProductService productService,
                                   IInstructionService instructionService, IPartService partService)
 {
     this.instructionPageService = instructionPageService;
     this.productService         = productService;
     this.instructionService     = instructionService;
     this.partService            = partService;
     fileManager = new FileManager();
 }
コード例 #5
0
        public HexFloorTileDay24(int size, IInstructionService instructionService, INeighboourStrategy strategy)
        {
            _tiles = new TileDay24[size * 2 + 1, (size * 2 + 1) * 2];

            for (int i = 0; i < _tiles.GetLength(0); i++)
            {
                for (int j = 0; j < _tiles.GetLength(1); j++)
                {
                    _tiles[i, j] = new TileDay24();
                }
            }

            _instructionService = instructionService;
            _strategy           = strategy;

            _heightCenter = size + 1;
            _widthCenter  = size * 2 + 1;
        }
コード例 #6
0
 public InstructionsController(IInstructionService serv)
 {
     instructionService = serv;
 }
コード例 #7
0
 public InstructionsController()
 {
     InstructionService = new InstructionService();
 }
コード例 #8
0
        public void GetInstructions_IsNull_ThrowsValidatePlateauException(string instruction)
        {
            _instructionService = new InstructionService();

            Assert.Throws <ArgumentNullException>(() => _instructionService.GetInstructions(instruction));
        }
コード例 #9
0
 public InstructionsController(IInstructionService service)
 {
     _service = service;
 }