protected override Task <BaseUrlValidationBotResponse <UrlValidationBotResponse> > CustomProcessAsync( BaseUrlValidationBotRequest <UrlValidationBotRequest> request) { if (request?.request?.challenge == null) { throw new ArgumentException($"Bad request body.", nameof(request)); } var response = new BaseUrlValidationBotResponse <UrlValidationBotResponse>( new UrlValidationBotResponse(request.request.challenge), request.token); return(Task.FromResult(response)); }
public Task<BaseUrlValidationBotResponse<UrlValidationBotResponse>> ProcessAsync(BaseUrlValidationBotRequest<JToken> request) { if (request?.request == null) throw new ArgumentException($"Request body is empty. RequestBody: {request}.", nameof(request)); UrlValidationBotRequest validationRequest; try { validationRequest = JsonConvert.DeserializeObject<UrlValidationBotRequest>(request.request.ToString()); if(validationRequest?.challenge == null) throw new ArgumentException($"Request challenge is empty. RequestBody: {request}.", nameof(request)); } catch (Exception e) { throw new ArgumentException($"Request body is empty. RequestBody: {request}.", nameof(request)); } return CustomProcessAsync(new BaseUrlValidationBotRequest<UrlValidationBotRequest>(validationRequest, request.lng, request.token)); }
public async Task BaseRPChoosingProcessorBadRequestTypeFail() { var validationReqObj = new BaseUrlValidationBotRequest <UrlValidationBotRequest>(new UrlValidationBotRequest(), null, null); validationReqObj.requestType = (BotRequestType)99999999; try { await _proc.ProcessAsync(JsonConvert.SerializeObject(validationReqObj)); Assert.Fail("There is not base request type exception."); } catch (NotSupportedException e) { } Assert.IsFalse(_commandProcessorIsChoosen); Assert.IsFalse(_validationProcessorIsChoosen); }
public async Task BaseRPChoosingProcessorOk() { var commandRequest = JsonConvert.SerializeObject( new BaseCommandBotRequest <MessageCommandBotRequest>("123", "asdasd", new MessageCommandBotRequest("mes"), "ru", null, BotCommandContext.MessagingPostForm)); await _proc.ProcessAsync(commandRequest); Assert.IsTrue(_commandProcessorIsChoosen); Assert.IsFalse(_validationProcessorIsChoosen); _commandProcessorIsChoosen = false; var validationReqObj = new BaseUrlValidationBotRequest <UrlValidationBotRequest>(new UrlValidationBotRequest(), null, null); var validationRequest = JsonConvert.SerializeObject(validationReqObj); await _proc.ProcessAsync(validationRequest); Assert.IsFalse(_commandProcessorIsChoosen); Assert.IsTrue(_validationProcessorIsChoosen); _validationProcessorIsChoosen = false; }
public Task <BaseUrlValidationBotResponse <UrlValidationBotResponse> > CustomProcessAsync( BaseUrlValidationBotRequest <UrlValidationBotRequest> request) { return(base.CustomProcessAsync(request)); }
protected override Task <BaseUrlValidationBotResponse <UrlValidationBotResponse> > CustomProcessAsync( BaseUrlValidationBotRequest <UrlValidationBotRequest> request) { return(Task.FromResult(new BaseUrlValidationBotResponse <UrlValidationBotResponse>(new UrlValidationBotResponse(Challenge), request.token))); }
protected abstract Task<BaseUrlValidationBotResponse<UrlValidationBotResponse>> CustomProcessAsync( BaseUrlValidationBotRequest<UrlValidationBotRequest> request);