/// <summary>
        /// Some shared validation to prevent image asset types from being added to documents.
        /// </summary>
        public static IEnumerable <ValidationResult> Validate(IUploadedFile file)
        {
            if (file != null && !string.IsNullOrWhiteSpace(file.FileName))
            {
                // Validate extension & mime type

                var ext = Path.GetExtension(file.FileName)?.Trim();

                if (string.IsNullOrWhiteSpace(ext))
                {
                    yield return(new ValidationResult("The file you're uploading has no file extension.", new string[] { "File" }));
                }
                else if (FilePathHelper.FileExtensionContainsInvalidChars(ext))
                {
                    yield return(new ValidationResult("The file you're uploading uses an extension containing invalid characters.", new string[] { "File" }));
                }
                else if ((ImageAssetConstants.PermittedImageTypes.ContainsKey(ext)) ||
                         (!string.IsNullOrEmpty(file.MimeType) && ImageAssetConstants.PermittedImageTypes.ContainsValue(file.MimeType)))
                {
                    yield return(new ValidationResult("Image files shoud be uploaded in the image assets section.", new string[] { "File" }));
                }

                // Validate filename

                if (string.IsNullOrWhiteSpace(file.FileName))
                {
                    yield return(new ValidationResult("The file you're uploading has no file name.", new string[] { "File" }));
                }
                else if (string.IsNullOrWhiteSpace(FilePathHelper.CleanFileName(file.FileName)))
                {
                    yield return(new ValidationResult("The file you're uploading has an invalid file name.", new string[] { "File" }));
                }
            }
        }
        public void FileExtensionContainsInvalidChars_WhenInvalid_ReturnsTrue(string s)
        {
            var result = FilePathHelper.FileExtensionContainsInvalidChars(s);

            Assert.True(result);
        }
        public void FileExtensionContainsInvalidChars_WhenNullOrWhitespace_ReturnsFalse(string s)
        {
            var result = FilePathHelper.FileExtensionContainsInvalidChars(s);

            Assert.False(result);
        }