@@ -339,8 +339,11 @@ public void Delete_WhereRecurseIsFalse_CallsApiCorrectly()
339339#endif
340340 }
341341
342- [ TestMethod , TestCategory ( TestCategories . Success ) ]
343- public void Delete_WhereRecurseIsTrueAndDirectoryIsNonempty_CallsApiCorrectly ( )
342+ public static IEnumerable < object [ ] > ConfigFindFilesData
343+ => new object [ ] [ ] { new object [ ] { true } , new object [ ] { false } } ;
344+
345+ [ DataTestMethod , TestCategory ( TestCategories . Success ) , DynamicData ( nameof ( ConfigFindFilesData ) ) ]
346+ public void Delete_WhereRecurseIsTrueAndDirectoryIsNonempty_CallsApiCorrectly ( bool supportsPatternSearch )
344347 {
345348 var fixture = DokanOperationsFixture . Instance ;
346349
@@ -353,15 +356,31 @@ public void Delete_WhereRecurseIsTrueAndDirectoryIsNonempty_CallsApiCorrectly()
353356 fixture . ExpectCreateFile ( path , ReadAttributesAccess , ReadWriteShare , FileMode . Open ) ;
354357 fixture . ExpectGetFileInformation ( path , FileAttributes . Directory ) ;
355358 fixture . ExpectOpenDirectory ( path ) ;
356- fixture . ExpectFindFilesWithPattern ( path , "*" , DokanOperationsFixture . GetEmptyDirectoryDefaultFiles ( ) . Concat ( new [ ]
357- {
359+ if ( supportsPatternSearch )
360+ {
361+ fixture . ExpectFindFilesWithPattern ( path , "*" , DokanOperationsFixture . GetEmptyDirectoryDefaultFiles ( ) . Concat ( new [ ]
362+ {
358363 new FileInformation ( )
359364 {
360365 FileName = subFileName , Attributes = FileAttributes . Normal ,
361366 Length = 100 ,
362367 CreationTime = DateTime . Today , LastWriteTime = DateTime . Today , LastAccessTime = DateTime . Today
363368 }
364369 } ) . ToArray ( ) ) ;
370+ }
371+ else
372+ {
373+ fixture . ExpectFindFilesWithPatternToFail ( path , "*" , DokanResult . NotImplemented ) ;
374+ fixture . ExpectFindFiles ( path , DokanOperationsFixture . GetEmptyDirectoryDefaultFiles ( ) . Concat ( new [ ]
375+ {
376+ new FileInformation ( )
377+ {
378+ FileName = subFileName , Attributes = FileAttributes . Normal ,
379+ Length = 100 ,
380+ CreationTime = DateTime . Today , LastWriteTime = DateTime . Today , LastAccessTime = DateTime . Today
381+ }
382+ } ) . ToArray ( ) ) ;
383+ }
365384 fixture . ExpectCreateFile ( path + subFilePath , DeleteAccess , ReadWriteShare , FileMode . Open , deleteOnClose : true ) ;
366385 fixture . ExpectGetFileInformation ( path + subFilePath , FileAttributes . Normal ) ;
367386 fixture . ExpectDeleteFile ( path + subFilePath ) ;
@@ -378,8 +397,8 @@ public void Delete_WhereRecurseIsTrueAndDirectoryIsNonempty_CallsApiCorrectly()
378397#endif
379398 }
380399
381- [ TestMethod , TestCategory ( TestCategories . Success ) ]
382- public void Delete_WhereRecurseIsTrueAndDirectoryIsEmpty_CallsApiCorrectly ( )
400+ [ DataTestMethod , TestCategory ( TestCategories . Success ) , DynamicData ( nameof ( ConfigFindFilesData ) ) ]
401+ public void Delete_WhereRecurseIsTrueAndDirectoryIsEmpty_CallsApiCorrectly ( bool supportsPatternSearch )
383402 {
384403 var fixture = DokanOperationsFixture . Instance ;
385404
@@ -390,7 +409,15 @@ public void Delete_WhereRecurseIsTrueAndDirectoryIsEmpty_CallsApiCorrectly()
390409 fixture . ExpectCreateFile ( path , ReadAttributesAccess , ReadWriteShare , FileMode . Open ) ;
391410 fixture . ExpectGetFileInformation ( path , FileAttributes . Directory ) ;
392411 fixture . ExpectOpenDirectory ( path ) ;
393- fixture . ExpectFindFilesWithPattern ( path , "*" , DokanOperationsFixture . GetEmptyDirectoryDefaultFiles ( ) ) ;
412+ if ( supportsPatternSearch )
413+ {
414+ fixture . ExpectFindFilesWithPattern ( path , "*" , DokanOperationsFixture . GetEmptyDirectoryDefaultFiles ( ) ) ;
415+ }
416+ else
417+ {
418+ fixture . ExpectFindFilesWithPatternToFail ( path , "*" , DokanResult . NotImplemented ) ;
419+ fixture . ExpectFindFiles ( path , DokanOperationsFixture . GetEmptyDirectoryDefaultFiles ( ) ) ;
420+ }
394421 fixture . ExpectOpenDirectory ( path , DeleteFromDirectoryAccess ) ;
395422 fixture . ExpectDeleteDirectory ( path ) ;
396423#endif
@@ -433,8 +460,7 @@ public void GetAccessControl_CallsApiCorrectly()
433460#endif
434461 }
435462
436- [ TestMethod , TestCategory ( TestCategories . Success ) ]
437- public void GetDirectories_OnRootDirectory_WithPatternSearch_CallsApiCorrectly ( )
463+ private void GetDirectories_OnRootDirectory_CallsApiCorrectly ( bool supportsPatternSearch )
438464 {
439465 var fixture = DokanOperationsFixture . Instance ;
440466
@@ -443,7 +469,15 @@ public void GetDirectories_OnRootDirectory_WithPatternSearch_CallsApiCorrectly()
443469 fixture . PermitAny ( ) ;
444470#else
445471 fixture . ExpectOpenDirectory ( path ) ;
446- fixture . ExpectFindFilesWithPattern ( path , "*" , fixture . RootDirectoryItems ) ;
472+ if ( supportsPatternSearch )
473+ {
474+ fixture . ExpectFindFilesWithPattern ( path , "*" , fixture . RootDirectoryItems ) ;
475+ }
476+ else
477+ {
478+ fixture . ExpectFindFilesWithPatternToFail ( path , "*" , DokanResult . NotImplemented ) ;
479+ fixture . ExpectFindFiles ( path , fixture . RootDirectoryItems ) ;
480+ }
447481
448482#endif
449483
@@ -464,9 +498,21 @@ public void GetDirectories_OnRootDirectory_WithPatternSearch_CallsApiCorrectly()
464498#endif
465499 }
466500
467- [ SuppressMessage ( "Microsoft.Naming" , "CA1702:CompoundWordsShouldBeCasedCorrectly" , MessageId = "SubDirectory" ) ]
468501 [ TestMethod , TestCategory ( TestCategories . Success ) ]
469- public void GetDirectories_OnSubDirectory_CallsApiCorrectly ( )
502+ public void GetDirectories_OnRootDirectory_WithPatternSearch_CallsApiCorrectly ( )
503+ {
504+ GetDirectories_OnRootDirectory_CallsApiCorrectly ( true ) ;
505+ }
506+
507+ [ TestMethod , TestCategory ( TestCategories . Success ) , TestCategory ( TestCategories . NoPatternSearch ) ]
508+ public void GetDirectories_OnRootDirectory_WithoutPatternSearch_CallsApiCorrectly ( )
509+ {
510+ GetDirectories_OnRootDirectory_CallsApiCorrectly ( false ) ;
511+ }
512+
513+ [ SuppressMessage ( "Microsoft.Naming" , "CA1702:CompoundWordsShouldBeCasedCorrectly" , MessageId = "SubDirectory" ) ]
514+ [ DataTestMethod , TestCategory ( TestCategories . Success ) , DynamicData ( nameof ( ConfigFindFilesData ) ) ]
515+ public void GetDirectories_OnSubDirectory_CallsApiCorrectly ( bool supportsPatternSearch )
470516 {
471517 var fixture = DokanOperationsFixture . Instance ;
472518
@@ -475,7 +521,15 @@ public void GetDirectories_OnSubDirectory_CallsApiCorrectly()
475521 fixture . PermitAny ( ) ;
476522#else
477523 fixture . ExpectOpenDirectory ( path ) ;
478- fixture . ExpectFindFilesWithPattern ( path , "*" , fixture . DirectoryItems ) ;
524+ if ( supportsPatternSearch )
525+ {
526+ fixture . ExpectFindFilesWithPattern ( path , "*" , fixture . DirectoryItems ) ;
527+ }
528+ else
529+ {
530+ fixture . ExpectFindFilesWithPatternToFail ( path , "*" , DokanResult . NotImplemented ) ;
531+ fixture . ExpectFindFiles ( path , fixture . DirectoryItems ) ;
532+ }
479533#endif
480534
481535 var sut = new DirectoryInfo ( fixture . DirectoryName . AsDriveBasedPath ( ) ) ;
@@ -528,8 +582,8 @@ public void GetDirectoriesWithFilter_OnRootDirectory_CallsApiCorrectly()
528582#endif
529583 }
530584
531- [ TestMethod , TestCategory ( TestCategories . Success ) ]
532- public void GetFiles_OnRootDirectory_CallsApiCorrectly ( )
585+ [ DataTestMethod , TestCategory ( TestCategories . Success ) , DynamicData ( nameof ( ConfigFindFilesData ) ) ]
586+ public void GetFiles_OnRootDirectory_CallsApiCorrectly ( bool supportsPatternSearch )
533587 {
534588 var fixture = DokanOperationsFixture . Instance ;
535589
@@ -538,7 +592,15 @@ public void GetFiles_OnRootDirectory_CallsApiCorrectly()
538592 fixture . PermitAny ( ) ;
539593#else
540594 fixture . ExpectOpenDirectory ( path ) ;
541- fixture . ExpectFindFilesWithPattern ( path , "*" , fixture . RootDirectoryItems ) ;
595+ if ( supportsPatternSearch )
596+ {
597+ fixture . ExpectFindFilesWithPattern ( path , "*" , fixture . RootDirectoryItems ) ;
598+ }
599+ else
600+ {
601+ fixture . ExpectFindFilesWithPatternToFail ( path , "*" , DokanResult . NotImplemented ) ;
602+ fixture . ExpectFindFiles ( path , fixture . RootDirectoryItems ) ;
603+ }
542604#endif
543605
544606 var sut = new DirectoryInfo ( DokanOperationsFixture . RootName . AsDriveBasedPath ( ) ) ;
@@ -559,8 +621,8 @@ public void GetFiles_OnRootDirectory_CallsApiCorrectly()
559621 }
560622
561623 [ SuppressMessage ( "Microsoft.Naming" , "CA1702:CompoundWordsShouldBeCasedCorrectly" , MessageId = "SubDirectory" ) ]
562- [ TestMethod , TestCategory ( TestCategories . Success ) ]
563- public void GetFiles_OnSubDirectory_CallsApiCorrectly ( )
624+ [ DataTestMethod , TestCategory ( TestCategories . Success ) , DynamicData ( nameof ( ConfigFindFilesData ) ) ]
625+ public void GetFiles_OnSubDirectory_CallsApiCorrectly ( bool supportsPatternSearch )
564626 {
565627 var fixture = DokanOperationsFixture . Instance ;
566628
@@ -569,7 +631,15 @@ public void GetFiles_OnSubDirectory_CallsApiCorrectly()
569631 fixture . PermitAny ( ) ;
570632#else
571633 fixture . ExpectOpenDirectory ( path ) ;
572- fixture . ExpectFindFilesWithPattern ( path , "*" , fixture . DirectoryItems ) ;
634+ if ( supportsPatternSearch )
635+ {
636+ fixture . ExpectFindFilesWithPattern ( path , "*" , fixture . DirectoryItems ) ;
637+ }
638+ else
639+ {
640+ fixture . ExpectFindFilesWithPatternToFail ( path , "*" , DokanResult . NotImplemented ) ;
641+ fixture . ExpectFindFiles ( path , fixture . DirectoryItems ) ;
642+ }
573643#endif
574644
575645 var sut = new DirectoryInfo ( fixture . DirectoryName . AsDriveBasedPath ( ) ) ;
@@ -622,8 +692,8 @@ public void GetFilesWithFilter_OnRootDirectory_CallsApiCorrectly()
622692 }
623693
624694 [ SuppressMessage ( "Microsoft.Naming" , "CA1702:CompoundWordsShouldBeCasedCorrectly" , MessageId = "SubDirectory" ) ]
625- [ TestMethod , TestCategory ( TestCategories . Success ) ]
626- public void GetFiles_UnknownDates_CallsApiCorrectly ( )
695+ [ DataTestMethod , TestCategory ( TestCategories . Success ) , DynamicData ( nameof ( ConfigFindFilesData ) ) ]
696+ public void GetFiles_UnknownDates_CallsApiCorrectly ( bool supportsPatternSearch )
627697 {
628698 var fixture = DokanOperationsFixture . Instance ;
629699
@@ -635,7 +705,15 @@ public void GetFiles_UnknownDates_CallsApiCorrectly()
635705 //Remove all dates
636706 var files = DokanOperationsFixture . RemoveDatesFromFileInformations ( fixture . DirectoryItems ) ;
637707
638- fixture . ExpectFindFilesWithPattern ( path , "*" , files ) ;
708+ if ( supportsPatternSearch )
709+ {
710+ fixture . ExpectFindFilesWithPattern ( path , "*" , files ) ;
711+ }
712+ else
713+ {
714+ fixture . ExpectFindFilesWithPatternToFail ( path , "*" , DokanResult . NotImplemented ) ;
715+ fixture . ExpectFindFiles ( path , files ) ;
716+ }
639717#endif
640718
641719 var sut = new DirectoryInfo ( fixture . DirectoryName . AsDriveBasedPath ( ) ) ;
@@ -673,8 +751,8 @@ public void GetFiles_UnknownDates_CallsApiCorrectly()
673751#endif
674752 }
675753
676- [ TestMethod , TestCategory ( TestCategories . Success ) ]
677- public void GetFileSystemInfos_OnRootDirectory_CallsApiCorrectly ( )
754+ [ DataTestMethod , TestCategory ( TestCategories . Success ) , DynamicData ( nameof ( ConfigFindFilesData ) ) ]
755+ public void GetFileSystemInfos_OnRootDirectory_CallsApiCorrectly ( bool supportsPatternSearch )
678756 {
679757 var fixture = DokanOperationsFixture . Instance ;
680758
@@ -683,7 +761,15 @@ public void GetFileSystemInfos_OnRootDirectory_CallsApiCorrectly()
683761 fixture . PermitAny ( ) ;
684762#else
685763 fixture . ExpectOpenDirectory ( path ) ;
686- fixture . ExpectFindFilesWithPattern ( path , "*" , fixture . RootDirectoryItems ) ;
764+ if ( supportsPatternSearch )
765+ {
766+ fixture . ExpectFindFilesWithPattern ( path , "*" , fixture . RootDirectoryItems ) ;
767+ }
768+ else
769+ {
770+ fixture . ExpectFindFilesWithPatternToFail ( path , "*" , DokanResult . NotImplemented ) ;
771+ fixture . ExpectFindFiles ( path , fixture . RootDirectoryItems ) ;
772+ }
687773#endif
688774
689775 var sut = new DirectoryInfo ( DokanOperationsFixture . RootName . AsDriveBasedPath ( ) ) ;
@@ -702,8 +788,8 @@ public void GetFileSystemInfos_OnRootDirectory_CallsApiCorrectly()
702788 }
703789
704790 [ SuppressMessage ( "Microsoft.Naming" , "CA1702:CompoundWordsShouldBeCasedCorrectly" , MessageId = "SubDirectory" ) ]
705- [ TestMethod , TestCategory ( TestCategories . Success ) ]
706- public void GetFileSystemInfos_OnSubDirectory_CallsApiCorrectly ( )
791+ [ DataTestMethod , TestCategory ( TestCategories . Success ) , DynamicData ( nameof ( ConfigFindFilesData ) ) ]
792+ public void GetFileSystemInfos_OnSubDirectory_CallsApiCorrectly ( bool supportsPatternSearch )
707793 {
708794 var fixture = DokanOperationsFixture . Instance ;
709795
@@ -712,7 +798,15 @@ public void GetFileSystemInfos_OnSubDirectory_CallsApiCorrectly()
712798 fixture . PermitAny ( ) ;
713799#else
714800 fixture . ExpectOpenDirectory ( path ) ;
715- fixture . ExpectFindFilesWithPattern ( path , "*" , fixture . DirectoryItems ) ;
801+ if ( supportsPatternSearch )
802+ {
803+ fixture . ExpectFindFilesWithPattern ( path , "*" , fixture . DirectoryItems ) ;
804+ }
805+ else
806+ {
807+ fixture . ExpectFindFilesWithPatternToFail ( path , "*" , DokanResult . NotImplemented ) ;
808+ fixture . ExpectFindFiles ( path , fixture . DirectoryItems ) ;
809+ }
716810#endif
717811
718812 var sut = new DirectoryInfo ( fixture . DirectoryName . AsDriveBasedPath ( ) ) ;
@@ -760,8 +854,8 @@ public void GetFileSystemInfosWithFilter_OnRootDirectory_CallsApiCorrectly()
760854#endif
761855 }
762856
763- [ TestMethod , TestCategory ( TestCategories . Success ) ]
764- public void GetFileSystemInfos_OnRootDirectory_WhereSearchOptionIsAllDirectories_CallsApiCorrectly ( )
857+ [ DataTestMethod , TestCategory ( TestCategories . Success ) , DynamicData ( nameof ( ConfigFindFilesData ) ) ]
858+ public void GetFileSystemInfos_OnRootDirectory_WhereSearchOptionIsAllDirectories_CallsApiCorrectly ( bool supportsPatternSearch )
765859 {
766860 var fixture = DokanOperationsFixture . Instance ;
767861
@@ -779,7 +873,15 @@ public void GetFileSystemInfos_OnRootDirectory_WhereSearchOptionIsAllDirectories
779873 foreach ( var pathAndItem in pathsAndItems )
780874 {
781875 fixture . ExpectOpenDirectory ( pathAndItem . Path ) ;
782- fixture . ExpectFindFilesWithPattern ( pathAndItem . Path , "*" , pathAndItem . Items ) ;
876+ if ( supportsPatternSearch )
877+ {
878+ fixture . ExpectFindFilesWithPattern ( pathAndItem . Path , "*" , pathAndItem . Items ) ;
879+ }
880+ else
881+ {
882+ fixture . ExpectFindFilesWithPatternToFail ( pathAndItem . Path , "*" , DokanResult . NotImplemented ) ;
883+ fixture . ExpectFindFiles ( pathAndItem . Path , pathAndItem . Items ) ;
884+ }
783885 }
784886#endif
785887
@@ -905,8 +1007,8 @@ public void MoveTo_WhereTargetExists_Throws()
9051007#endif
9061008 }
9071009
908- [ TestMethod , TestCategory ( TestCategories . Success ) ]
909- public void SetAccessControl_CallsApiCorrectly ( )
1010+ [ DataTestMethod , TestCategory ( TestCategories . Success ) , DynamicData ( nameof ( ConfigFindFilesData ) ) ]
1011+ public void SetAccessControl_CallsApiCorrectly ( bool supportsPatternSearch )
9101012 {
9111013 var fixture = DokanOperationsFixture . Instance ;
9121014
@@ -922,7 +1024,15 @@ public void SetAccessControl_CallsApiCorrectly()
9221024 fixture . ExpectGetFileInformation ( path . AsRootedPath ( ) , FileAttributes . Directory ) ;
9231025 fixture . ExpectGetFileSecurity ( path . AsRootedPath ( ) , DokanOperationsFixture . DefaultDirectorySecurity ) ;
9241026 fixture . ExpectOpenDirectory ( path . AsRootedPath ( ) , share : FileShare . ReadWrite ) ;
925- fixture . ExpectFindFiles ( path . AsRootedPath ( ) , new FileInformation [ 0 ] ) ;
1027+ if ( supportsPatternSearch )
1028+ {
1029+ fixture . ExpectFindFilesWithPattern ( path . AsRootedPath ( ) , "*" , new FileInformation [ 0 ] ) ;
1030+ }
1031+ else
1032+ {
1033+ fixture . ExpectFindFilesWithPatternToFail ( path . AsRootedPath ( ) , "*" , DokanResult . NotImplemented ) ;
1034+ fixture . ExpectFindFiles ( path . AsRootedPath ( ) , new FileInformation [ 0 ] ) ;
1035+ }
9261036 fixture . ExpectSetFileSecurity ( path . AsRootedPath ( ) , security ) ;
9271037 fixture . ExpectCreateFile ( DokanOperationsFixture . RootName , ReadPermissionsAccess , ReadWriteShare , FileMode . Open ) ;
9281038 fixture . ExpectGetFileInformation ( DokanOperationsFixture . RootName , FileAttributes . Directory ) ;
0 commit comments