public async Task handleCommand_PickNextRand_CommandResponseReceivedEventTriggered() { DbContextOptions <ApplicationDbContext> options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "Test") .Options; IServiceScope scope = Substitute.For <IServiceScope>(); scope.ServiceProvider.GetService(typeof(ApplicationDbContext)).ReturnsForAnyArgs(new ApplicationDbContext(options)); IServiceScopeFactory scopefactory = Substitute.For <IServiceScopeFactory>(); scopefactory.CreateScope().ReturnsForAnyArgs(scope); IEventBus eventbus = new EventBusLocal(); CommandResponseArgs receivedEventsArgs = null; //eventbus.TriggerEvent(EventType.).For CommandService service = new CommandService(scopefactory, eventbus); eventbus.CommandOutputReceived += delegate(object sender, CommandResponseArgs e) { receivedEventsArgs = e; }; ChatCommandInputArgs args = new ChatCommandInputArgs() { Message = "!randnext", Sender = "chromos33", ChannelName = "deathmic", Type = BobDeathmic.Data.Enums.ChatType.Twitch, elevatedPermissions = true }; await service.handleCommand(args, BobDeathmic.Data.Enums.ChatType.Twitch, "deathmic"); Assert.AreNotEqual(null, receivedEventsArgs); Assert.AreEqual("chromos33", receivedEventsArgs.Sender); }
void handleCommandResponse(object sender, CommandResponseArgs e) { if (e.Chat == Data.Enums.ChatType.Discord) { switch (e.MessageType) { case Eventbus.MessageType.ChannelMessage: SendChannelMessage(e.Channel, e.Message); break; case Eventbus.MessageType.PrivateMessage: SendPrivateMessage(e.Sender, e.Message); break; } } }
public void handleCommandResponse(object sender, CommandResponseArgs e) { if (e.Chat == Data.Enums.ChatType.Twitch) { switch (e.MessageType) { case Eventbus.MessageType.ChannelMessage: AddMessageToQueue(e.Channel, e.Message); break; case Eventbus.MessageType.PrivateMessage: client.SendWhisper(e.Sender, e.Message); break; } } }