@@ -114,6 +114,57 @@ public void GetContentType_ReturnsTextPlainForCompressedTextFiles(string path)
114
114
Assert . Equal ( "text/plain" , contentType . MimeType ) ;
115
115
}
116
116
117
+ [ Fact ]
118
+ public void GetContentType_CustomMappingOverridesBuiltInMapping ( )
119
+ {
120
+ // Arrange
121
+ var customMapping = new ContentTypeMapping ( "text/html" , "no-store, must-revalidate, no-cache" , "*.html" , 2 ) ;
122
+ var provider = new ContentTypeProvider ( [ customMapping ] ) ;
123
+
124
+ // Act
125
+ var contentType = provider . ResolveContentTypeMapping ( CreateContext ( "index.html" ) , _log ) ;
126
+
127
+ // Assert
128
+ Assert . Equal ( "text/html" , contentType . MimeType ) ;
129
+ Assert . Equal ( "no-store, must-revalidate, no-cache" , contentType . Cache ) ;
130
+ Assert . Equal ( "*.html" , contentType . Pattern ) ;
131
+ Assert . Equal ( 2 , contentType . Priority ) ;
132
+ }
133
+
134
+ [ Fact ]
135
+ public void GetContentType_CustomMappingOverridesBuiltInMappingForCompressedFiles ( )
136
+ {
137
+ // Arrange
138
+ var customMapping = new ContentTypeMapping ( "text/html" , "no-store, must-revalidate, no-cache" , "*.html" , 2 ) ;
139
+ var provider = new ContentTypeProvider ( [ customMapping ] ) ;
140
+
141
+ // Act
142
+ var contentType = provider . ResolveContentTypeMapping ( CreateContext ( "index.html.gz" ) , _log ) ;
143
+
144
+ // Assert
145
+ Assert . Equal ( "text/html" , contentType . MimeType ) ;
146
+ Assert . Equal ( "no-store, must-revalidate, no-cache" , contentType . Cache ) ;
147
+ Assert . Equal ( "*.html" , contentType . Pattern ) ;
148
+ Assert . Equal ( 2 , contentType . Priority ) ;
149
+ }
150
+
151
+ [ Fact ]
152
+ public void GetContentType_CustomJavaScriptMappingOverridesBuiltIn ( )
153
+ {
154
+ // Arrange
155
+ var customMapping = new ContentTypeMapping ( "text/javascript" , "max-age=3600" , "*.js" , 3 ) ;
156
+ var provider = new ContentTypeProvider ( [ customMapping ] ) ;
157
+
158
+ // Act
159
+ var contentType = provider . ResolveContentTypeMapping ( CreateContext ( "app.js" ) , _log ) ;
160
+
161
+ // Assert
162
+ Assert . Equal ( "text/javascript" , contentType . MimeType ) ;
163
+ Assert . Equal ( "max-age=3600" , contentType . Cache ) ;
164
+ Assert . Equal ( "*.js" , contentType . Pattern ) ;
165
+ Assert . Equal ( 3 , contentType . Priority ) ;
166
+ }
167
+
117
168
private class TestTaskLoggingHelper : TaskLoggingHelper
118
169
{
119
170
public TestTaskLoggingHelper ( ) : base ( new TestTask ( ) )
0 commit comments