示例#1
0
        public void TestVideoFile(string type)
        {
            var path   = SolutionPath + "test_file_" + type;
            var header = MimeChecker.GetFileHeader(path);

            DoTests(header, FileType.Video, type);
        }
示例#2
0
        public void Jpeg()
        {
            var header = MimeChecker.GetFileHeader(SolutionPath + "/Files/test_file_jpg");

            Assert.NotNull(header, "File header returned null");
            Assert.AreEqual(header.Type, FileType.Image, "File should be an image");
            Assert.AreEqual(header.Extension, "jpg", "File format should be a jpg");
        }
示例#3
0
        public void Wav()
        {
            var header = MimeChecker.GetFileHeader(SolutionPath + "/Files/test_file_wav");

            Assert.NotNull(header, "File header returned null");
            Assert.AreEqual(header.Type, FileType.Audio, "Should be an audio file");
            Assert.AreEqual(header.Extension, "wav", "File format should be wav");
        }
 public void PartialSignature_IsDetected()
 {
     var buffer = new byte[] { 00, 00, 01, 0xB0 };
     var checker = new MimeChecker();
     for (int n = 0; n < 16; n++)
     {
         using (var stream = new MemoryStream(buffer))
         {
             buffer[3] = (byte)(0xB0 | n);
             var header = checker.GetFileHeader(stream);
             Assert.AreEqual(FileType.Video, header.Type);
             Assert.AreEqual("mpg", header.Extension);
         }
     }
 }
示例#5
0
        public void PartialSignature_IsDetected()
        {
            var buffer  = new byte[] { 00, 00, 01, 0xB0 };
            var checker = new MimeChecker();

            for (int n = 0; n < 16; n++)
            {
                using (var stream = new MemoryStream(buffer))
                {
                    buffer[3] = (byte)(0xB0 | n);
                    var header = checker.GetFileHeader(stream);
                    Assert.AreEqual(FileType.Video, header.Type);
                    Assert.AreEqual("mpg", header.Extension);
                }
            }
        }
示例#6
0
        public void Avi()
        {
            var header = MimeChecker.GetFileHeader(SolutionPath + "/Files/test_file_avi");

            DoTests(header, FileType.Video, "avi");
        }
示例#7
0
        public void Jpeg()
        {
            var header = MimeChecker.GetFileHeader(SolutionPath + "/Files/test_file_jpg");

            DoTests(header, FileType.Image, "jpg");
        }
示例#8
0
        public void Gif()
        {
            var header = MimeChecker.GetFileHeader(SolutionPath + "/Files/test_file_gif");

            DoTests(header, FileType.Image, "gif");
        }
示例#9
0
        public void Wav()
        {
            var header = MimeChecker.GetFileHeader(SolutionPath + "/Files/test_file_wav");

            DoTests(header, FileType.Audio, "wav");
        }