Esempio n. 1
0
        public void TestGuessDefaultFileExtension(string mimeType, string extension)
        {
            var sut    = new MimeTypeByExtension();
            var actual = sut.GuessDefaultExtensionFor(mimeType);

            actual.Should().Be(extension);
        }
Esempio n. 2
0
        public void TryFilesWhichWorkWithUrlmon(string filename, string mimetype)
        {
            var uri    = filename.ToUri();
            var actual = new MimeTypeByExtension().GetMimeTypeFor(uri);

            actual.Should().Be(mimetype);
        }
Esempio n. 3
0
        public void TestGetExtensions(string mimeType, string extensions)
        {
            var sut      = new MimeTypeByExtension();
            var actual   = sut.GetExtensionsFor(mimeType);
            var expected = extensions.Split(',');

            actual.Should().Contain(expected);
        }
Esempio n. 4
0
 public void TestRegisterCustomExtension()
 {
     MimeTypeByExtension.IsRegistered("cs").Should().BeFalse();
     try
     {
         MimeTypeByExtension.Register("cs", "text/plain");
         MimeTypeByExtension.IsRegistered("cs").Should().BeTrue();
         new MimeTypeByExtension().GetMimeTypeFor(@"test\code.cs".ToUri()).Should().Be("text/plain");
     }
     finally { MimeTypeByExtension.UseDefaulMapping(); }
 }
Esempio n. 5
0
 public void TestOverrideMimeMapping()
 {
     // cf.: http://stackoverflow.com/questions/208056/what-are-the-mime-types-for-net-project-source-code-files
     MimeTypeByExtension.IsRegistered("cs").Should().BeFalse();
     try
     {
         var myMapping = new Dictionary <string, string> {
             { "cs", "text/plain" }
         };
         MimeTypeByExtension.UseMimeMapping(myMapping);
         new MimeTypeByExtension().GetMimeTypeFor(@"test\code.cs".ToUri()).Should().Be("text/plain");
     }
     finally { MimeTypeByExtension.UseDefaulMapping(); }
 }