public void AllowTypesAttribute_ShouldThrowExceptionIfNoExtensionsProvided(string fileName, string[] allowedExtensions)
        {
            var stream = FileHelpers.ReadFile(fileName);

            var attributeToTest = new AllowedTypesAttribute(allowedExtensions);

            Assert.Throws <InvalidOperationException>(() => attributeToTest.IsValid(stream));
        }
        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));
        }
        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));
        }
        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));
        }