File tree 3 files changed +18
-14
lines changed
Source/Testably.Abstractions.Testing/Helpers
Tests/Testably.Abstractions.Tests/FileSystem/Path
3 files changed +18
-14
lines changed Original file line number Diff line number Diff line change 1
- using System . Linq ;
2
-
3
- namespace Testably . Abstractions . Testing . Helpers ;
1
+ namespace Testably . Abstractions . Testing . Helpers ;
4
2
5
3
internal partial class Execute
6
4
{
7
5
private sealed class MacPath ( MockFileSystem fileSystem ) : LinuxPath ( fileSystem )
8
6
{
9
- private readonly MockFileSystem _fileSystem = fileSystem ;
10
-
11
7
private string ? _tempPath ;
12
8
13
9
/// <inheritdoc cref="IPath.GetTempPath()" />
@@ -16,12 +12,5 @@ public override string GetTempPath()
16
12
_tempPath ??= $ "/var/folders/{ RandomString ( 2 ) } /{ RandomString ( 2 ) } _{ RandomString ( 27 ) } /T/";
17
13
return _tempPath ;
18
14
}
19
-
20
- private string RandomString ( int length )
21
- {
22
- const string chars = "abcdefghijklmnopqrstuvwxyz0123456789" ;
23
- return new string ( Enumerable . Repeat ( chars , length )
24
- . Select ( s => s [ _fileSystem . RandomSystem . Random . Shared . Next ( s . Length ) ] ) . ToArray ( ) ) ;
25
- }
26
15
}
27
16
}
Original file line number Diff line number Diff line change 1
1
using System ;
2
- using System . Diagnostics ;
3
2
using System . Diagnostics . CodeAnalysis ;
3
+ using System . Linq ;
4
4
using System . Text ;
5
5
#if FEATURE_FILESYSTEM_NET7
6
6
using Testably . Abstractions . Testing . Storage ;
@@ -283,7 +283,7 @@ public ReadOnlySpan<char> GetPathRoot(ReadOnlySpan<char> path)
283
283
284
284
/// <inheritdoc cref="IPath.GetRandomFileName()" />
285
285
public string GetRandomFileName ( )
286
- => System . IO . Path . GetRandomFileName ( ) ;
286
+ => $ " { RandomString ( 8 ) } . { RandomString ( 3 ) } " ;
287
287
288
288
#if FEATURE_PATH_RELATIVE
289
289
/// <inheritdoc cref="IPath.GetRelativePath(string, string)" />
@@ -489,6 +489,13 @@ private string JoinInternal(string?[] paths)
489
489
}
490
490
#endif
491
491
492
+ protected string RandomString ( int length )
493
+ {
494
+ const string chars = "abcdefghijklmnopqrstuvwxyz0123456789" ;
495
+ return new string ( Enumerable . Repeat ( chars , length )
496
+ . Select ( s => s [ fileSystem . RandomSystem . Random . Shared . Next ( s . Length ) ] ) . ToArray ( ) ) ;
497
+ }
498
+
492
499
private bool TryGetExtensionIndex ( string path , [ NotNullWhen ( true ) ] out int ? dotIndex )
493
500
{
494
501
for ( int i = path . Length - 1 ; i >= 0 ; i -- )
Original file line number Diff line number Diff line change @@ -8,6 +8,14 @@ public abstract partial class GetRandomFileNameTests<TFileSystem>
8
8
: FileSystemTestBase < TFileSystem >
9
9
where TFileSystem : IFileSystem
10
10
{
11
+ [ SkippableFact ]
12
+ public void GetRandomFileName_ShouldMatch8Dot3Pattern ( )
13
+ {
14
+ string result = FileSystem . Path . GetRandomFileName ( ) ;
15
+
16
+ result . Should ( ) . Match ( "????????.???" ) ;
17
+ }
18
+
11
19
[ SkippableFact ]
12
20
public void GetRandomFileName_ShouldReturnRandomFileNameWithExtension ( )
13
21
{
You can’t perform that action at this time.
0 commit comments