Пример #1
0
        public async Task AddTwoTournamentDirectors()
        {
            const ulong              firstUserId   = 123;
            const ulong              secondUserId  = 1234;
            MessageStore             messageStore  = new MessageStore();
            ICommandContext          context       = this.CreateCommandContext(messageStore);
            GlobalTournamentsManager globalManager = new GlobalTournamentsManager();

            AddTournamentDirectorDirectly(globalManager, firstUserId);

            BotCommandHandler commandHandler = new BotCommandHandler(context, globalManager);

            IGuildUser guildUser = this.CreateGuildUser(secondUserId);
            await commandHandler.AddTournamentDirectorAsync(guildUser, DefaultTournamentName);

            string expectedMessage = BotStrings.AddTournamentDirectorSuccessful(
                DefaultTournamentName, DefaultGuildName);

            messageStore.VerifyChannelMessages(expectedMessage);

            TournamentsManager manager = globalManager.GetOrAdd(DefaultGuildId, id => new TournamentsManager());

            Assert.IsTrue(
                manager.TryGetTournament(DefaultTournamentName, out ITournamentState state),
                "Could not find tournament.");
            Assert.IsTrue(state.IsDirector(firstUserId), "First director was not added.");
            Assert.IsTrue(state.IsDirector(secondUserId), "Second director was not added.");
        }
Пример #2
0
        public async Task AddSameTournamentDirectors()
        {
            MessageStore             messageStore  = new MessageStore();
            ICommandContext          context       = this.CreateCommandContext(messageStore);
            GlobalTournamentsManager globalManager = new GlobalTournamentsManager();

            AddTournamentDirectorDirectly(globalManager, DefaultUserId);

            BotCommandHandler commandHandler = new BotCommandHandler(context, globalManager);

            IGuildUser guildUser = this.CreateGuildUser(DefaultUserId);
            await commandHandler.AddTournamentDirectorAsync(guildUser, DefaultTournamentName);

            string expectedMessage = BotStrings.UserAlreadyTournamentDirector(DefaultTournamentName, DefaultGuildName);

            messageStore.VerifyChannelMessages(expectedMessage);

            TournamentsManager manager = globalManager.GetOrAdd(DefaultGuildId, id => new TournamentsManager());

            Assert.IsTrue(
                manager.TryGetTournament(DefaultTournamentName, out ITournamentState state),
                "Could not find tournament.");
            Assert.IsTrue(state.IsDirector(DefaultUserId), "User should still be a director.");
        }