public async void ShouldLetAdminsPostLinks() { var commandQueue = new MockCommandQueue(); var dataSource = new MockDataSource(); var repo = dataSource.Repository<User>() as MockRepository<User>; repo.ObjectCache.Add("ballouthebear", new User() { Channels = new Dictionary<string, UserChannel>() { { "#ballouthebear", new UserChannel() { IsModerator = true } } } }); var linkSpamHandler = new LinkSpamFilter(commandQueue, dataSource); var message = MessageParser.ParseIrcMessage("@color=#FF0000;display-name=BallouTheBear;emotes=;subscriber=0;turbo=0;user-id=30514348;user-type= :[email protected] PRIVMSG #ballouthebear :Check it out! www.google.com"); await linkSpamHandler.ReceiveMessage(message); var command = commandQueue.DequeueCommand(); Assert.Equal(command, ""); }
public async void PollHandlerCanCreateAndPostPoll() { PluginStore.InitializePluginStoreNew(builder => new AssemblyCatalog(GetType().Assembly, builder)); var commandQ = new MockCommandQueue(); var dataSource = new MockDataSource(); var repo = dataSource.Repository<User>() as MockRepository<User>; repo.ObjectCache.Add("ballouthebear", new User() { Channels = new Dictionary<string, UserChannel>() { { "#ballouthebear", new UserChannel() { IsModerator = true } } } }); var rawMessage = "@color=#FF0000;display-name=BallouTheBear;emotes=;subscriber=0;turbo=0;user-id=30514348;user-type= :[email protected] PRIVMSG #ballouthebear :!poll \"Do you like big butts?\";\"Yes\";\"No\""; var message = MessageParser.ParseIrcMessage(rawMessage); var pollHandler = new PollHandler(commandQ, dataSource, new MockLogger()); await pollHandler.ReceiveMessage(message); var result = commandQ.DequeueCommand(); Assert.NotNull(result); Assert.NotEqual("", result); Assert.Contains("Do you like big butts?", result); }
public async void PollHandlerRejectsOnlyOneOption() { var commandQ = new MockCommandQueue(); var dataSource = new MockDataSource(); var repo = dataSource.Repository<User>() as MockRepository<User>; repo.ObjectCache.Add("ballouthebear", new User() { Channels = new Dictionary<string, UserChannel>() { { "#ballouthebear", new UserChannel() { IsModerator = true } } } }); var rawMessage = "@color=#FF0000;display-name=BallouTheBear;emotes=;subscriber=0;turbo=0;user-id=30514348;user-type= :[email protected] PRIVMSG #ballouthebear :!poll \"Do you like big butts?\";\"Yes\""; var message = MessageParser.ParseIrcMessage(rawMessage); var pollHandler = new PollHandler(commandQ, dataSource, new MockLogger()); await pollHandler.ReceiveMessage(message); var result = commandQ.DequeueCommand(); Assert.NotNull(result); Assert.NotEqual("", result); Assert.Contains("You must have at least two options!", result); }
public async void ShouldTimeoutLinkSpamMessages() { var commandQueue = new MockCommandQueue(); var dataSource = new MockDataSource(); var linkSpamHandler = new LinkSpamFilter(commandQueue, dataSource); var message = MessageParser.ParseIrcMessage("@color=#FF0000;display-name=BallouTheBear;emotes=;subscriber=0;turbo=0;user-id=30514348;user-type= :[email protected] PRIVMSG #ballouthebear :Check it out! www.google.com"); await linkSpamHandler.ReceiveMessage(message); var command = commandQueue.DequeueCommand(); Assert.NotEqual(command, ""); }
public async void CanGetUptime() { var commandQueue = new MockCommandQueue(); var twitchApi = new MockTwitchApi(); var uptimeHandler = new UptimeHandler(commandQueue, twitchApi); var message = new Message() { Command = Constants.PrivateMessageCommand, Suffix = "!uptime", Parameters = new List<string> { "#testChannel"} }; await uptimeHandler.ReceiveMessage(message); var uptime = commandQueue.DequeueCommand(); Assert.NotNull(uptime); Assert.NotEqual(uptime, ""); }
public async void AdminCanGratPermissionToUserForLinks() { var commandQueue = new MockCommandQueue(); var dataSource = new MockDataSource(); var repo = dataSource.Repository<User>() as MockRepository<User>; repo.ObjectCache.Add("ballouthebear", new User() { Channels = new Dictionary<string, UserChannel>() { { "#ballouthebear", new UserChannel() { IsModerator = true } } }, Data = new Dictionary<string, object>() }); repo.ObjectCache.Add("taylormade86", new User() { Channels = new Dictionary<string, UserChannel>() { { "#ballouthebear", new UserChannel() { IsModerator = false } } }, Data = new Dictionary<string, object>() }); var linkSpamHandler = new LinkSpamFilter(commandQueue, dataSource); var adminMessage = MessageParser.ParseIrcMessage("@color=#FF0000;display-name=BallouTheBear;emotes=;subscriber=0;turbo=0;user-id=30514348;user-type= :[email protected] PRIVMSG #ballouthebear :!permit taylormade86"); await linkSpamHandler.ReceiveMessage(adminMessage); var command = commandQueue.DequeueCommand(); Assert.Equal(command, "PRIVMSG #ballouthebear :User taylormade86 has been permitted to post a link."); var userMessage = MessageParser.ParseIrcMessage("@color=#FF0000;display-name=Taylormade86;emotes=;subscriber=0;turbo=0;user-id=30514348;user-type= :[email protected] PRIVMSG #ballouthebear :Check it out! www.google.com"); await linkSpamHandler.ReceiveMessage(userMessage); command = commandQueue.DequeueCommand(); Assert.Equal(command, ""); }