public void ValidationPassesWhenFileSizeIsNotLargerThan10MB(long fileSize)
        {
            IFormFile file      = new FormFile(new MemoryStream(Encoding.UTF8.GetBytes("This is a dummy file")), 0, fileSize, "FileName", "FileName.doc");
            var       attribute = new FileValidatiorAttribute(false);

            var isValid = attribute.IsValid(file);

            Assert.True(isValid);
        }
        public void ValidationFailsWhenFileSizeExceeds10MB()
        {
            IFormFile file      = new FormFile(new MemoryStream(Encoding.UTF8.GetBytes("This is a dummy file")), 0, (10 * 1024 * 1024) + 1, "FileName", "FileName.doc");
            var       attribute = new FileValidatiorAttribute(false);

            var isValid = attribute.IsValid(file);

            Assert.False(isValid);
        }
        public void ValidationPassesWhenFileNameNotLongerThanFiftyCharacters(string fileName)
        {
            IFormFile file      = new FormFile(new MemoryStream(Encoding.UTF8.GetBytes("This is a dummy file")), 0, 50, fileName, fileName + ".doc");
            var       attribute = new FileValidatiorAttribute(false);

            var isValid = attribute.IsValid(file);

            Assert.True(isValid);
        }
        public void ValidationFailsWhenFileNameLongerThanFiftyCharacters()
        {
            IFormFile file      = new FormFile(new MemoryStream(Encoding.UTF8.GetBytes("This is a dummy file")), 0, 50, "fileWithNameLongerThanFiftyCharactersShouldNotPassValidation", "fileWithNameLongerThanFiftyCharactersShouldNotPassValidation.doc");
            var       attribute = new FileValidatiorAttribute(false);

            var isValid = attribute.IsValid(file);

            Assert.False(isValid);
        }
        public void NullFileValidationFailsWhenNullFlagIsNotRaised()
        {
            IFormFile file      = null;
            var       attribute = new FileValidatiorAttribute(false);

            var isValid = attribute.IsValid(file);

            Assert.False(isValid);
        }
        public void NullFileValidationPassesWhenNullFlagIsRaised()
        {
            IFormFile file      = null;
            var       attribute = new FileValidatiorAttribute(true);

            var isValid = attribute.IsValid(file);

            Assert.True(isValid);
        }