private async Task CommandExecutionShouldReturnCommandExecuted_WhenValidCommandIsExecuted(string commandText)
        {
            var matchedCommand = MatchCommand(commandText);
            var result         = _execution.ExecuteCommand(matchedCommand.Item1, matchedCommand.Item2);
            await result.Item1;

            Assert.Equal(EventExecutionStatus.Executed, result.Item2.Status);
        }
Exemple #2
0
 /// <summary>
 /// Processes a context generated from whatever service you are providing commands for.
 /// It will parse the message, check if it is a command, find the correct command and execute it.
 /// </summary>
 /// <param name="ctx">The context created by you from a message from the service you're providing commands for.</param>
 public async Task ProcessMessageAsync(TContext ctx)
 {
     if (ctx.Message.StartsWith(Prefix))
     {
         var parsedCommand = Parser.ParseContext(ctx, PrefixLength);
         var commandMatch  = _matcher.MatchCommand(RegisteredModules, parsedCommand);
         var result        = _execution.ExecuteCommand(commandMatch, parsedCommand);
         await result.Item1;
         OnCommandExecuted?.Invoke(this, result.Item2);
     }
 }