Exemplo n.º 1
0
    private async Task ShowStrikes(SocketUser user)
    {
        var strikes = await _strikesHandler.GetStrikesAsync(Context.Guild.Id, user.Id);

        var builder = new EmbedBuilder()
        {
            Color = new Color(150, 0, 0),
        };

        foreach (var strike in strikes)
        {
            builder.AddField($"Id: {strike.Id}", $"Date: {strike.Date}\nMod: {Context.Guild.GetUser(strike.Mod)}\n\n{strike.Reason}", true);
        }

        await Context.Guild.GetTextChannel(await _guildHandler.GetModChannelAsync(Context.Guild.Id))
        .SendMessageAsync($"Strikes logged against {user.Mention}:", embed: builder.Build());
    }
Exemplo n.º 2
0
    public void GetStrikesAsync()
    {
        var mock = new Mock <IStrikeData>(MockBehavior.Strict);

        mock.Setup(x => x.GetStrikesAsync(0, 0)).Returns(Task.FromResult(GetTestStrikes()));

        var StrikeService = new StrikeService(mock.Object);

        var actual = StrikeService.GetStrikesAsync(0, 0).Result;

        for (int i = 0; i < actual.Count; i++)
        {
            Assert.Equal(1 * ((ulong)i + 1), actual[i].Guild);
            Assert.Equal(2 * ((ulong)i + 1), actual[i].Mod);
            Assert.Equal(3 * ((ulong)i + 1), actual[i].User);
            Assert.Equal($"reason{1 * (i + 1)}", actual[i].Reason);
            Assert.Equal($"date{1 * (i + 1)}", actual[i].Date);
            Assert.Equal(10 * (i + 1), actual[i].Id);
        }
    }