Пример #1
0
        public static void CallbackQueryTest()
        {
            //field class UpdateInfo
            const int    updateId   = 123;
            const string idСallback = "123";

            //field class CallbackQueryInfo
            const string inlineMessageId = "123";
            const string chatInstance    = "123";
            const string data            = "TestData";
            const string gameShortName   = "TestGameShortName";


            dynamic callbackQueryInfo = CallbackQueryInfoObject.GetObject(idСallback, MCommonUserInfo, MCommonMessageInfo, inlineMessageId,
                                                                          chatInstance, data, gameShortName);

            dynamic updateInfoObject = UpdateInfoObject.GetObject(updateId, callbackQuery: callbackQueryInfo);

            UpdateInfo updateInfo = new UpdateInfo(updateInfoObject);

            Assert.AreEqual(updateInfo.UpdateId, updateId);

            //UserInfo field
            AssertUserInfo(updateInfo.CallbackQuery.From);

            //MessageInfo field
            AssertMessageInfo(updateInfo.CallbackQuery.Message);

            //CallbackQueryInfo field
            Assert.AreEqual(idСallback, updateInfo.CallbackQuery.Id);
            Assert.AreEqual(inlineMessageId, updateInfo.CallbackQuery.InlineMessageId);
            Assert.AreEqual(chatInstance, updateInfo.CallbackQuery.ChatInstance);
            Assert.AreEqual(data, updateInfo.CallbackQuery.Data);
            Assert.AreEqual(gameShortName, updateInfo.CallbackQuery.GameShortName);
        }
        public static void CallbackQueryTest()
        {
            //field class UserInfo
            const int id = 123;
            const bool isBot = true;
            const string idСallback = "123";
            const string firstName = "TestFirstName";
            const string lastName = "TestLastName";
            const string username = "******";
            const string languageCode = "TestLanguageCode";

            //field class MessageInfo
            const int messageId = 123;
            const int date = 0;
            const int chatId = 123;
            const ChatType chatType = ChatType.channel;

            //field class CallbackQueryInfo
            const string inlineMessageId = "123";
            const string chatInstance = "123";
            const string data = "TestData";
            const string gameShortName = "TestGameShortName";
            
            JObject userInfo = UserInfoObject.GetObject(id, isBot, firstName, lastName, username, languageCode);
            JObject messageInfo = MessageInfoObject.GetMandatoryFieldsMessageInfo(messageId, date, chatId, chatType);

            dynamic callbackQueryInfo = CallbackQueryInfoObject.GetObject(idСallback, userInfo, messageInfo, inlineMessageId,
                chatInstance, data, gameShortName);

            CallbackQueryInfo callbackQuery = new CallbackQueryInfo(callbackQueryInfo);

            Assert.Multiple(() =>
            {
                //UserInfo field
                Assert.AreEqual(id, callbackQuery.From.Id);
                Assert.AreEqual(isBot, callbackQuery.From.IsBot);
                Assert.AreEqual(firstName, callbackQuery.From.FirstName);
                Assert.AreEqual(lastName, callbackQuery.From.LastName);
                Assert.AreEqual(username, callbackQuery.From.UserName);
                Assert.AreEqual(languageCode, callbackQuery.From.LanguageCode);

                //MessageInfo field
                Assert.AreEqual(messageId, callbackQuery.Message.MessageId);
                Assert.AreEqual(date, callbackQuery.Message.DateUnix);
                Assert.AreEqual(chatId, callbackQuery.Message.Chat.Id);
                Assert.AreEqual(chatType, callbackQuery.Message.Chat.Type);

                //CallbackQueryInfo field
                Assert.AreEqual(idСallback, callbackQuery.Id);
                Assert.AreEqual(inlineMessageId, callbackQuery.InlineMessageId);
                Assert.AreEqual(chatInstance, callbackQuery.ChatInstance);
                Assert.AreEqual(data, callbackQuery.Data);
                Assert.AreEqual(gameShortName, callbackQuery.GameShortName);
            });
        }