예제 #1
0
        public void Should_Parse_Valid_Commands(string text, string commandValue)
        {
            Mock <IBot> mockBot = new Mock <IBot>();

            mockBot.SetupGet(x => x.Username).Returns("Test_Bot");

            IBot    bot     = mockBot.Object;
            Message message = new Message
            {
                Text     = text,
                Entities = new[]
                {
                    new MessageEntity
                    {
                        Type   = MessageEntityType.BotCommand,
                        Offset = text.IndexOf(commandValue, StringComparison.OrdinalIgnoreCase),
                        Length = commandValue.Length
                    },
                },
            };

            bool result = bot.CanHandleCommand("test", message);

            Assert.True(result);
        }
예제 #2
0
        public void Should_Refuse_Handling_Non_Message_Updates()
        {
            Mock <IBot> mockBot = new Mock <IBot>();

            mockBot.SetupGet(x => x.Username).Returns("Test_Bot");

            IBot    bot     = mockBot.Object;
            Message message = new Message
            {
                Text = null,
            };

            bool result = bot.CanHandleCommand("test", message);

            Assert.False(result);
        }
예제 #3
0
        public void Should_Not_Parse_Invalid_Command_Text(string text)
        {
            Mock <IBot> mockBot = new Mock <IBot>();

            mockBot.SetupGet(x => x.Username).Returns("Test_Bot");

            IBot    bot     = mockBot.Object;
            Message message = new Message
            {
                Text = text,
            };

            bool result = bot.CanHandleCommand("test", message);

            Assert.False(result);
        }