示例#1
0
        public void GetReplyKeyboardForGroups_Success_Empty()
        {
            //Arrange
            var preferences = new List <UserPreference>();

            //Act
            var resultKeyboard = MessageMarkupUtilities.GetReplyKeyboardForGroups(preferences);

            //Assert
            Assert.That(resultKeyboard, Is.Empty);
        }
示例#2
0
        public void GetReplyKeyboardForGroups_Success_NotEmpty()
        {
            //Arrange
            var preferences = new List <UserPreference>()
            {
                new() { TargetId = 111, TargetName = "First group" },
                new() { TargetId = 222, TargetName = "Вторая группа" },
            };

            //Act
            var resultKeyboard = MessageMarkupUtilities.GetReplyKeyboardForGroups(preferences);

            //Assert
            Assert.That(resultKeyboard, Is.Not.Empty);
            Assert.That(resultKeyboard.Count, Is.EqualTo(2));
            Assert.That(resultKeyboard[0][0].Text, Is.EqualTo("First group (id: 111)"));
            Assert.That(resultKeyboard[1][0].Text, Is.EqualTo("Вторая группа (id: 222)"));
        }
示例#3
0
        public override OutputUserMessage GetResponseTo(Message inputMessage, User user)
        {
            var currentSubscriptions = _db.Preferences.Where(pref => pref.User.Id == user.Id);
            var keyboard             = MessageMarkupUtilities.GetReplyKeyboardForGroups(currentSubscriptions);

            keyboard.Add(new List <KeyboardButton> {
                new KeyboardButton(TgBotText.Cancel)
            });
            user.State = ChatState.EditExistingGroup;
            _db.SaveChanges();

            var replyMarkup = new ReplyKeyboardMarkup(keyboard, resizeKeyboard: true, oneTimeKeyboard: true);

            return(new OutputUserMessage()
            {
                ChatId = inputMessage.Chat.Id,
                Text = TgBotText.EditCurrentSubscriptionsLink,
                ReplyMarkup = replyMarkup
            });
        }