Ejemplo n.º 1
0
        public async Task CreateActivityFromUpdate_Message()
        {
            // Arrange
            var update = new Update()
            {
                Message = new Message()
                {
                    Text = "toto", Chat = new Chat()
                    {
                        Id = 15
                    }
                }
            };
            // Act
            var activity = await _target.CreateActivityFromUpdate(update);

            // Assert
            Check.That(activity.ActivityType).Equals(ActivityType.Message);
            Check.That(activity.Text).Equals(update.Message.Text);
            Check.That(activity.ChatId).Equals(update.Message.Chat.Id);
        }
Ejemplo n.º 2
0
        public virtual async Task <ITurnContext> GetContext(Update update)
        {
            long   chatId   = 0;
            string text     = null;
            var    activity = await _adapter.CreateActivityFromUpdate(update);

            chatId = activity.ChatId;
            lock (Padlock)
            {
                if (!_turnContexts.ContainsKey(chatId))
                {
                    var turnContext = _lifetimeScope.Resolve <ITurnContext>();
                    _turnContexts.Add(chatId, turnContext);
                }
                var tc = _turnContexts[chatId];
                tc.ChatId   = chatId;
                tc.Activity = activity;

                return(tc);
            }
        }