public void CanHandleInChannel() { var command = new ParametrizedCommand(InChat.Channel, "test"); var paramses = new HandlerParams(null, new Update { Message = new Message { Text = "/test@testbot", Chat = new Chat { Type = ChatType.Channel } } }, null, "testbot"); Assert.True(command.CanHandleInternal(paramses)); paramses = new HandlerParams(null, new Update { Message = new Message { Text = "/test@testbot", Chat = new Chat { Type = ChatType.Group } } }, null, "testbot"); Assert.False(command.CanHandleInternal(paramses)); paramses = new HandlerParams(null, new Update { Message = new Message { Text = "/test@testbot", Chat = new Chat { Type = ChatType.Supergroup } } }, null, "testbot"); Assert.False(command.CanHandleInternal(paramses)); paramses = new HandlerParams(null, new Update { Message = new Message { Text = "/test@testbot", Chat = new Chat { Type = ChatType.Private } } }, null, "testbot"); Assert.False(command.CanHandleInternal(paramses)); }
public void CanHandleByTextWithUsername() { var command = new ParametrizedCommand("test"); var paramses = new HandlerParams(null, new Update { Message = new Message { Text = "/test@testbot" } }, null, "testbot"); Assert.True(command.CanHandleInternal(paramses)); }
public void CanFilterUserName() { var commandInChat = new ParametrizedCommand(InChat.All, "test", CommandParseMode.Both); var command = new ParametrizedCommand("test", CommandParseMode.Both); var paramses = new HandlerParams(null, new Update { Message = new Message { Text = "/test@testbot" } }, null, "testbot"); Assert.True(commandInChat.CanHandleInternal(paramses)); Assert.True(command.CanHandleInternal(paramses)); commandInChat = new ParametrizedCommand(InChat.All, "test", CommandParseMode.WithUsername); command = new ParametrizedCommand("test", CommandParseMode.WithUsername); Assert.True(commandInChat.CanHandleInternal(paramses)); Assert.True(command.CanHandleInternal(paramses)); commandInChat = new ParametrizedCommand(InChat.All, "test", CommandParseMode.WithoutUsername); command = new ParametrizedCommand("test", CommandParseMode.WithoutUsername); Assert.False(commandInChat.CanHandleInternal(paramses)); Assert.False(command.CanHandleInternal(paramses)); paramses = new HandlerParams(null, new Update { Message = new Message { Text = "/test" } }, null, "testbot"); Assert.True(commandInChat.CanHandleInternal(paramses)); Assert.True(command.CanHandleInternal(paramses)); }