Пример #1
0
        public async Task Process_CommandMessage_SourceHasNotMetric(LangCode langCode, string content, StateType sourceState,
                                                                    MessageCode returnCode)
        {
            int    externalId = 1;
            string name       = "Koko";
            var    source     = new Source(externalId, name);

            source.UpdateState(sourceState);
            SourceRepoMock.Setup(r => r.FindOrCreateNew(externalId, name)).Returns(() => source);

            var message = new CommandUpdateMessage
            {
                ChatId       = externalId,
                Username     = name,
                Content      = content,
                LanguageCode = langCode,
            };

            await message.Accept(MessageProcessor);

            var localizer = new Localizer();
            var text      = localizer.GetMessage(langCode, returnCode);

            BotResponseMock.Verify(x => x.Response(text), Times.Once);
        }
Пример #2
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));
        }