public void DiscordMessagesAreCorrectlyLogger(LogSeverity severity, LogLevel expectedLevel)
        {
            // arrange
            const string logMessage       = "Test log";
            var          fixture          = new DiscordBotFixture();
            var          logMessageDummy  = new LogMessage(severity, "", logMessage);
            var          logProviderDummy = new Mock <ILoggerProvider>();
            var          loggerDummy      = new LoggerFixture();

            logProviderDummy
            .Setup(t => t.CreateLogger(It.IsAny <string>()))
            .Returns(loggerDummy);

            Logging.StaticLogger.LoggerFactory.AddProvider(logProviderDummy.Object);

            var _ = fixture.GetInstance();

            // act
            fixture.DiscordSocketClientWrapperMock.Raise(x => x.Log += null, null, logMessageDummy);

            // assert
            loggerDummy.LoggedMessages.Count.Should().Be(1);
            loggerDummy.LoggedMessages.First().message.Should().Be(logMessage);
            loggerDummy.LoggedMessages.First().level.Should().Be(expectedLevel);
        }
        public async Task StoppingTheBotInvokesTheStopMethodOnTheClient()
        {
            // arrange
            var fixture = new DiscordBotFixture();

            var sut = fixture.GetInstance();

            // act
            await sut.StopAsync();

            // assert
            fixture.DiscordSocketClientWrapperMock.Verify(t => t.StopAsync(), Times.Once);
        }
        public void MessagesOtherThanSocketUserMessageIsNotHandled()
        {
            // arrange
            var fixture        = new DiscordBotFixture();
            var botConfigDummy = new Mock <IDiscordBotConfig>();
            var messageDummy   = new SocketMessageWrapper(botConfigDummy.Object);

            var _ = fixture.GetInstance();

            // act
            fixture.DiscordSocketClientWrapperMock.Raise(x => x.MessageReceived += null, null, messageDummy);

            // assert
            fixture.CommandServiceWrapperMock.Verify(t => t.ExecuteAsync(It.IsAny <ICommandContext>(), It.IsAny <int>(), null, MultiMatchHandling.Exception), Times.Never);
        }
        public async Task StartingTheBotMoreThanOnceWillOnlyInvokeModuleSetupOnce()
        {
            // arrange
            var fixture = new DiscordBotFixture();

            var sut = fixture.GetInstance();

            // act
            await sut.StartAsync();

            await sut.StartAsync();

            // assert
            fixture.CommandServiceWrapperMock.Verify(t => t.AddModulesAsync(It.IsAny <Assembly>(), It.IsAny <IServiceProvider>()), Times.Once());
        }
        public async Task StartingTheBotInvokesAllRequiredMethods()
        {
            // arrange
            var fixture = new DiscordBotFixture();

            var sut = fixture.GetInstance();

            // act
            await sut.StartAsync();

            // assert
            fixture.CommandServiceWrapperMock.Verify(t => t.AddModulesAsync(It.IsAny <Assembly>(), It.IsAny <IServiceProvider>()), Times.Once());
            fixture.DiscordSocketClientWrapperMock.Verify(t => t.LoginAsync(), Times.Once);
            fixture.DiscordSocketClientWrapperMock.Verify(t => t.StartAsync(), Times.Once);
        }