11using System . IO . Abstractions ;
22using GitVersion . Configuration ;
33using GitVersion . Core . Tests . Helpers ;
4+ using GitVersion . Extensions ;
45using GitVersion . Helpers ;
56using GitVersion . Logging ;
67using GitVersion . VersionCalculation ;
@@ -18,11 +19,7 @@ public class ArgumentParserTests : TestBase
1819 [ SetUp ]
1920 public void SetUp ( )
2021 {
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 ( ) ) ) ;
2623 this . environment = sp . GetRequiredService < IEnvironment > ( ) ;
2724 this . argumentParser = sp . GetRequiredService < IArgumentParser > ( ) ;
2825 this . fileSystem = sp . GetRequiredService < IFileSystem > ( ) ;
@@ -283,91 +280,91 @@ public void UpdateAssemblyInfoWithFilename()
283280 {
284281 using var repo = new EmptyRepositoryFixture ( ) ;
285282
286- var assemblyFile = PathHelper . Combine ( repo . RepositoryPath , "CommonAssemblyInfo.cs" ) ;
283+ var assemblyFile = FileSystemHelper . Path . Combine ( repo . RepositoryPath , "CommonAssemblyInfo.cs" ) ;
287284 using var file = this . fileSystem . File . Create ( assemblyFile ) ;
288285
289286 var arguments = this . argumentParser . ParseArguments ( $ "-targetpath { repo . RepositoryPath } -updateAssemblyInfo CommonAssemblyInfo.cs") ;
290287 arguments . UpdateAssemblyInfo . ShouldBe ( true ) ;
291288 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" ) ) ;
293290 }
294291
295292 [ Test ]
296293 public void UpdateAssemblyInfoWithMultipleFilenames ( )
297294 {
298295 using var repo = new EmptyRepositoryFixture ( ) ;
299296
300- var assemblyFile1 = PathHelper . Combine ( repo . RepositoryPath , "CommonAssemblyInfo.cs" ) ;
297+ var assemblyFile1 = FileSystemHelper . Path . Combine ( repo . RepositoryPath , "CommonAssemblyInfo.cs" ) ;
301298 using var file = this . fileSystem . File . Create ( assemblyFile1 ) ;
302299
303- var assemblyFile2 = PathHelper . Combine ( repo . RepositoryPath , "VersionAssemblyInfo.cs" ) ;
300+ var assemblyFile2 = FileSystemHelper . Path . Combine ( repo . RepositoryPath , "VersionAssemblyInfo.cs" ) ;
304301 using var file2 = this . fileSystem . File . Create ( assemblyFile2 ) ;
305302
306303 var arguments = this . argumentParser . ParseArguments ( $ "-targetpath { repo . RepositoryPath } -updateAssemblyInfo CommonAssemblyInfo.cs VersionAssemblyInfo.cs") ;
307304 arguments . UpdateAssemblyInfo . ShouldBe ( true ) ;
308305 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" ) ) ;
311308 }
312309
313310 [ Test ]
314311 public void UpdateProjectFilesWithMultipleFilenames ( )
315312 {
316313 using var repo = new EmptyRepositoryFixture ( ) ;
317314
318- var assemblyFile1 = PathHelper . Combine ( repo . RepositoryPath , "CommonAssemblyInfo.csproj" ) ;
315+ var assemblyFile1 = FileSystemHelper . Path . Combine ( repo . RepositoryPath , "CommonAssemblyInfo.csproj" ) ;
319316 using var file = this . fileSystem . File . Create ( assemblyFile1 ) ;
320317
321- var assemblyFile2 = PathHelper . Combine ( repo . RepositoryPath , "VersionAssemblyInfo.csproj" ) ;
318+ var assemblyFile2 = FileSystemHelper . Path . Combine ( repo . RepositoryPath , "VersionAssemblyInfo.csproj" ) ;
322319 using var file2 = this . fileSystem . File . Create ( assemblyFile2 ) ;
323320
324321 var arguments = this . argumentParser . ParseArguments ( $ "-targetpath { repo . RepositoryPath } -updateProjectFiles CommonAssemblyInfo.csproj VersionAssemblyInfo.csproj") ;
325322 arguments . UpdateProjectFiles . ShouldBe ( true ) ;
326323 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" ) ) ;
329326 }
330327
331328 [ Test ]
332329 public void UpdateAssemblyInfoWithMultipleFilenamesMatchingGlobbing ( )
333330 {
334331 using var repo = new EmptyRepositoryFixture ( ) ;
335332
336- var assemblyFile1 = PathHelper . Combine ( repo . RepositoryPath , "CommonAssemblyInfo.cs" ) ;
333+ var assemblyFile1 = FileSystemHelper . Path . Combine ( repo . RepositoryPath , "CommonAssemblyInfo.cs" ) ;
337334 using var file = this . fileSystem . File . Create ( assemblyFile1 ) ;
338335
339- var assemblyFile2 = PathHelper . Combine ( repo . RepositoryPath , "VersionAssemblyInfo.cs" ) ;
336+ var assemblyFile2 = FileSystemHelper . Path . Combine ( repo . RepositoryPath , "VersionAssemblyInfo.cs" ) ;
340337 using var file2 = this . fileSystem . File . Create ( assemblyFile2 ) ;
341338
342- var subdir = PathHelper . Combine ( repo . RepositoryPath , "subdir" ) ;
339+ var subdir = FileSystemHelper . Path . Combine ( repo . RepositoryPath , "subdir" ) ;
343340
344341 this . fileSystem . Directory . CreateDirectory ( subdir ) ;
345- var assemblyFile3 = PathHelper . Combine ( subdir , "LocalAssemblyInfo.cs" ) ;
342+ var assemblyFile3 = FileSystemHelper . Path . Combine ( subdir , "LocalAssemblyInfo.cs" ) ;
346343 using var file3 = this . fileSystem . File . Create ( assemblyFile3 ) ;
347344
348345 var arguments = this . argumentParser . ParseArguments ( $ "-targetpath { repo . RepositoryPath } -updateAssemblyInfo **/*AssemblyInfo.cs") ;
349346 arguments . UpdateAssemblyInfo . ShouldBe ( true ) ;
350347 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" ) ) ;
354351 }
355352
356353 [ Test ]
357354 public void UpdateAssemblyInfoWithRelativeFilename ( )
358355 {
359356 using var repo = new EmptyRepositoryFixture ( ) ;
360357
361- var assemblyFile = PathHelper . Combine ( repo . RepositoryPath , "CommonAssemblyInfo.cs" ) ;
358+ var assemblyFile = FileSystemHelper . Path . Combine ( repo . RepositoryPath , "CommonAssemblyInfo.cs" ) ;
362359 using var file = this . fileSystem . File . Create ( assemblyFile ) ;
363360
364- var targetPath = PathHelper . Combine ( repo . RepositoryPath , "subdir1" , "subdir2" ) ;
361+ var targetPath = FileSystemHelper . Path . Combine ( repo . RepositoryPath , "subdir1" , "subdir2" ) ;
365362 this . fileSystem . Directory . CreateDirectory ( targetPath ) ;
366363
367364 var arguments = this . argumentParser . ParseArguments ( $ "-targetpath { targetPath } -updateAssemblyInfo ..\\ ..\\ CommonAssemblyInfo.cs") ;
368365 arguments . UpdateAssemblyInfo . ShouldBe ( true ) ;
369366 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" ) ) ;
371368 }
372369
373370 [ Test ]
@@ -765,7 +762,7 @@ public void ThrowIfConfigurationFileDoesNotExist(string configFile) =>
765762 [ Test ]
766763 public void EnsureConfigurationFileIsSet ( )
767764 {
768- var configFile = PathHelper . GetTempPath ( ) + Guid . NewGuid ( ) + ".yaml" ;
765+ var configFile = FileSystemHelper . Path . GetTempPath ( ) + Guid . NewGuid ( ) + ".yaml" ;
769766 this . fileSystem . File . WriteAllText ( configFile , "next-version: 1.0.0" ) ;
770767 var arguments = this . argumentParser . ParseArguments ( $ "-config { configFile } ") ;
771768 arguments . ConfigurationFile . ShouldBe ( configFile ) ;
0 commit comments