コード例 #1
0
        public async Task <NavigationCommandModel> Navigate(NavigationCommandModel navigationCommand)
        {
            _navigationCommandModel = navigationCommand;
            var instructions = navigationCommand.Instructions.ToCharArray();
            await Task.Run(() =>
            {
                Array.ForEach(instructions, x =>
                {
                    if (x == 'L')
                    {
                        TurnLeft();
                    }
                    if (x == 'R')
                    {
                        TurnRight();
                    }
                    if (x == 'M')
                    {
                        Move();
                    }
                });
            });

            Console.WriteLine($"Output position...");
            Console.WriteLine($"{ _navigationCommandModel.X_Position } { _navigationCommandModel.Y_Position } { _navigationCommandModel.Z_Position }");

            return(_navigationCommandModel);
        }
コード例 #2
0
        public async Task ExpectedResult()
        {
            //Arrange
            var service = new NavigationService();
            var request = new NavigationCommandModel()
            {
                X_Position   = 1,
                Y_Position   = 2,
                Z_Position   = 'N',
                Instructions = "LMLMLMLMM"
            };


            //Act
            var result = await service.Navigate(request);

            //Assert
            Assert.Equal(1, result.X_Position);
            Assert.Equal(3, result.Y_Position);
            Assert.Equal('N', result.Z_Position);
        }
コード例 #3
0
 private NavigationCommandBuilder()
 {
     NavigationCommand = new NavigationCommandModel();
 }
コード例 #4
0
 public async Task ExecuteCommand(NavigationCommandModel navigationCommand)
 {
     await _navigationService.Navigate(navigationCommand);
 }