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); }
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); }
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); }