コード例 #1
0
        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);
        }
コード例 #2
0
        public static IRequestProcessor BuildNestedRequestProcessor(IDependencyLibrary dependencyLibrary)
        {
            IRequestProcessor p = new BaseRequestProcessor();

            p = new ErrorLoggingRequestProcessor(p, dependencyLibrary.Get <IConnectionFactory>());
            return(p);
        }
コード例 #3
0
 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);
 }