public async Task ValidParameter_Should_ChangeChatConfig_And_ReplyMessage(GrammarAlgorithms algorithmParameter) { // Arrange var channelConfigurationServiceMock = new Mock <IDiscordChannelConfigService>(); var command = new SetAlgorithmCommand(channelConfigurationServiceMock.Object); const string replyMessage = "Algorithm updated"; var chatConfig = new DiscordChannelConfig { GrammarAlgorithm = GrammarAlgorithms.YandexSpellerApi }; 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.SetAlgorithm} {(int)algorithmParameter}"); 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 "Algorithm updated" 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(algorithmParameter, chatConfig.GrammarAlgorithm); }
static string GetAvailableAlgorithms(GrammarAlgorithms selectedAlgorith) { var algorithms = Enum.GetValues(typeof(GrammarAlgorithms)).Cast <GrammarAlgorithms>(); var messageBuilder = new StringBuilder(); messageBuilder.AppendLine("Algorithms available:"); foreach (var item in algorithms) { var selected = item == selectedAlgorith ? "✅" : ""; messageBuilder.AppendLine($"{(int)item} - {item.GetDescription()} {selected}"); } return(messageBuilder.ToString()); }