0
Answer

MEF CompositionContainer Unit Test

David Smith

David Smith

3y
716
1

Can someone assist me in writing a unit test for the code in orange. I am trying to write a unit test for the CompositionContainer and ComposePart

//An aggregate catalog that combines multiple catalogs

var catalog = new AggregateCatalog();

//Adds all the parts found in the same assembly as the current class

catalog.Catalogs.Add(new AssemblyCatalog(typeof(this).Assembly));

//If parts are placed at some other location then adds that directory path

catalog.Catalogs.Add(new DirectoryCatalog(componentsDirectoryPath));

//Create the CompositionContainer with the parts in the catalog CompositionContainer _container = new CompositionContainer(catalog);

//Fill the imports of this object

this._container.ComposeParts(this);