1
- using Microsoft . Extensions . Configuration ;
2
- using Microsoft . Extensions . DependencyInjection ;
3
- using Microsoft . Extensions . Logging ;
4
- using System ;
1
+ using System ;
5
2
using System . Collections . Generic ;
6
3
using System . IO ;
7
4
using 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 ;
9
9
using Xunit . Abstractions ;
10
- using Xunit . Microsoft . DependencyInjection . Logging ;
11
-
10
+ using Xunit . Microsoft . DependencyInjection . Logging ;
11
+
12
12
namespace Xunit . Microsoft . DependencyInjection . Abstracts
13
- {
13
+ {
14
14
public abstract class TestBedFixture : IDisposable , IAsyncDisposable
15
15
{
16
16
private readonly IServiceCollection _services ;
@@ -26,6 +26,7 @@ protected TestBedFixture()
26
26
}
27
27
28
28
public IConfigurationRoot Configuration { get ; private set ; }
29
+ public IConfigurationBuilder ConfigurationBuilder { get ; private set ; }
29
30
30
31
public IServiceProvider GetServiceProvider ( ITestOutputHelper testOutputHelper )
31
32
{
@@ -48,6 +49,7 @@ public T GetScopedService<T>(ITestOutputHelper testOutputHelper)
48
49
public T GetService < T > ( ITestOutputHelper testOutputHelper )
49
50
=> GetServiceProvider ( testOutputHelper ) . GetService < T > ( ) ;
50
51
52
+ [ Obsolete ( "GetConfigurationFile() method will be deprecated in the next release. Please start using GetConfigurationFiles() instead." ) ]
51
53
protected abstract string GetConfigurationFile ( ) ;
52
54
protected abstract void AddServices ( IServiceCollection services , IConfiguration configuration ) ;
53
55
@@ -70,12 +72,12 @@ private IConfigurationRoot GetConfigurationRoot()
70
72
71
73
private IConfigurationRoot GetConfigurationRoot ( IEnumerable < string > configurationFiles )
72
74
{
73
- var builder = new ConfigurationBuilder ( ) . SetBasePath ( Directory . GetCurrentDirectory ( ) ) ;
75
+ ConfigurationBuilder = new ConfigurationBuilder ( ) . SetBasePath ( Directory . GetCurrentDirectory ( ) ) ;
74
76
foreach ( var configurationFile in configurationFiles )
75
77
{
76
- builder . AddJsonFile ( configurationFile ) ;
78
+ ConfigurationBuilder . AddJsonFile ( configurationFile ) ;
77
79
}
78
- return builder . Build ( ) ;
80
+ return ConfigurationBuilder . Build ( ) ;
79
81
}
80
82
81
83
protected virtual void Dispose ( bool disposing )
@@ -107,18 +109,18 @@ public void Dispose()
107
109
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
108
110
Dispose ( disposing : true ) ;
109
111
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 ( ) ;
123
125
}
124
126
}
0 commit comments