1313using System . Threading . Tasks ;
1414using Microsoft . AspNetCore . Builder ;
1515using Microsoft . AspNetCore . Hosting ;
16- using Microsoft . AspNetCore . Hosting . Server . Features ;
1716using Microsoft . AspNetCore . Http ;
1817using Microsoft . AspNetCore . Server . IntegrationTesting ;
1918using Microsoft . AspNetCore . Server . IntegrationTesting . Common ;
2019using Microsoft . AspNetCore . Testing . xunit ;
2120using Microsoft . Extensions . DependencyInjection ;
21+ using Microsoft . Extensions . Logging . Testing ;
2222using Xunit ;
2323
2424namespace Microsoft . AspNetCore . StaticFiles
2525{
26- public class StaticFileMiddlewareTests
26+ public class StaticFileMiddlewareTests : LoggedTest
2727 {
2828 [ Fact ]
2929 public async Task ReturnsNotFoundWithoutWwwroot ( )
3030 {
3131 var builder = new WebHostBuilder ( )
32+ . ConfigureServices ( services => services . AddSingleton ( LoggerFactory ) )
3233 . UseKestrel ( )
3334 . Configure ( app => app . UseStaticFiles ( ) ) ;
3435
@@ -47,6 +48,7 @@ public async Task ReturnsNotFoundWithoutWwwroot()
4748 public async Task FoundFile_LastModifiedTrimsSeconds ( )
4849 {
4950 var builder = new WebHostBuilder ( )
51+ . ConfigureServices ( services => services . AddSingleton ( LoggerFactory ) )
5052 . UseKestrel ( )
5153 . UseWebRoot ( AppContext . BaseDirectory )
5254 . Configure ( app => app . UseStaticFiles ( ) ) ;
@@ -87,6 +89,7 @@ public async Task FoundFile_Served_Windows(string baseUrl, string baseDir, strin
8789 private async Task FoundFile_Served ( string baseUrl , string baseDir , string requestUrl )
8890 {
8991 var builder = new WebHostBuilder ( )
92+ . ConfigureServices ( services => services . AddSingleton ( LoggerFactory ) )
9093 . UseKestrel ( )
9194 . UseWebRoot ( Path . Combine ( AppContext . BaseDirectory , baseDir ) )
9295 . Configure ( app => app . UseStaticFiles ( new StaticFileOptions ( )
@@ -124,6 +127,7 @@ private async Task FoundFile_Served(string baseUrl, string baseDir, string reque
124127 public async Task HeadFile_HeadersButNotBodyServed ( string baseUrl , string baseDir , string requestUrl )
125128 {
126129 var builder = new WebHostBuilder ( )
130+ . ConfigureServices ( services => services . AddSingleton ( LoggerFactory ) )
127131 . UseKestrel ( )
128132 . UseWebRoot ( Path . Combine ( AppContext . BaseDirectory , baseDir ) )
129133 . Configure ( app => app . UseStaticFiles ( new StaticFileOptions ( )
@@ -181,6 +185,7 @@ private void ClientDisconnect_NoWriteExceptionThrown(ServerType serverType)
181185 var responseComplete = new ManualResetEvent ( false ) ;
182186 Exception exception = null ;
183187 var builder = new WebHostBuilder ( )
188+ . ConfigureServices ( services => services . AddSingleton ( LoggerFactory ) )
184189 . UseWebRoot ( Path . Combine ( AppContext . BaseDirectory ) )
185190 . Configure ( app =>
186191 {
0 commit comments