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); }
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); }
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); }