1
1
using System . IO . Abstractions ;
2
2
using GitVersion . Configuration ;
3
3
using GitVersion . Core . Tests . Helpers ;
4
+ using GitVersion . Extensions ;
4
5
using GitVersion . Helpers ;
5
6
using GitVersion . Logging ;
6
7
using GitVersion . VersionCalculation ;
@@ -18,11 +19,7 @@ public class ArgumentParserTests : TestBase
18
19
[ SetUp ]
19
20
public void SetUp ( )
20
21
{
21
- var sp = ConfigureServices ( services =>
22
- {
23
- services . AddSingleton < IArgumentParser , ArgumentParser > ( ) ;
24
- services . AddSingleton < IGlobbingResolver , GlobbingResolver > ( ) ;
25
- } ) ;
22
+ var sp = ConfigureServices ( services => services . AddModule ( new GitVersionAppModule ( ) ) ) ;
26
23
this . environment = sp . GetRequiredService < IEnvironment > ( ) ;
27
24
this . argumentParser = sp . GetRequiredService < IArgumentParser > ( ) ;
28
25
this . fileSystem = sp . GetRequiredService < IFileSystem > ( ) ;
@@ -283,91 +280,91 @@ public void UpdateAssemblyInfoWithFilename()
283
280
{
284
281
using var repo = new EmptyRepositoryFixture ( ) ;
285
282
286
- var assemblyFile = PathHelper . Combine ( repo . RepositoryPath , "CommonAssemblyInfo.cs" ) ;
283
+ var assemblyFile = FileSystemHelper . Path . Combine ( repo . RepositoryPath , "CommonAssemblyInfo.cs" ) ;
287
284
using var file = this . fileSystem . File . Create ( assemblyFile ) ;
288
285
289
286
var arguments = this . argumentParser . ParseArguments ( $ "-targetpath { repo . RepositoryPath } -updateAssemblyInfo CommonAssemblyInfo.cs") ;
290
287
arguments . UpdateAssemblyInfo . ShouldBe ( true ) ;
291
288
arguments . UpdateAssemblyInfoFileName . Count . ShouldBe ( 1 ) ;
292
- arguments . UpdateAssemblyInfoFileName . ShouldContain ( x => PathHelper . GetFileName ( x ) . Equals ( "CommonAssemblyInfo.cs" ) ) ;
289
+ arguments . UpdateAssemblyInfoFileName . ShouldContain ( x => FileSystemHelper . Path . GetFileName ( x ) . Equals ( "CommonAssemblyInfo.cs" ) ) ;
293
290
}
294
291
295
292
[ Test ]
296
293
public void UpdateAssemblyInfoWithMultipleFilenames ( )
297
294
{
298
295
using var repo = new EmptyRepositoryFixture ( ) ;
299
296
300
- var assemblyFile1 = PathHelper . Combine ( repo . RepositoryPath , "CommonAssemblyInfo.cs" ) ;
297
+ var assemblyFile1 = FileSystemHelper . Path . Combine ( repo . RepositoryPath , "CommonAssemblyInfo.cs" ) ;
301
298
using var file = this . fileSystem . File . Create ( assemblyFile1 ) ;
302
299
303
- var assemblyFile2 = PathHelper . Combine ( repo . RepositoryPath , "VersionAssemblyInfo.cs" ) ;
300
+ var assemblyFile2 = FileSystemHelper . Path . Combine ( repo . RepositoryPath , "VersionAssemblyInfo.cs" ) ;
304
301
using var file2 = this . fileSystem . File . Create ( assemblyFile2 ) ;
305
302
306
303
var arguments = this . argumentParser . ParseArguments ( $ "-targetpath { repo . RepositoryPath } -updateAssemblyInfo CommonAssemblyInfo.cs VersionAssemblyInfo.cs") ;
307
304
arguments . UpdateAssemblyInfo . ShouldBe ( true ) ;
308
305
arguments . UpdateAssemblyInfoFileName . Count . ShouldBe ( 2 ) ;
309
- arguments . UpdateAssemblyInfoFileName . ShouldContain ( x => PathHelper . GetFileName ( x ) . Equals ( "CommonAssemblyInfo.cs" ) ) ;
310
- arguments . UpdateAssemblyInfoFileName . ShouldContain ( x => PathHelper . GetFileName ( x ) . Equals ( "VersionAssemblyInfo.cs" ) ) ;
306
+ arguments . UpdateAssemblyInfoFileName . ShouldContain ( x => FileSystemHelper . Path . GetFileName ( x ) . Equals ( "CommonAssemblyInfo.cs" ) ) ;
307
+ arguments . UpdateAssemblyInfoFileName . ShouldContain ( x => FileSystemHelper . Path . GetFileName ( x ) . Equals ( "VersionAssemblyInfo.cs" ) ) ;
311
308
}
312
309
313
310
[ Test ]
314
311
public void UpdateProjectFilesWithMultipleFilenames ( )
315
312
{
316
313
using var repo = new EmptyRepositoryFixture ( ) ;
317
314
318
- var assemblyFile1 = PathHelper . Combine ( repo . RepositoryPath , "CommonAssemblyInfo.csproj" ) ;
315
+ var assemblyFile1 = FileSystemHelper . Path . Combine ( repo . RepositoryPath , "CommonAssemblyInfo.csproj" ) ;
319
316
using var file = this . fileSystem . File . Create ( assemblyFile1 ) ;
320
317
321
- var assemblyFile2 = PathHelper . Combine ( repo . RepositoryPath , "VersionAssemblyInfo.csproj" ) ;
318
+ var assemblyFile2 = FileSystemHelper . Path . Combine ( repo . RepositoryPath , "VersionAssemblyInfo.csproj" ) ;
322
319
using var file2 = this . fileSystem . File . Create ( assemblyFile2 ) ;
323
320
324
321
var arguments = this . argumentParser . ParseArguments ( $ "-targetpath { repo . RepositoryPath } -updateProjectFiles CommonAssemblyInfo.csproj VersionAssemblyInfo.csproj") ;
325
322
arguments . UpdateProjectFiles . ShouldBe ( true ) ;
326
323
arguments . UpdateAssemblyInfoFileName . Count . ShouldBe ( 2 ) ;
327
- arguments . UpdateAssemblyInfoFileName . ShouldContain ( x => PathHelper . GetFileName ( x ) . Equals ( "CommonAssemblyInfo.csproj" ) ) ;
328
- arguments . UpdateAssemblyInfoFileName . ShouldContain ( x => PathHelper . GetFileName ( x ) . Equals ( "VersionAssemblyInfo.csproj" ) ) ;
324
+ arguments . UpdateAssemblyInfoFileName . ShouldContain ( x => FileSystemHelper . Path . GetFileName ( x ) . Equals ( "CommonAssemblyInfo.csproj" ) ) ;
325
+ arguments . UpdateAssemblyInfoFileName . ShouldContain ( x => FileSystemHelper . Path . GetFileName ( x ) . Equals ( "VersionAssemblyInfo.csproj" ) ) ;
329
326
}
330
327
331
328
[ Test ]
332
329
public void UpdateAssemblyInfoWithMultipleFilenamesMatchingGlobbing ( )
333
330
{
334
331
using var repo = new EmptyRepositoryFixture ( ) ;
335
332
336
- var assemblyFile1 = PathHelper . Combine ( repo . RepositoryPath , "CommonAssemblyInfo.cs" ) ;
333
+ var assemblyFile1 = FileSystemHelper . Path . Combine ( repo . RepositoryPath , "CommonAssemblyInfo.cs" ) ;
337
334
using var file = this . fileSystem . File . Create ( assemblyFile1 ) ;
338
335
339
- var assemblyFile2 = PathHelper . Combine ( repo . RepositoryPath , "VersionAssemblyInfo.cs" ) ;
336
+ var assemblyFile2 = FileSystemHelper . Path . Combine ( repo . RepositoryPath , "VersionAssemblyInfo.cs" ) ;
340
337
using var file2 = this . fileSystem . File . Create ( assemblyFile2 ) ;
341
338
342
- var subdir = PathHelper . Combine ( repo . RepositoryPath , "subdir" ) ;
339
+ var subdir = FileSystemHelper . Path . Combine ( repo . RepositoryPath , "subdir" ) ;
343
340
344
341
this . fileSystem . Directory . CreateDirectory ( subdir ) ;
345
- var assemblyFile3 = PathHelper . Combine ( subdir , "LocalAssemblyInfo.cs" ) ;
342
+ var assemblyFile3 = FileSystemHelper . Path . Combine ( subdir , "LocalAssemblyInfo.cs" ) ;
346
343
using var file3 = this . fileSystem . File . Create ( assemblyFile3 ) ;
347
344
348
345
var arguments = this . argumentParser . ParseArguments ( $ "-targetpath { repo . RepositoryPath } -updateAssemblyInfo **/*AssemblyInfo.cs") ;
349
346
arguments . UpdateAssemblyInfo . ShouldBe ( true ) ;
350
347
arguments . UpdateAssemblyInfoFileName . Count . ShouldBe ( 3 ) ;
351
- arguments . UpdateAssemblyInfoFileName . ShouldContain ( x => PathHelper . GetFileName ( x ) . Equals ( "CommonAssemblyInfo.cs" ) ) ;
352
- arguments . UpdateAssemblyInfoFileName . ShouldContain ( x => PathHelper . GetFileName ( x ) . Equals ( "VersionAssemblyInfo.cs" ) ) ;
353
- arguments . UpdateAssemblyInfoFileName . ShouldContain ( x => PathHelper . GetFileName ( x ) . Equals ( "LocalAssemblyInfo.cs" ) ) ;
348
+ arguments . UpdateAssemblyInfoFileName . ShouldContain ( x => FileSystemHelper . Path . GetFileName ( x ) . Equals ( "CommonAssemblyInfo.cs" ) ) ;
349
+ arguments . UpdateAssemblyInfoFileName . ShouldContain ( x => FileSystemHelper . Path . GetFileName ( x ) . Equals ( "VersionAssemblyInfo.cs" ) ) ;
350
+ arguments . UpdateAssemblyInfoFileName . ShouldContain ( x => FileSystemHelper . Path . GetFileName ( x ) . Equals ( "LocalAssemblyInfo.cs" ) ) ;
354
351
}
355
352
356
353
[ Test ]
357
354
public void UpdateAssemblyInfoWithRelativeFilename ( )
358
355
{
359
356
using var repo = new EmptyRepositoryFixture ( ) ;
360
357
361
- var assemblyFile = PathHelper . Combine ( repo . RepositoryPath , "CommonAssemblyInfo.cs" ) ;
358
+ var assemblyFile = FileSystemHelper . Path . Combine ( repo . RepositoryPath , "CommonAssemblyInfo.cs" ) ;
362
359
using var file = this . fileSystem . File . Create ( assemblyFile ) ;
363
360
364
- var targetPath = PathHelper . Combine ( repo . RepositoryPath , "subdir1" , "subdir2" ) ;
361
+ var targetPath = FileSystemHelper . Path . Combine ( repo . RepositoryPath , "subdir1" , "subdir2" ) ;
365
362
this . fileSystem . Directory . CreateDirectory ( targetPath ) ;
366
363
367
364
var arguments = this . argumentParser . ParseArguments ( $ "-targetpath { targetPath } -updateAssemblyInfo ..\\ ..\\ CommonAssemblyInfo.cs") ;
368
365
arguments . UpdateAssemblyInfo . ShouldBe ( true ) ;
369
366
arguments . UpdateAssemblyInfoFileName . Count . ShouldBe ( 1 ) ;
370
- arguments . UpdateAssemblyInfoFileName . ShouldContain ( x => PathHelper . GetFileName ( x ) . Equals ( "CommonAssemblyInfo.cs" ) ) ;
367
+ arguments . UpdateAssemblyInfoFileName . ShouldContain ( x => FileSystemHelper . Path . GetFileName ( x ) . Equals ( "CommonAssemblyInfo.cs" ) ) ;
371
368
}
372
369
373
370
[ Test ]
@@ -765,7 +762,7 @@ public void ThrowIfConfigurationFileDoesNotExist(string configFile) =>
765
762
[ Test ]
766
763
public void EnsureConfigurationFileIsSet ( )
767
764
{
768
- var configFile = PathHelper . GetTempPath ( ) + Guid . NewGuid ( ) + ".yaml" ;
765
+ var configFile = FileSystemHelper . Path . GetTempPath ( ) + Guid . NewGuid ( ) + ".yaml" ;
769
766
this . fileSystem . File . WriteAllText ( configFile , "next-version: 1.0.0" ) ;
770
767
var arguments = this . argumentParser . ParseArguments ( $ "-config { configFile } ") ;
771
768
arguments . ConfigurationFile . ShouldBe ( configFile ) ;
0 commit comments