File tree Expand file tree Collapse file tree 5 files changed +28
-18
lines changed
Source/Testably.Abstractions.Testing/FileSystem
Tests/Testably.Abstractions.Tests Expand file tree Collapse file tree 5 files changed +28
-18
lines changed Original file line number Diff line number Diff line change 3232 " CodeAnalysisEnd" ,
3333 " CodeCoverage" ,
3434 " Compile" ,
35+ " DotNetFrameworkUnitTests" ,
3536 " DotNetUnitTests" ,
3637 " MutationComment" ,
3738 " MutationTestPreparation" ,
Original file line number Diff line number Diff line change 3737 <ItemGroup >
3838 <PackageVersion Include =" AutoFixture.AutoNSubstitute" Version =" 5.0.0-preview0012" />
3939 <PackageVersion Include =" AutoFixture.Xunit3" Version =" 5.0.0-preview0012" />
40- <PackageVersion Include =" aweXpect" Version =" 0.17 .0" />
40+ <PackageVersion Include =" aweXpect" Version =" 0.20 .0" />
4141 <PackageVersion Include =" aweXpect.Testably" Version =" 0.3.0" />
4242 <PackageVersion Include =" FluentAssertions" Version =" 7.0.0" />
4343 <PackageVersion Include =" Microsoft.NET.Test.Sdk" Version =" 17.12.0" />
Original file line number Diff line number Diff line change @@ -78,7 +78,10 @@ public void CreateAsSymbolicLink(string pathToTarget)
7878
7979 FullName . EnsureValidFormat ( _fileSystem ) ;
8080 pathToTarget . ThrowCommonExceptionsIfPathToTargetIsInvalid ( _fileSystem ) ;
81- if ( _fileSystem . Storage . TryAddContainer ( Location , InMemoryContainer . NewFile ,
81+ if ( _fileSystem . Storage . TryAddContainer ( Location ,
82+ FileSystemType == FileSystemTypes . Directory
83+ ? InMemoryContainer . NewDirectory
84+ : InMemoryContainer . NewFile ,
8285 out IStorageContainer ? container ) )
8386 {
8487 Container = container ;
Original file line number Diff line number Diff line change @@ -74,22 +74,6 @@ public void Delete_Recursive_MissingDirectory_ShouldThrowDirectoryNotFoundExcept
7474 hResult : - 2147024893 ) ;
7575 }
7676
77- [ Theory ]
78- [ AutoData ]
79- public void Delete_WhenFile_ShouldThrowIOException (
80- string directoryName )
81- {
82- FileSystem . File . WriteAllText ( directoryName , "" ) ;
83- string expectedPath = FileSystem . Path . Combine ( BasePath , directoryName ) ;
84- Exception ? exception = Record . Exception ( ( ) =>
85- {
86- FileSystem . Directory . Delete ( directoryName , true ) ;
87- } ) ;
88-
89- exception . Should ( ) . BeException < IOException > ( $ "The directory name is invalid*{ expectedPath } ",
90- hResult : - 2147024629 ) ;
91- }
92-
9377 [ Theory ]
9478 [ AutoData ]
9579 public void Delete_Recursive_WithFileInSubdirectory_ShouldDeleteDirectoryWithContent (
@@ -228,6 +212,24 @@ public void Delete_ShouldDeleteDirectory(string directoryName)
228212 result . Should ( ) . NotExist ( ) ;
229213 }
230214
215+ [ Theory ]
216+ [ AutoData ]
217+ public async Task Delete_WhenFile_ShouldThrowIOException (
218+ string directoryName )
219+ {
220+ FileSystem . File . WriteAllText ( directoryName , "" ) ;
221+ string expectedPath = FileSystem . Path . Combine ( BasePath , directoryName ) ;
222+
223+ void Act ( )
224+ {
225+ FileSystem . Directory . Delete ( directoryName , true ) ;
226+ }
227+
228+ await That ( Act ) . Throws < IOException > ( )
229+ . WithMessage ( $ "*The directory name is invalid*{ expectedPath } *") . AsWildcard ( ) . And
230+ . WithHResult ( Test . IsNetFramework ? - 2146232800 : - 2147024629 ) ;
231+ }
232+
231233 [ Theory ]
232234 [ AutoData ]
233235 public void Delete_WithSimilarNamedFile_ShouldOnlyDeleteDirectory (
Original file line number Diff line number Diff line change 22global using FluentAssertions ;
33global using System ;
44global using System . IO . Abstractions ;
5+ global using System . Threading . Tasks ;
56global using Testably . Abstractions . FileSystem ;
67global using Testably . Abstractions . FluentAssertions ;
78global using Testably . Abstractions . Testing ;
89global using Testably . Abstractions . TestHelpers ;
910global using Testably . Abstractions . Tests . TestHelpers ;
1011global using Xunit ;
12+ global using aweXpect ;
13+ global using static aweXpect . Expect ;
14+ global using Skip = Testably . Abstractions . TestHelpers . Skip ;
1115#if NET48
1216global using Testably . Abstractions . Polyfills ;
1317#else
You can’t perform that action at this time.
0 commit comments