@@ -177,7 +177,7 @@ public override string[] GetDirectories(string path, string searchPattern, Searc
177177#if FEATURE_ENUMERATION_OPTIONS
178178 public override string [ ] GetDirectories ( string path , string searchPattern , EnumerationOptions enumerationOptions )
179179 {
180- return GetDirectories ( path , "*" , enumerationOptions . RecurseSubdirectories ? SearchOption . AllDirectories : SearchOption . TopDirectoryOnly ) ;
180+ return GetDirectories ( path , "*" , EnumerationOptionsToSearchOption ( enumerationOptions ) ) ;
181181 }
182182#endif
183183
@@ -206,7 +206,7 @@ public override string[] GetFiles(string path, string searchPattern, SearchOptio
206206#if FEATURE_ENUMERATION_OPTIONS
207207 public override string [ ] GetFiles ( string path , string searchPattern , EnumerationOptions enumerationOptions )
208208 {
209- return GetFiles ( path , "*" , enumerationOptions . RecurseSubdirectories ? SearchOption . AllDirectories : SearchOption . TopDirectoryOnly ) ;
209+ return GetFiles ( path , "*" , EnumerationOptionsToSearchOption ( enumerationOptions ) ) ;
210210 }
211211#endif
212212
@@ -638,5 +638,42 @@ private string ReplaceLastOccurrence(string source, string find, string replace)
638638 var result = source . Remove ( place , find . Length ) . Insert ( place , replace ) ;
639639 return result ;
640640 }
641+
642+ #if FEATURE_ENUMERATION_OPTIONS
643+ private SearchOption EnumerationOptionsToSearchOption ( EnumerationOptions enumerationOptions )
644+ {
645+ static Exception CreateExceptionForUnsupportedProperty ( string propertyName )
646+ {
647+ return new NotSupportedException (
648+ $ "Changing EnumerationOptions.{ propertyName } is not yet implemented for the mock file system."
649+ ) ;
650+ }
651+
652+ if ( enumerationOptions . AttributesToSkip != ( FileAttributes . System | FileAttributes . Hidden ) )
653+ {
654+ throw CreateExceptionForUnsupportedProperty ( "AttributesToSkip" ) ;
655+ }
656+ if ( ! enumerationOptions . IgnoreInaccessible )
657+ {
658+ throw CreateExceptionForUnsupportedProperty ( "IgnoreInaccessible" ) ;
659+ }
660+ if ( enumerationOptions . MatchCasing != MatchCasing . PlatformDefault )
661+ {
662+ throw CreateExceptionForUnsupportedProperty ( "MatchCasing" ) ;
663+ }
664+ if ( enumerationOptions . MatchType != MatchType . Simple )
665+ {
666+ throw CreateExceptionForUnsupportedProperty ( "MatchType" ) ;
667+ }
668+ if ( enumerationOptions . ReturnSpecialDirectories )
669+ {
670+ throw CreateExceptionForUnsupportedProperty ( "ReturnSpecialDirectories" ) ;
671+ }
672+
673+ return enumerationOptions . RecurseSubdirectories
674+ ? SearchOption . AllDirectories
675+ : SearchOption . TopDirectoryOnly ;
676+ }
677+ #endif
641678 }
642679}
0 commit comments