private async Task SendDirectMessageAsync(PegRecipient recipient) { var pegsPlural = recipient.PegCount == 1 ? string.Empty : "s"; var penaltiesPlural = recipient.PenaltyCount == 1 ? "y" : "ies"; var pointsPlural = recipient.TotalPoints == 1 ? string.Empty : "s"; var message = $"You have received {recipient.PegCount} peg{pegsPlural} and {recipient.PenaltyCount} penalt{penaltiesPlural} this cycle, for a total of {recipient.TotalPoints} point{pointsPlural}:\n\n"; message += string.Join("\n", recipient.Pegs.Select(FormatPeg)); await _messageHandler.SendMessageAsync(new Message { Text = message, RoomId = recipient.UserId }); }
public static IEnumerable <object[]> GetWinnersTestData() { // no eligible winners yield return(new object[] { new List <PegRecipient> { new PegRecipient { UserId = "User1Id", Name = "User 1", Location = "Location1", TotalPoints = 2, PegCount = 2, PenaltyCount = 1, PegsGivenCount = 0, Pegs = new List <PegDetails> { new PegDetails { SenderName = "User 2", Weight = 1, Comment = "This is a peg keyword1 keyword2", Keywords = new List <string> { "keyword1", "keyword2" }, SenderLocation = "Location1" }, new PegDetails { SenderName = "User 3", Weight = 2, Comment = "This is a peg keyword1", Keywords = new List <string> { "keyword1" }, SenderLocation = "Location2" } }, Penalties = new List <PegDetails> { new PegDetails { SenderName = "OtherBot", Weight = 1, Comment = "This is a shame peg penaltyKeyword", Keywords = new List <string> { "penaltyKeyword" }, SenderLocation = "Location1" } } } }, 1, // minimum 1, // winners new List <PegRecipient>() }); // single winner var winner1 = new PegRecipient { UserId = "Winner1Id", Name = "Winner 1", Location = "Location1", TotalPoints = 2, PegCount = 2, PenaltyCount = 1, PegsGivenCount = 2, Pegs = new List <PegDetails> { new PegDetails { SenderName = "User 2", Weight = 1, Comment = "This is a peg keyword1 keyword2", Keywords = new List <string> { "keyword1", "keyword2" }, SenderLocation = "Location1" }, new PegDetails { SenderName = "User 3", Weight = 2, Comment = "This is a peg keyword1", Keywords = new List <string> { "keyword1" }, SenderLocation = "Location2" } }, Penalties = new List <PegDetails> { new PegDetails { SenderName = "OtherBot", Weight = 1, Comment = "This is a shame peg penaltyKeyword", Keywords = new List <string> { "penaltyKeyword" }, SenderLocation = "Location1" } } }; var notEnoughPegsGiven = new PegRecipient { UserId = "NotEnoughPegs", Name = "Not Enough Pegs", Location = "Location2", TotalPoints = 2, PegCount = 1, PenaltyCount = 0, PegsGivenCount = 1, Pegs = new List <PegDetails> { new PegDetails { SenderName = "User 2", Weight = 1, Comment = "This is an inter location peg keyword2", Keywords = new List <string> { "keyword2" }, SenderLocation = "Location1" } }, Penalties = new List <PegDetails>() }; var cutoff = new PegRecipient { UserId = "Cutoff", Name = "Cutoff", Location = "Location1", TotalPoints = 1, PegCount = 1, PenaltyCount = 0, PegsGivenCount = 2, Pegs = new List <PegDetails> { new PegDetails { SenderName = "User 2", Weight = 1, Comment = "This is another peg keyword1", Keywords = new List <string> { "keyword1" }, SenderLocation = "Location1" } }, Penalties = new List <PegDetails>() }; yield return(new object[] { new List <PegRecipient> { winner1, notEnoughPegsGiven, cutoff }, 2, // minimum 1, // winners new List <PegRecipient> { winner1 } }); yield return(new object[] { new List <PegRecipient> { winner1, notEnoughPegsGiven, cutoff }, 2, // minimum 2, // winners new List <PegRecipient> { winner1, cutoff } }); }