public void SecretSanta_Generate_WithBanned_ReturnsASet() { var result = SecretSantaGenerator.Generate(_participants, _banned); CheckForValidSantaList(result); CheckResultHasNoBannedPair(result); }
private static void CreateSantasList(string[] args) { IList <string> participants = ReadFile(args[0]); IDictionary <string, string> bannedPairs = new Dictionary <string, string>(); string outputFile; switch (args.Length) { case 2: outputFile = args[1]; break; case 3: bannedPairs = ReadDictFile(args[1]); outputFile = args[2]; break; default: throw new ArgumentException("Invalid number of arguments passed"); } var santasList = SecretSantaGenerator.Generate(participants, bannedPairs); WriteDictFile(outputFile, santasList); }
public async Task SendAsync() { if (string.IsNullOrEmpty(_configuration["SANTA_PARTICIPANT_PATH"])) { throw new ArgumentException("You must provide path to participants file as first argument"); } var participantsPath = _configuration["SANTA_PARTICIPANT_PATH"]; if (!File.Exists(participantsPath)) { throw new ArgumentException($"File {participantsPath} doesn't exists"); } _logger.LogInformation("Load participants list"); var json = File.ReadAllText(participantsPath); var participants = JsonConvert.DeserializeObject <List <Participant> >(json); _logger.LogInformation("Participants: {count}", participants.Count); var santasList = SecretSantaGenerator.Generate(participants, new Dictionary <Participant, Participant>()); _logger.LogInformation("List generated"); try { await _mailSender.SendMail(santasList, "Secret Santa 2019", "~/Views/Mail/Notification.cshtml"); } catch (Exception ex) { _logger.LogCritical(ex, ex.ToString()); } }
public void SecretSanta_Generate_ReturnsASet() { var result = SecretSantaGenerator.Generate(_participants); CheckForValidSantaList(result); }