public void GetCommand_Success(string data, ButtonCode expectedCode, int expectedMenuMessageId, string expectedParameter = null)
        {
            var buttonCommand = _commandFactory.GetCommand(data);

            Assert.NotNull(buttonCommand);
            Assert.Equal(buttonCommand.Button, expectedCode);
            Assert.Equal(buttonCommand.MenuMessageId, expectedMenuMessageId);
            Assert.Equal(buttonCommand.Parameter, expectedParameter);
        }
Example #2
0
        public async Task GetCommand_Success(string commandName, LangCode langCode, string expectedName)
        {
            var message = new TextUpdateMessage
            {
                ChatId       = 1,
                LanguageCode = langCode,
            };

            var command = _commandFactory.GetCommand(commandName);
            await command.HandleAsync(message);

            Assert.Equal(command.Name, expectedName);
        }
Example #3
0
        public async Task Visit(CommandUpdateMessage message)
        {
            var source = GetSource(message);

            source.UpdateLastActionDate();
            _sourceRepository.Update(source);

            if (source.State == StateType.HasMetric)
            {
                var command = _commands.GetCommand(message.Content);
                await command.HandleAsync(message);

                return;
            }

            await _botClient.SendTextMessageAsync(message, GetMessageCode(source.State));
        }
Example #4
0
 public async Task Visit(CallbackQueryUpdateMessage message)
 {
     // This is the result of selecting a menu button
     var buttonCommand = _buttonCommands.GetCommand(message.Content);
     await buttonCommand.HandleAsync(message);
 }