Example #1
0
        public static void MessageInfoChatsTypeParserTest()
        {
            const int id = 1049413668;
            dynamic   mandatoryMessageInfoFields = MCommonMandatoryFieldsMessageInfo;

            //private
            mandatoryMessageInfoFields.chat = ChatInfoObject.GetObject(id, "private");
            MessageInfo messageInfo = new MessageInfo(mandatoryMessageInfoFields);

            Assert.AreEqual(ChatType.@private, messageInfo.Chat.Type);

            //channel
            mandatoryMessageInfoFields.chat = ChatInfoObject.GetObject(id, "channel");
            messageInfo = new MessageInfo(mandatoryMessageInfoFields);

            Assert.AreEqual(ChatType.channel, messageInfo.Chat.Type);

            //group
            mandatoryMessageInfoFields.chat = ChatInfoObject.GetObject(id, "group");
            messageInfo = new MessageInfo(mandatoryMessageInfoFields);

            Assert.AreEqual(ChatType.@group, messageInfo.Chat.Type);

            //supergroup
            mandatoryMessageInfoFields.chat = ChatInfoObject.GetObject(id, "supergroup");
            messageInfo = new MessageInfo(mandatoryMessageInfoFields);

            Assert.AreEqual(ChatType.supergroup, messageInfo.Chat.Type);

            //null
            mandatoryMessageInfoFields.chat = ChatInfoObject.GetObject(id, "grou");
            MessageInfo messageInfo2 = new MessageInfo(mandatoryMessageInfoFields);

            Assert.AreEqual(null, messageInfo2.Chat.Type);
        }
Example #2
0
        public static void MessageInfoParseChatIdTest()
        {
            const int idIntMin = int.MinValue;
            const int idIntMax = int.MaxValue;

            const long idLongMin = long.MinValue;
            const long idLongMax = long.MaxValue;

            const string type = "channel";

            dynamic mandatoryMessageInfoFields = MCommonMandatoryFieldsMessageInfo;

            //min_int
            mandatoryMessageInfoFields.chat = ChatInfoObject.GetObject(idIntMin, type);
            MessageInfo messageInfo = new MessageInfo(mandatoryMessageInfoFields);

            Assert.IsInstanceOf <long>(messageInfo.Chat.Id);

            //max_int
            mandatoryMessageInfoFields.chat = ChatInfoObject.GetObject(idIntMax, type);
            messageInfo = new MessageInfo(mandatoryMessageInfoFields);
            Assert.IsInstanceOf <long>(messageInfo.Chat.Id);

            //min_long
            mandatoryMessageInfoFields.chat = ChatInfoObject.GetObject(idLongMin, type);
            messageInfo = new MessageInfo(mandatoryMessageInfoFields);
            Assert.IsInstanceOf <long>(messageInfo.Chat.Id);

            //max_long
            mandatoryMessageInfoFields.chat = ChatInfoObject.GetObject(idLongMax, type);
            messageInfo = new MessageInfo(mandatoryMessageInfoFields);
            Assert.IsInstanceOf <long>(messageInfo.Chat.Id);
        }
Example #3
0
        public static void MessageInfoChatsTypeParserTest()
        {
            const int id = 1049413668;
            dynamic   mandatoryMessageInfoFields = new JObject();

            mandatoryMessageInfoFields.message_id = -1147483648;
            mandatoryMessageInfoFields.date       = 0;

            //private
            mandatoryMessageInfoFields.chat = ChatInfoObject.GetObject(id, "private");
            MessageInfo messageInfo = new MessageInfo(mandatoryMessageInfoFields);

            Assert.AreEqual(messageInfo.Chat.Id, id);
            Assert.AreEqual(messageInfo.Chat.Type, ChatType.@private);

            //channel
            mandatoryMessageInfoFields.chat = ChatInfoObject.GetObject(id, "channel");
            messageInfo = new MessageInfo(mandatoryMessageInfoFields);

            Assert.AreEqual(messageInfo.Chat.Id, id);
            Assert.AreEqual(messageInfo.Chat.Type, ChatType.channel);

            //group
            mandatoryMessageInfoFields.chat = ChatInfoObject.GetObject(id, "group");
            messageInfo = new MessageInfo(mandatoryMessageInfoFields);

            Assert.AreEqual(messageInfo.Chat.Id, id);
            Assert.AreEqual(messageInfo.Chat.Type, ChatType.@group);

            //supergroup
            mandatoryMessageInfoFields.chat = ChatInfoObject.GetObject(id, "supergroup");
            messageInfo = new MessageInfo(mandatoryMessageInfoFields);

            Assert.AreEqual(messageInfo.Chat.Id, id);
            Assert.AreEqual(messageInfo.Chat.Type, ChatType.supergroup);

            //null
            mandatoryMessageInfoFields.chat = ChatInfoObject.GetObject(id, "grou");
            MessageInfo messageInfo2 = new MessageInfo(mandatoryMessageInfoFields);

            Assert.AreEqual(messageInfo2.Chat.Id, id);
            Assert.AreEqual(messageInfo2.Chat.Type, null);
        }
