public TransactionResult Explore(IRoverDto rover, string commandText) { var result = new TransactionResult <IRoverDto>(); try { _roverBusiness.Explore(rover, commandText); result.SetStatusSucceeded("Transaction succeed."); } catch (ValidationException ve) { result.SetStatusValidationException(ve.Message); } catch (Exception ex) { result.SetStatusUnhandledException(ex); } return(result); }
public void Explore(IRoverDto rover, string commandText) { if (rover is null) { throw new ValidationException("rover is null. Please try again."); } if (commandText is null) { throw new ValidationException("Command is null. Please try again."); } var commandMatch = Regex.Match(commandText, RegexPatterns.Command, RegexOptions.Singleline); if (!commandMatch.Success || !commandMatch.Groups[1].Value.Equals(commandText)) { throw new ValidationException($"{commandText} is not matched."); } var commands = commandText.Select(s => EnumExtensions.GetMemberByValue <Command>(s.ToString().ToUpper())); rover.Explore(commands); }