public void GetExportFactories_With_A_Predicate_Should_Return_Filtered_Results() { //Arrange var catalog = new AggregateCatalog( new DirectoryCatalog("."), new AssemblyCatalog(Assembly.GetExecutingAssembly())); var container = new CompositionContainer(new AssemblyCatalog(Assembly.GetAssembly(typeof(TestMefExtensionHelpers)))); //Act var myAObjects = container.GetExportFactories<MyObjectBaseClass, MyMetadataAttribute>(attribute => attribute.Category == "A"); var myBObjects = container.GetExportFactories<MyObjectBaseClass, MyMetadataAttribute>(attribute => attribute.Category == "B"); var myAObjectWithNameTwo = container.GetExportFactories<MyObjectBaseClass, MyMetadataAttribute>(attribute => attribute.Category == "A" && attribute.Name == "Two"); //Assert Assert.Equal(2, myAObjects.Count()); Assert.Equal(1, myBObjects.Count()); Assert.Equal(1, myAObjectWithNameTwo.Count()); //And let's check that we can create a bunch of objects from a factory Assert.NotNull(myBObjects.First().Create()); Assert.NotNull(myBObjects.First().Create()); Assert.NotNull(myBObjects.First().Create()); Assert.NotNull(myBObjects.First().Create()); //A different change. }