public async Task ParameterNotReceived_Should_ReplyMessage()
        {
            // Arrange
            var          channelConfigurationServiceMock = new Mock <IDiscordChannelConfigService>();
            var          command      = new LanguageCommand(channelConfigurationServiceMock.Object);
            const string replyMessage = "Parameter not received";

            var chatConfig = new DiscordChannelConfig
            {
                SelectedLanguage = SupportedLanguages.Auto
            };

            var channelMock = new Mock <IMessageChannel>();
            var user        = new Mock <IGuildUser>();

            user.Setup(v => v.GuildPermissions).Returns(GuildPermissions.All);
            var message = new Mock <IMessage>();

            message.Setup(v => v.Content).Returns(DiscordBotCommands.Language);
            message.Setup(v => v.Author).Returns(user.Object);
            message.Setup(v => v.Channel).Returns(channelMock.Object);

            channelConfigurationServiceMock.Setup(v => v.GetConfigurationByChannelId(message.Object.Channel.Id))
            .ReturnsAsync(chatConfig);

            // Act
            await command.Handle(message.Object);

            // Assert

            // Verify SendMessageAsync was called with the reply message "Parameter not received"
            channelMock.Verify(v => v.SendMessageAsync(null, false, It.Is <Embed>(e => e.Description.Contains(replyMessage)), null, null, null, null, null, null, MessageFlags.None));
            Assert.Equal(SupportedLanguages.Auto, chatConfig.SelectedLanguage); // Make sure SelectedLanguage is still Auto
        }
예제 #2
0
 private static int Main(string[] args)
 {
     Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
     Logger.Initialize();
     return(Parser.Default.ParseArguments <GenerateCommand, ParseCommand, CleanCommand, LanguageCommand>(args)
            .MapResult(
                (GenerateCommand opts) => GenerateCommand.Handle(opts),
                (ParseCommand opts) => ParseCommand.Handle(opts),
                (CleanCommand opts) => CleanCommand.Handle(opts),
                (LanguageCommand opts) => LanguageCommand.Handle(opts),
                (DocumentationCommand opts) => DocumentationCommand.Handle(opts),
                errs => 1));
 }