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);
            });
        }
Exemplo n.º 2
0
        public static void MessageInfoPinnedMessageTest()
        {
            const int messageId = 1000;
            const int date      = 0;
            const int chatId    = 125421;

            dynamic MessageInfoPinnedMessage = mMandatoryFieldsMessageInfo;

            MessageInfoPinnedMessage.pinned_message = MessageInfoObject.GetMandatoryFieldsMessageInfo(messageId, date, chatId, ChatType.@group);

            MessageInfo messageInfo = new MessageInfo(MessageInfoPinnedMessage);

            Assert.AreEqual(messageInfo.PinnedMessage.MessageId, messageId);
            Assert.AreEqual(messageInfo.PinnedMessage.DateUnix, date);
            Assert.AreEqual(messageInfo.PinnedMessage.Chat.Id, chatId);

            Console.WriteLine(MessageInfoPinnedMessage);
        }
Exemplo n.º 3
0
        public static void MessageInfoReplyToMessageTest()
        {
            const int messageId = 1000;
            const int date      = 0;
            const int chatId    = 125421;

            dynamic messageInfoReplyToMessage = MCommonMandatoryFieldsMessageInfo;

            messageInfoReplyToMessage.reply_to_message = MessageInfoObject.GetMandatoryFieldsMessageInfo(messageId, date, chatId, ChatType.channel);

            MessageInfo messageInfo = new MessageInfo(messageInfoReplyToMessage);

            Assert.Multiple(() =>
            {
                Assert.AreEqual(messageId, messageInfo.ReplyToMessage.MessageId);
                Assert.AreEqual(date, messageInfo.ReplyToMessage.DateUnix);
                Assert.AreEqual(chatId, messageInfo.ReplyToMessage.Chat.Id);
            });
        }
Exemplo n.º 4
0
        public static void GetUpdatesResultMessageInfoTest()
        {
            //message
            JObject messageInfo = MessageInfoObject.GetMandatoryFieldsMessageInfo(mMessageId, mDate, mChatId, mChatType);
            dynamic result      = UpdateInfoObject.GetObjectInArray(mUpdateId, messageInfo);

            dynamic          getUpdates   = GetUpdatesResultObject.GetObject(mOk, result);
            GetUpdatesResult updateResult = new GetUpdatesResult(getUpdates.ToString());

            AssertUpdateInfo(updateResult);
            AssertMessageInfo(updateResult.Result[0].Message);

            //editedMessage
            result = UpdateInfoObject.GetObjectInArray(mUpdateId, editedMessage: messageInfo);

            getUpdates   = GetUpdatesResultObject.GetObject(mOk, result);
            updateResult = new GetUpdatesResult(getUpdates.ToString());

            AssertUpdateInfo(updateResult);
            AssertMessageInfo(updateResult.Result[0].EditedMessage);

            //channelPost
            result = UpdateInfoObject.GetObjectInArray(mUpdateId, channelPost: messageInfo);

            getUpdates   = GetUpdatesResultObject.GetObject(mOk, result);
            updateResult = new GetUpdatesResult(getUpdates.ToString());

            AssertUpdateInfo(updateResult);
            AssertMessageInfo(updateResult.Result[0].ChannelPost);

            //editedChannelPost
            result = UpdateInfoObject.GetObjectInArray(mUpdateId, editedChannelPost: messageInfo);

            getUpdates   = GetUpdatesResultObject.GetObject(mOk, result);
            updateResult = new GetUpdatesResult(getUpdates.ToString());

            AssertUpdateInfo(updateResult);
            AssertMessageInfo(updateResult.Result[0].EditedChannelPost);
        }