Example #1
0
        public async Task BCRPFindCmdOK()
        {
            var cmd       = new Cmd();
            var cmd2      = new Cmd2();
            var processor = new CommandRequestProcessorTest(new List <ICommand> {
                cmd, cmd2
            });
            var request = new BaseCommandBotRequest <JToken>(null, cmd.UniqueName,
                                                             JToken.FromObject(new DiscussCommandBotRequest()), null, null, BotCommandContext.DiscussPostForm);
            await processor.ProcessAsync(request);

            Assert.IsTrue(cmd.DiscussCmdExecuted);
            Assert.IsFalse(cmd.EventCmdExecuted);
            Assert.IsFalse(cmd.MesCmdExecuted);
            cmd.DiscussCmdExecuted = false;

            request.ctx = BotCommandContext.EventPostForm;
            await processor.ProcessAsync(request);

            Assert.IsFalse(cmd.DiscussCmdExecuted);
            Assert.IsTrue(cmd.EventCmdExecuted);
            Assert.IsFalse(cmd.MesCmdExecuted);
            cmd.EventCmdExecuted = false;

            request.ctx = BotCommandContext.MessagingPostForm;
            await processor.ProcessAsync(request);

            Assert.IsFalse(cmd.DiscussCmdExecuted);
            Assert.IsFalse(cmd.EventCmdExecuted);
            Assert.IsTrue(cmd.MesCmdExecuted);
        }
Example #2
0
        public async Task BCRPNotFoundCtxCmdFail()
        {
            var cmd       = new Cmd();
            var cmd2      = new Cmd2();
            var processor = new CommandRequestProcessorTest(new List <ICommand> {
                cmd, cmd2
            });
            var response = await processor.ProcessAsync(new BaseCommandBotRequest <JToken>(null, cmd.UniqueName,
                                                                                           JToken.FromObject(new DiscussCommandBotRequest()), null, null, (BotCommandContext)5));

            CheckFailResponse(response);
        }
Example #3
0
        public async Task BCRPNotFoundCmdFail()
        {
            var cmd       = new Cmd();
            var processor = new CommandRequestProcessorTest(new List <ICommand>());
            var response  = await processor.ProcessAsync(new BaseCommandBotRequest <JToken>(null, null, JToken.FromObject("aaa"), null, null, BotCommandContext.DiscussPostForm));

            CheckFailResponse(response);

            processor = new CommandRequestProcessorTest(new List <ICommand> {
                cmd
            });
            response = await processor.ProcessAsync(new BaseCommandBotRequest <JToken>(null, "notExistedCommand",
                                                                                       JToken.FromObject(new DiscussCommandBotRequest()), null, null, BotCommandContext.DiscussPostForm));

            CheckFailResponse(response);
        }