File tree Expand file tree Collapse file tree 3 files changed +15
-2
lines changed
src/TestableIO.System.IO.Abstractions.TestingHelpers
tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ public override IFileSystemInfo ResolveLinkTarget(bool returnFinalTarget)
8282 public override FileAttributes Attributes
8383 {
8484 get { return GetMockFileDataForRead ( ) . Attributes ; }
85- set { GetMockFileDataForWrite ( ) . Attributes = value ; }
85+ set { GetMockFileDataForWrite ( ) . Attributes = value | FileAttributes . Directory ; }
8686 }
8787
8888 /// <inheritdoc />
Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ public override FileAttributes Attributes
6666 set
6767 {
6868 var mockFileData = GetMockFileDataForWrite ( ) ;
69- mockFileData . Attributes = value ;
69+ mockFileData . Attributes = value & ~ FileAttributes . Directory ;
7070 }
7171 }
7272
Original file line number Diff line number Diff line change @@ -66,6 +66,19 @@ public void MockDirectoryInfo_Attributes_ShouldReturnMinusOneForNonExistingFile(
6666 Assert . That ( directoryInfo . Attributes , Is . EqualTo ( expected ) ) ;
6767 }
6868
69+ [ Test ]
70+ public void MockDirectoryInfo_Attributes_Clear_ShouldRemainDirectory ( )
71+ {
72+ var fileSystem = new MockFileSystem ( ) ;
73+ var path = XFS . Path ( @"c:\existing\directory" ) ;
74+ fileSystem . Directory . CreateDirectory ( path ) ;
75+ var directoryInfo = fileSystem . DirectoryInfo . New ( path ) ;
76+ directoryInfo . Attributes = 0 ;
77+
78+ Assert . That ( fileSystem . File . Exists ( path ) , Is . False ) ;
79+ Assert . That ( directoryInfo . Attributes , Is . EqualTo ( FileAttributes . Directory ) ) ;
80+ }
81+
6982 [ Test ]
7083 public void MockDirectoryInfo_Attributes_SetterShouldThrowDirectoryNotFoundExceptionOnNonExistingFileOrDirectory ( )
7184 {
You can’t perform that action at this time.
0 commit comments