private void CreateHandler( IOptionsMonitor <BotConfiguration> options, IFileScoresheetGenerator scoresheetGenerator, out ReaderCommandHandler handler, out GameState game, out MessageStore messageStore) { messageStore = new MessageStore(); ICommandContext commandContext = CommandMocks.CreateCommandContext( messageStore, DefaultIds, DefaultGuildId, DefaultChannelId, userId: DefaultReaderId, updateMockGuild: UpdateMockGuild, out _); GameStateManager manager = new GameStateManager(); manager.TryCreate(DefaultChannelId, out game); game.TeamManager = new ByCommandTeamManager(); IDatabaseActionFactory dbActionFactory = CommandMocks.CreateDatabaseActionFactory( this.botConfigurationfactory); handler = new ReaderCommandHandler(commandContext, manager, options, dbActionFactory, scoresheetGenerator); }
public async Task ClearAllRemovesGame() { GameStateManager manager = new GameStateManager(); manager.TryCreate(DefaultChannelId, out GameState currentGame); MessageStore messageStore = new MessageStore(); ICommandContext commandContext = CommandMocks.CreateCommandContext( messageStore, DefaultIds, DefaultGuildId, DefaultChannelId, DefaultReaderId); IDatabaseActionFactory dbActionFactory = CommandMocks.CreateDatabaseActionFactory( this.botConfigurationfactory); IOptionsMonitor <BotConfiguration> options = CommandMocks.CreateConfigurationOptionsMonitor(); IFileScoresheetGenerator scoresheetGenerator = (new Mock <IFileScoresheetGenerator>()).Object; ReaderCommandHandler handler = new ReaderCommandHandler( commandContext, manager, options, dbActionFactory, scoresheetGenerator); await handler.ClearAllAsync(); Assert.IsFalse( manager.TryGet(DefaultChannelId, out _), "Game should have been removed from the manager."); Assert.AreEqual(1, messageStore.ChannelMessages.Count, "Unexpected number of messages sent."); }
private void CreateHandler( out ReaderCommandHandler handler, out GameState game, out MessageStore messageStore) { this.CreateHandler(DefaultIds, out handler, out game, out messageStore); }