@@ -42,6 +42,62 @@ public async Task CanInitializeWithCriteria()
4242 Assert . Equal ( 2 , pluginCount ) ;
4343 }
4444
45+ [ Fact ]
46+ public async Task CanUseFolderOptions ( )
47+ {
48+ var options = new FolderPluginCatalogOptions
49+ {
50+ TypeFinderOptions = new TypeFinderOptions ( )
51+ {
52+ TypeFinderCriterias = new List < TypeFinderCriteria > ( )
53+ {
54+ TypeFinderCriteriaBuilder
55+ . Create ( )
56+ . HasName ( "SecondPlugin" )
57+ . Tag ( "MyPlugin" ) ,
58+ }
59+ }
60+ } ;
61+
62+ var catalog = new FolderPluginCatalog ( _pluginFolder , options ) ;
63+
64+ await catalog . Initialize ( ) ;
65+
66+ var pluginCount = catalog . GetPlugins ( ) . Count ;
67+
68+ Assert . Equal ( 1 , pluginCount ) ;
69+ Assert . Equal ( "SecondPlugin" , catalog . Single ( ) . Type . Name ) ;
70+ }
71+
72+ [ Fact ]
73+ public async Task FolderOptionsAreUsedToLimitLoadedAssemblies ( )
74+ {
75+ var options = new FolderPluginCatalogOptions
76+ {
77+ TypeFinderOptions = new TypeFinderOptions ( )
78+ {
79+ TypeFinderCriterias = new List < TypeFinderCriteria > ( )
80+ {
81+ TypeFinderCriteriaBuilder
82+ . Create ( )
83+ . HasName ( "SecondPlugin" )
84+ . Tag ( "MyPlugin" ) ,
85+ }
86+ }
87+ } ;
88+
89+ var catalog = new FolderPluginCatalog ( _pluginFolder , options ) ;
90+
91+ await catalog . Initialize ( ) ;
92+
93+ var field = catalog . GetType ( ) . GetField ( "_catalogs" , BindingFlags . Instance | BindingFlags . NonPublic ) ;
94+ // ReSharper disable once PossibleNullReferenceException
95+ var loadedAssemblies = ( List < AssemblyPluginCatalog > ) field . GetValue ( catalog ) ;
96+
97+ // ReSharper disable once AssignNullToNotNullAttribute
98+ Assert . Single ( loadedAssemblies ) ;
99+ }
100+
45101 [ Fact ]
46102 public async Task CanConfigureNamingOptions ( )
47103 {
@@ -61,9 +117,6 @@ public async Task CanConfigureNamingOptions()
61117 }
62118 }
63119
64-
65-
66-
67120 [ Fact ]
68121 public async Task CanUseReferencedDependencies ( )
69122 {
@@ -124,7 +177,7 @@ public async Task CanUseSelectedHoststDependencies()
124177 Assert . Equal ( "3.1.2.0" , loggerVersion ) ;
125178 Assert . Equal ( "9.0.0.0" , oldPluginVersion ) ;
126179 }
127-
180+
128181 [ Collection ( nameof ( NotThreadSafeResourceCollection ) ) ]
129182 public class DefaultOptions : IDisposable
130183 {
@@ -149,15 +202,15 @@ public async Task CanConfigureDefaultNamingOptions()
149202 Assert . EndsWith ( "Modified" , plugin . Name ) ;
150203 }
151204 }
152-
205+
153206 [ Fact ]
154207 public async Task DefaultAssemblyNamingOptionsDoesntAffectFolderCatalogs ( )
155208 {
156209 AssemblyPluginCatalogOptions . Defaults . PluginNameOptions = new PluginNameOptions ( )
157210 {
158211 PluginNameGenerator = ( nameOptions , type ) => type . FullName + "ModifiedAssembly"
159212 } ;
160-
213+
161214 var catalog = new FolderPluginCatalog ( _pluginFolder ) ;
162215 await catalog . Initialize ( ) ;
163216
@@ -168,7 +221,7 @@ public async Task DefaultAssemblyNamingOptionsDoesntAffectFolderCatalogs()
168221 Assert . False ( plugin . Name . EndsWith ( "ModifiedAssembly" ) ) ;
169222 }
170223 }
171-
224+
172225 public void Dispose ( )
173226 {
174227 AssemblyPluginCatalogOptions . Defaults . PluginNameOptions = new PluginNameOptions ( ) ;
0 commit comments