示例#1
0
    public void AddConfigAsync()
    {
        var mock = new Mock <IGuildData>(MockBehavior.Strict);

        mock.Setup(x => x.AddConfigAsync(1, 2, '-', false)).Returns(Task.CompletedTask);
        mock.Setup(x => x.AddConfigAsync(1, 2, '!', false)).Returns(Task.CompletedTask);
        mock.Setup(x => x.AddConfigAsync(1, 2, '-', true)).Returns(Task.CompletedTask);
        mock.Setup(x => x.AddConfigAsync(1, 2, '?', true)).Returns(Task.CompletedTask);
        var guildService = new GuildService(mock.Object);

        guildService.AddConfigAsync(1, 2);
        guildService.AddConfigAsync(1, 2, prefix: '!');
        guildService.AddConfigAsync(1, 2, messagelog: true);
        guildService.AddConfigAsync(1, 2, prefix: '?', true);

        mock.Verify(x => x.AddConfigAsync(1, 2, '-', false), Times.Exactly(1));
        mock.Verify(x => x.AddConfigAsync(1, 2, '!', false), Times.Exactly(1));
        mock.Verify(x => x.AddConfigAsync(1, 2, '-', true), Times.Exactly(1));
        mock.Verify(x => x.AddConfigAsync(1, 2, '?', true), Times.Exactly(1));
    }
示例#2
0
 private async Task AddGuild(SocketGuild guild)
 {
     await _guildService.AddConfigAsync(guild.Id, guild.DefaultChannel.Id);
 }