David Smith

David Smith

  • NA
  • 2k
  • 0

MEF CompositionContainer Unit Test

Nov 4 2021 3:16 AM

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);