public void AsText_ProfilesWithErrors()
        {
            var report = new ValidationReport(new ProfileValidationResult(new SlackUser {
                Id = "User1", Name = "User 1"
            }, "errors"), new ProfileValidationResult(new SlackUser {
                Id = "User2", Name = "User 2"
            }, "errors"));

            Assert.Equal("2 users have bad profiles:\r\n<@User1>, <@User2>", report.ToString());
        }
        public void ToString_2ValidationsWithBadImages_TheTwoUsersAreIncludedInReport()
        {
            var report = new ValidationReport(
                new ProfileValidationResult(new SlackUser {
                Id = "User1", Name = "User 1"
            }, "errors", new Uri("http://suspect1.jpg")),
                new ProfileValidationResult(new SlackUser {
                Id = "User2", Name = "User 2"
            }, "errors"),
                new ProfileValidationResult(new SlackUser {
                Id = "User3", Name = "User 3"
            }, "errors", new Uri("http://suspect3.jpg")));

            var text = report.ToString();

            Assert.Equal($"3 users have bad profiles:{Environment.NewLine}<@User1> 🌅, <@User2>, <@User3> 🌅", text);
        }
        async Task ValidateAllProfiles(bool informUsers = false)
        {
            if (informUsers)
            {
                await slackIntegration.SendDirectMessage(adminUser, "Notifying all users");
            }
            else
            {
                await slackIntegration.SendDirectMessage(adminUser, "Validating all users");
            }

            async Task <string> ValidateAllProfiles()
            {
                var usersWithIncompleteProfiles = new List <ProfileValidationResult>();

                foreach (var user in await slackIntegration.GetAllUsers())
                {
                    await slackIntegration.IndicateTyping(adminUser);

                    var verificationResult = await slackProfileValidator.ValidateProfile(user);

                    if (verificationResult.IsValid)
                    {
                        continue;
                    }

                    usersWithIncompleteProfiles.Add(verificationResult);
                    if (!informUsers)
                    {
                        continue;
                    }

                    await slackIntegration.SendDirectMessage(verificationResult.User, verificationResult.Errors);

                    await slackIntegration.SendDirectMessage(adminUser, verificationResult.Errors);
                }

                var validationReport = new ValidationReport(usersWithIncompleteProfiles.ToArray());
                await faceWhitelist.UploadReport(validationReport);

                return(validationReport.ToString());
            }

            await slackIntegration.SendDirectMessage(adminUser, await ValidateAllProfiles());
        }
 /// <summary>
 ///     Initializes a new instance of the <see cref="CommandValidationException" /> class.
 /// </summary>
 /// <param name="validationReport">The validation report.</param>
 /// <exception cref="System.ArgumentNullException">validationReport</exception>
 public CommandValidationException(ValidationReport validationReport) : this(validationReport.ToString(), validationReport)
 {
 }
        public void AsText_NoProfileErrors()
        {
            var report = new ValidationReport();

            Assert.Equal("No profiles contain errors :)", report.ToString());
        }
 /// <summary>
 ///     Initializes a new instance of the <see cref="CommandValidationException" /> class.
 /// </summary>
 /// <param name="validationReport">The validation report.</param>
 /// <exception cref="System.ArgumentNullException">validationReport</exception>
 public CommandValidationException(ValidationReport validationReport) : this(validationReport.ToString(), validationReport)
 {
 }