File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed
examples/Xunit.Microsoft.DependencyInjection.ExampleTests Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 11namespace Xunit . Microsoft . DependencyInjection . ExampleTests ;
22
3- public class ConfigurationTests : TestBed < TestProjectFixtureWithoutAppsettings >
3+ public class ConfigurationTests : TestBed < TestProjectFixture >
44{
55 private const string Key = "CONFIG_KEY" ;
66 private const string Value = "Value" ;
77
8- public ConfigurationTests ( ITestOutputHelper testOutputHelper , TestProjectFixtureWithoutAppsettings fixture )
8+ public ConfigurationTests ( ITestOutputHelper testOutputHelper , TestProjectFixture fixture )
99 : base ( testOutputHelper , fixture )
1010 {
1111 Environment . SetEnvironmentVariable ( Key , Value ) ;
Original file line number Diff line number Diff line change 1+ namespace Xunit . Microsoft . DependencyInjection . ExampleTests ;
2+
3+ public class ConfigurationTestsWithoutAppsettings : TestBed < TestProjectFixtureWithoutAppsettings >
4+ {
5+ private const string Key = "CONFIG_KEY" ;
6+ private const string Value = "Value" ;
7+
8+ public ConfigurationTestsWithoutAppsettings ( ITestOutputHelper testOutputHelper , TestProjectFixtureWithoutAppsettings fixture )
9+ : base ( testOutputHelper , fixture )
10+ {
11+ Environment . SetEnvironmentVariable ( Key , Value ) ;
12+ }
13+
14+ [ Fact ]
15+ public void EnvironmentVariablesViaConstructorAreAvailable ( )
16+ {
17+ _fixture . GetServiceProvider ( _testOutputHelper ) ;
18+
19+ var value = _fixture . Configuration ! . GetValue < string > ( Key ) ;
20+
21+ Assert . Equal ( Value , value ) ;
22+ }
23+ }
You can’t perform that action at this time.
0 commit comments