11namespace System . IO . Abstractions . TestingHelpers . Tests
22{
3- using NUnit . Framework ;
3+ using System . Collections . Generic ;
4+ using NUnit . Framework ;
45
56 using XFS = MockUnixSupport ;
67
@@ -10,7 +11,7 @@ public class MockFileDeleteTests
1011 public void MockFile_Delete_ShouldDeleteFile ( )
1112 {
1213 var fileSystem = new MockFileSystem ( ) ;
13- var path = XFS . Path ( "C:\\ test" ) ;
14+ var path = XFS . Path ( "C:\\ some_folder \\ test" ) ;
1415 var directory = fileSystem . Path . GetDirectoryName ( path ) ;
1516 fileSystem . AddFile ( path , new MockFileData ( "Bla" ) ) ;
1617
@@ -35,5 +36,28 @@ public void MockFile_Delete_ShouldThrowArgumentExceptionIfPathContainsOnlyWhites
3536 // Assert
3637 Assert . Throws < ArgumentException > ( action ) ;
3738 }
39+
40+ [ Test ]
41+ public void MockFile_Delete_ShouldThrowDirectoryNotFoundExceptionIfParentFolderAbsent ( )
42+ {
43+ var fileSystem = new MockFileSystem ( ) ;
44+ var path = XFS . Path ( "C:\\ test\\ somefile.txt" ) ;
45+
46+ Assert . Throws < DirectoryNotFoundException > ( ( ) => fileSystem . File . Delete ( path ) ) ;
47+ }
48+
49+ [ Test ]
50+ public void MockFile_Delete_ShouldSilentlyReturnIfNonExistingFileInExistingFolder ( )
51+ {
52+ var fileSystem = new MockFileSystem ( new Dictionary < string , MockFileData > ( )
53+ {
54+ { XFS . Path ( "C:\\ temp\\ exist.txt" ) , new MockFileData ( "foobar" ) } ,
55+ } ) ;
56+
57+ string filePath = XFS . Path ( "C:\\ temp\\ somefile.txt" ) ;
58+
59+ // Delete() returns void, so there is nothing to check here beside absense of an exception
60+ Assert . DoesNotThrow ( ( ) => fileSystem . File . Delete ( filePath ) ) ;
61+ }
3862 }
3963}
0 commit comments