コード例 #1
0
        public void OnlyImageAttribute_ShouldValidateIfTheFileIsImage(string fileName, bool expectedResult)
        {
            var stream = FileHelpers.ReadFile(fileName);

            var attributeToTest = new AllowImageOnlyAttribute();

            Assert.AreEqual(expectedResult, attributeToTest.IsValid(stream));
        }
コード例 #2
0
        public void OnlyImageAttribute_ShouldReturnReturnFalseIfOneOfFilesIsNotImage()
        {
            var fileNames = new[] { "test.png", "test.jpg", "test.bmp", "test.exe" };
            var files     = FileHelpers.ReadFiles(fileNames);

            var attrebuteToTest = new AllowImageOnlyAttribute();

            Assert.IsFalse(attrebuteToTest.IsValid(files));
        }
コード例 #3
0
        public void OnlyImageAttribute_ShouldValidateMultupleFilesIfTheyAreImages()
        {
            var fileNames = new[] { "test.png", "test.jpg", "test.bmp" };
            var files     = FileHelpers.ReadFiles(fileNames);

            var attrebuteToTest = new AllowImageOnlyAttribute();

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