Пример #1
0
        public void AllowTypesAttribute_ShouldThrowExceptionIfNoExtensionsProvided(string fileName, string[] allowedExtensions)
        {
            var stream = FileHelpers.ReadFile(fileName);

            var attributeToTest = new AllowedTypesAttribute(allowedExtensions);

            Assert.Throws <InvalidOperationException>(() => attributeToTest.IsValid(stream));
        }
Пример #2
0
        public void AllowedTypeAttribute_ShouldAllowOnlyPointedTypes(string fileName, string[] allowedExtensions, bool expectedResult)
        {
            var stream = FileHelpers.ReadFile(fileName);

            var attributeToTest = new AllowedTypesAttribute(allowedExtensions);

            Assert.AreEqual(expectedResult, attributeToTest.IsValid(stream));
        }
Пример #3
0
        public void AllowTypesAttribute_ShouldReturnFalseIfOneOfTheFilesIsNotAllowed()
        {
            var fileNames = new[] { "test.zip", "test.7z", "test.gz" };
            var files     = FileHelpers.ReadFiles(fileNames);

            var attributeToTest = new AllowedTypesAttribute(FileExtension.Zip, FileExtension.SevenZ);

            Assert.IsFalse(attributeToTest.IsValid(files));
        }
Пример #4
0
        public void AllowTypesAttribute_ShouldValidateMultipleFiles()
        {
            var fileNames = new[] { "test.zip", "test.7z", "test.gz" };
            var files     = FileHelpers.ReadFiles(fileNames);

            var attributeToTest = new AllowedTypesAttribute(FileExtension.Zip, FileExtension.SevenZ, FileExtension.Gz);

            Assert.IsTrue(attributeToTest.IsValid(files));
        }