private void CreateHandler( out AdminCommandHandler handler, out MessageStore messageStore) { this.CreateHandler( 9999, "Voice", out handler, out messageStore, out _); }
public async Task Verify_required_role() { var handler = new AdminCommandHandler(); handler.SecurityContextManager = Substitute.For <ISecurityContextManager>(); handler.SecurityContextManager.GetCurrentClaims().ReturnsForAnyArgs(new Claim[] { new Claim("role", "admin"), }); //invoke the handler, evereything should go ok await handler.HandleAsync(new AdminCommand()).ConfigureAwait(false); }
private void CreateHandler( ulong voiceChannelId, string voiceChannelName, out AdminCommandHandler handler, out MessageStore messageStore, out IGuildTextChannel guildTextChannel) { messageStore = new MessageStore(); ICommandContext commandContext = CommandMocks.CreateCommandContext( messageStore, DefaultIds, DefaultGuildId, DefaultChannelId, DefaultReaderId, (mockGuild, textChannel) => { Mock <IVoiceChannel> mockVoiceChannel = new Mock <IVoiceChannel>(); mockVoiceChannel.Setup(voiceChannel => voiceChannel.Id).Returns(voiceChannelId); mockVoiceChannel.Setup(voiceChannel => voiceChannel.Name).Returns(voiceChannelName); mockGuild .Setup(guild => guild.GetVoiceChannelAsync(It.IsAny <ulong>(), It.IsAny <CacheMode>(), It.IsAny <RequestOptions>())) .Returns(Task.FromResult(mockVoiceChannel.Object)); List <IVoiceChannel> voiceChannels = new List <IVoiceChannel>() { mockVoiceChannel.Object }; mockGuild .Setup(guild => guild.GetVoiceChannelsAsync(It.IsAny <CacheMode>(), It.IsAny <RequestOptions>())) .Returns(Task.FromResult <IReadOnlyCollection <IVoiceChannel> >(voiceChannels)); }, out guildTextChannel); IDatabaseActionFactory dbActionFactory = CommandMocks.CreateDatabaseActionFactory( this.botConfigurationfactory); handler = new AdminCommandHandler(commandContext, dbActionFactory); }