Skip to content

Commit bd6134c

Browse files
committed
Turn scope by default for testing purposes
1 parent 5919948 commit bd6134c

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/Middleware/Diagnostics/src/ExceptionHandler/ExceptionHandlerOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class ExceptionHandlerOptions
2222
/// replace it on <see cref="HttpContext.RequestServices"/> when re-executing the request to handle an error.
2323
/// </summary>
2424
/// <remarks>The default value is <see langword="false"/>.</remarks>
25-
public bool CreateScopeForErrors { get; set; }
25+
public bool CreateScopeForErrors { get; set; } = true;
2626

2727
/// <summary>
2828
/// The <see cref="RequestDelegate" /> that will handle the exception. If this is not

src/Middleware/Diagnostics/test/UnitTests/ExceptionHandlerMiddlewareTest.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,29 @@ private class TestServiceProvider : IServiceProvider
396396
{
397397
public object GetService(Type serviceType)
398398
{
399+
if (serviceType == typeof(IServiceScopeFactory))
400+
{
401+
return new TestServiceScopeFactory();
402+
}
403+
399404
throw new NotImplementedException();
400405
}
401406
}
407+
408+
private class TestServiceScopeFactory : IServiceScopeFactory
409+
{
410+
public IServiceScope CreateScope()
411+
{
412+
return new TestServiceScope();
413+
}
414+
}
415+
416+
private class TestServiceScope : IServiceScope
417+
{
418+
public IServiceProvider ServiceProvider => new TestServiceProvider();
419+
420+
public void Dispose()
421+
{
422+
}
423+
}
402424
}

0 commit comments

Comments
 (0)