@@ -22,11 +22,21 @@ public sealed class AggregatedConfigurationTests
22
22
[ DataRow ( PlatformConfigurationConstants . PlatformResultDirectory ) ]
23
23
[ DataRow ( PlatformConfigurationConstants . PlatformCurrentWorkingDirectory ) ]
24
24
[ DataRow ( PlatformConfigurationConstants . PlatformTestHostWorkingDirectory ) ]
25
- public void IndexerTest_DirectoryNotSetAndNoConfigurationProviders_DirectoryIsNull ( string key )
26
- => Assert . IsNull ( new AggregatedConfiguration ( [ ] , _testApplicationModuleInfoMock . Object , _fileSystemMock . Object , new ( null , [ ] , [ ] ) ) [ key ] ) ;
25
+ public void IndexerTest_DirectoryNotSetAndNoConfigurationProviders ( string key )
26
+ {
27
+ _testApplicationModuleInfoMock . Setup ( x => x . GetCurrentTestApplicationDirectory ( ) ) . Returns ( "TestAppDir" ) ;
28
+ string ? expected = key switch
29
+ {
30
+ PlatformConfigurationConstants . PlatformResultDirectory => Path . Combine ( "TestAppDir" , "TestResults" ) ,
31
+ PlatformConfigurationConstants . PlatformCurrentWorkingDirectory => "TestAppDir" ,
32
+ PlatformConfigurationConstants . PlatformTestHostWorkingDirectory => null ,
33
+ _ => throw ApplicationStateGuard . Unreachable ( ) ,
34
+ } ;
35
+
36
+ Assert . AreEqual ( expected , new AggregatedConfiguration ( [ ] , _testApplicationModuleInfoMock . Object , _fileSystemMock . Object , new ( null , [ ] , [ ] ) ) [ key ] ) ;
37
+ }
27
38
28
39
[ TestMethod ]
29
- [ DataRow ( PlatformConfigurationConstants . PlatformResultDirectory ) ]
30
40
[ DataRow ( PlatformConfigurationConstants . PlatformCurrentWorkingDirectory ) ]
31
41
[ DataRow ( PlatformConfigurationConstants . PlatformTestHostWorkingDirectory ) ]
32
42
public void IndexerTest_DirectoryNotSetButConfigurationProvidersPresent_DirectoryIsNull ( string key )
@@ -126,7 +136,7 @@ public async ValueTask CheckTestResultsDirectoryOverrideAndCreateItAsync_Results
126
136
Mock < IFileLoggerProvider > mockFileLogger = new ( ) ;
127
137
mockFileLogger . Setup ( x => x . CheckLogFolderAndMoveToTheNewIfNeededAsync ( It . IsAny < string > ( ) ) ) . Callback ( ( ) => { } ) ;
128
138
129
- AggregatedConfiguration aggregatedConfiguration = new ( [ ] , mockTestApplicationModuleInfo . Object , mockFileSystem . Object , new ( null , [ new CommandLineParseOption ( "results-directory" , [ ExpectedPath ] ) ] , [ ] ) ) ;
139
+ AggregatedConfiguration aggregatedConfiguration = new ( [ ] , mockTestApplicationModuleInfo . Object , mockFileSystem . Object , new ( null , [ ] , [ ] ) ) ;
130
140
await aggregatedConfiguration . CheckTestResultsDirectoryOverrideAndCreateItAsync ( mockFileLogger . Object ) ;
131
141
132
142
string expectedPath = "a" + Path . DirectorySeparatorChar + "b" + Path . DirectorySeparatorChar + "TestResults" ;
@@ -161,35 +171,3 @@ public bool TryGet(string key, out string? value)
161
171
}
162
172
}
163
173
}
164
-
165
- internal sealed class FakeCommandLineOptions : ICommandLineOptions
166
- {
167
- private readonly string _path ;
168
- private readonly bool _bypass ;
169
-
170
- public FakeCommandLineOptions ( string path , bool bypass = false )
171
- {
172
- _path = path ;
173
- _bypass = bypass ;
174
- }
175
-
176
- public bool IsOptionSet ( string optionName ) => throw new NotImplementedException ( ) ;
177
-
178
- public bool TryGetOptionArgumentList ( string optionName , [ NotNullWhen ( true ) ] out string [ ] ? arguments )
179
- {
180
- arguments = null ;
181
- if ( _bypass )
182
- {
183
- return false ;
184
- }
185
-
186
- switch ( optionName )
187
- {
188
- case PlatformCommandLineProvider . ResultDirectoryOptionKey :
189
- arguments = [ _path ] ;
190
- return true ;
191
- default :
192
- return false ;
193
- }
194
- }
195
- }
0 commit comments