Example #4
0
        public static void MessageInfoForwardFromChatTest()
        {
            const int    id        = 1049413668;
            const string type      = "channel";
            const string title     = "TestTitle";
            const string username  = "******";
            const string firstName = "TestFirstName";
            const string lastName  = "TestLastName";
            const bool   allMembersAreAdministrators = false;
            JObject      photo       = ChatPhotoInfoObject.GetObject("123456", "654321");
            const string description = "TestDescription";
            const string inviteLink  = "TestLink";

            dynamic mandatoryMessageInfoFields = new JObject();

            mandatoryMessageInfoFields.message_id = -1147483648;
            mandatoryMessageInfoFields.date       = 0;

            mandatoryMessageInfoFields.chat = ChatInfoObject.GetMinimalMandatoryObject(id, ChatType.channel);

            mandatoryMessageInfoFields.forward_from_chat = ChatInfoObject.GetObject(id, type,
                                                                                    title, username, firstName, lastName, allMembersAreAdministrators,
                                                                                    photo, description, inviteLink);

            MessageInfo messageInfo = new MessageInfo(mandatoryMessageInfoFields);

            Assert.AreEqual(messageInfo.ForwardFromChat.Id, id);
            Assert.AreEqual(messageInfo.ForwardFromChat.Type, ChatType.channel);
            Assert.AreEqual(messageInfo.ForwardFromChat.Title, title);
            Assert.AreEqual(messageInfo.ForwardFromChat.Username, username);
            Assert.AreEqual(messageInfo.ForwardFromChat.FirstName, firstName);
            Assert.AreEqual(messageInfo.ForwardFromChat.LastName, lastName);
            Assert.AreEqual(messageInfo.ForwardFromChat.AllMembersAreAdministrators, allMembersAreAdministrators);
            Assert.AreEqual(messageInfo.ForwardFromChat.Photo.SmallFileId, "123456");
            Assert.AreEqual(messageInfo.ForwardFromChat.Photo.BigFileId, "654321");
            Assert.AreEqual(messageInfo.ForwardFromChat.Description, description);
            Assert.AreEqual(messageInfo.ForwardFromChat.InviteLink, inviteLink);

            Console.WriteLine(mandatoryMessageInfoFields);
        }
Example #5
0
        public static void MessageInfoParseChatIdTest()
        {
            const int id_int_min = int.MinValue;
            const int id_int_max = int.MaxValue;

            const long id_long_min = long.MinValue;
            const long id_long_max = long.MaxValue;

            const string type = "channel";

            dynamic mandatoryMessageInfoFields = new JObject();

            mandatoryMessageInfoFields.message_id = -1147483648;
            mandatoryMessageInfoFields.date       = 0;

            //min_int
            mandatoryMessageInfoFields.chat = ChatInfoObject.GetObject(id_int_min, type);
            MessageInfo messageInfo = new MessageInfo(mandatoryMessageInfoFields);

            Assert.IsInstanceOf <long>(messageInfo.Chat.Id);

            //max_int
            mandatoryMessageInfoFields.chat = ChatInfoObject.GetObject(id_int_max, type);
            messageInfo = new MessageInfo(mandatoryMessageInfoFields);
            Assert.IsInstanceOf <long>(messageInfo.Chat.Id);

            //min_long
            mandatoryMessageInfoFields.chat = ChatInfoObject.GetObject(id_long_min, type);
            messageInfo = new MessageInfo(mandatoryMessageInfoFields);
            Assert.IsInstanceOf <long>(messageInfo.Chat.Id);

            //max_long
            mandatoryMessageInfoFields.chat = ChatInfoObject.GetObject(id_long_max, type);
            messageInfo = new MessageInfo(mandatoryMessageInfoFields);
            Assert.IsInstanceOf <long>(messageInfo.Chat.Id);
        }