public BaseRPChoosingProcessorTest() { var localizationServiceMock = new Mock <ILocalizationService>(); localizationServiceMock.Setup(x => x.SetLocale(It.IsAny <string>())); var authServiceMock = new Mock <IBotAuthService>(); authServiceMock.Setup(x => x.IsAuthBotRequest(It.IsAny <string>())).Returns(true); _commandProcessorIsChoosen = false; var commandProcessorMock = new Mock <ICustomRequestProcessor <BaseCommandBotRequest <JToken>, BaseCommandBotResponse <ICommandResponseBody>, ICommandResponseBody> >(); commandProcessorMock.Setup(x => x.ProcessAsync(It.IsAny <BaseCommandBotRequest <JToken> >())) .Returns(() => Task.FromResult <BaseCommandBotResponse <ICommandResponseBody> >(null)) .Callback(() => _commandProcessorIsChoosen = true); commandProcessorMock.Setup(x => x.RequestType).Returns(BotRequestType.BotCommand); _validationProcessorIsChoosen = false; var validationProcessorMock = new Mock <ICustomRequestProcessor <BaseUrlValidationBotRequest <JToken>, BaseUrlValidationBotResponse <UrlValidationBotResponse>, UrlValidationBotResponse> >(); validationProcessorMock.Setup(x => x.ProcessAsync(It.IsAny <BaseUrlValidationBotRequest <JToken> >())) .Returns(() => Task.FromResult <BaseUrlValidationBotResponse <UrlValidationBotResponse> >(null)) .Callback(() => _validationProcessorIsChoosen = true); validationProcessorMock.Setup(x => x.RequestType).Returns(BotRequestType.Validation); _proc = new TestRequestProcessor(authServiceMock.Object, validationProcessorMock.Object, localizationServiceMock.Object).SetRequestProcessor(commandProcessorMock.Object); }
public static IRequestProcessor BuildNestedRequestProcessor(IDependencyLibrary dependencyLibrary) { IRequestProcessor p = new BaseRequestProcessor(); p = new ErrorLoggingRequestProcessor(p, dependencyLibrary.Get <IConnectionFactory>()); return(p); }
public BaseRPDeserializeTests() { _localizationServiceMock = new Mock <ILocalizationService>(); _localizationServiceMock.Setup(x => x.SetLocale(It.IsAny <string>())); _validationProcessorMock = new Mock <ICustomRequestProcessor <BaseUrlValidationBotRequest <JToken>, BaseUrlValidationBotResponse <UrlValidationBotResponse>, UrlValidationBotResponse> >(); _validationProcessorMock.Setup(x => x.ProcessAsync(It.IsAny <BaseUrlValidationBotRequest <JToken> >())).Returns(() => null); _authServiceMock = new Mock <IBotAuthService>(); _authServiceMock.Setup(s => s.IsAuthBotRequest(It.IsAny <string>())).Returns(true); _commandProcessorMock = new Mock <ICustomRequestProcessor <BaseCommandBotRequest <JToken>, BaseCommandBotResponse <ICommandResponseBody>, ICommandResponseBody> >(); _commandProcessorMock.Setup(x => x.ProcessAsync(It.IsAny <BaseCommandBotRequest <JToken> >())) .Returns(() => Task.FromResult(new BaseCommandBotResponse <ICommandResponseBody>( CommandBotResponseType.Post, new BotCommandStateResponse("mes", BotCommandStateType.Success), Token))); _commandProcessorMock.Setup(x => x.RequestType).Returns(BotRequestType.BotCommand); _proc = new TestRequestProcessor(_authServiceMock.Object, _validationProcessorMock.Object, _localizationServiceMock.Object).SetRequestProcessor(_commandProcessorMock.Object); }