1- using Microsoft . Extensions . Configuration ;
2- using Microsoft . Extensions . DependencyInjection ;
3- using Microsoft . Extensions . Logging ;
4- using System ;
1+ using System ;
52using System . Collections . Generic ;
63using System . IO ;
74using System . Linq ;
8- using System . Threading . Tasks ;
5+ using System . Threading . Tasks ;
6+ using Microsoft . Extensions . Configuration ;
7+ using Microsoft . Extensions . DependencyInjection ;
8+ using Microsoft . Extensions . Logging ;
99using Xunit . Abstractions ;
10- using Xunit . Microsoft . DependencyInjection . Logging ;
11-
10+ using Xunit . Microsoft . DependencyInjection . Logging ;
11+
1212namespace Xunit . Microsoft . DependencyInjection . Abstracts
13- {
13+ {
1414 public abstract class TestBedFixture : IDisposable , IAsyncDisposable
1515 {
1616 private readonly IServiceCollection _services ;
@@ -26,6 +26,7 @@ protected TestBedFixture()
2626 }
2727
2828 public IConfigurationRoot Configuration { get ; private set ; }
29+ public IConfigurationBuilder ConfigurationBuilder { get ; private set ; }
2930
3031 public IServiceProvider GetServiceProvider ( ITestOutputHelper testOutputHelper )
3132 {
@@ -48,6 +49,7 @@ public T GetScopedService<T>(ITestOutputHelper testOutputHelper)
4849 public T GetService < T > ( ITestOutputHelper testOutputHelper )
4950 => GetServiceProvider ( testOutputHelper ) . GetService < T > ( ) ;
5051
52+ [ Obsolete ( "GetConfigurationFile() method will be deprecated in the next release. Please start using GetConfigurationFiles() instead." ) ]
5153 protected abstract string GetConfigurationFile ( ) ;
5254 protected abstract void AddServices ( IServiceCollection services , IConfiguration configuration ) ;
5355
@@ -70,12 +72,12 @@ private IConfigurationRoot GetConfigurationRoot()
7072
7173 private IConfigurationRoot GetConfigurationRoot ( IEnumerable < string > configurationFiles )
7274 {
73- var builder = new ConfigurationBuilder ( ) . SetBasePath ( Directory . GetCurrentDirectory ( ) ) ;
75+ ConfigurationBuilder = new ConfigurationBuilder ( ) . SetBasePath ( Directory . GetCurrentDirectory ( ) ) ;
7476 foreach ( var configurationFile in configurationFiles )
7577 {
76- builder . AddJsonFile ( configurationFile ) ;
78+ ConfigurationBuilder . AddJsonFile ( configurationFile ) ;
7779 }
78- return builder . Build ( ) ;
80+ return ConfigurationBuilder . Build ( ) ;
7981 }
8082
8183 protected virtual void Dispose ( bool disposing )
@@ -107,18 +109,18 @@ public void Dispose()
107109 // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
108110 Dispose ( disposing : true ) ;
109111 GC . SuppressFinalize ( this ) ;
110- }
111-
112- public async ValueTask DisposeAsync ( )
113- {
114- if ( ! _disposedAsync )
115- {
116- await DisposeAsyncCore ( ) ;
117- GC . SuppressFinalize ( this ) ;
118- _disposedAsync = true ;
119- }
120- }
121-
122- protected abstract ValueTask DisposeAsyncCore ( ) ;
112+ }
113+
114+ public async ValueTask DisposeAsync ( )
115+ {
116+ if ( ! _disposedAsync )
117+ {
118+ await DisposeAsyncCore ( ) ;
119+ GC . SuppressFinalize ( this ) ;
120+ _disposedAsync = true ;
121+ }
122+ }
123+
124+ protected abstract ValueTask DisposeAsyncCore ( ) ;
123125 }
124126}
0 commit comments