Hi,
I some of my tests i inject a dependency by MEF with :
Code:
// In My TestClass
[AssemblyInitialize]
public static void InitializeAssembly(TestContext testContext)
{
// Add Task scheduler DAL assembly for MEF injection.
Bootstrapper.ConfigureAggregateCatalog(new AssemblyCatalog(typeof(CommandManager).Assembly));
Bootstrapper.ConfigureAggregateCatalog(new AssemblyCatalog(typeof(CommandAdapterDataAccessMock).Assembly));
// Configures recomposition container using MEF
Bootstrapper.ConfigureContainer();
}
...
// In the tested class.
[Import]
private IIngestionDataAccessFactory factory;
public DataIngestionService()
{
Bootstrapper.SatisfyImportsOnce(this); // -> Boum
}
If i run all the test in VS, all are green, in MsTest, all green but in NCrunch i get a composition Error:
System.ComponentModel.Composition.CompositionException: The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.
1) More than one export was found that matches the constraint:
ContractName Itesoft.ProductionManager.DataIngestion.Contracts.IIngestionDataAccessFactory
RequiredTypeIdentity Itesoft.ProductionManager.DataIngestion.Contracts.IIngestionDataAccessFactory
Resulting in: Cannot set import 'Itesoft.ProductionManager.DataIngestion.BLL.DataIngestionService.factory (ContractName="Itesoft.ProductionManager.DataIngestion.Contracts.IIngestionDataAccessFactory")' on part 'Itesoft.ProductionManager.DataIngestion.BLL.DataIngestionService'.
Element: Itesoft.ProductionManager.DataIngestion.BLL.DataIngestionService.factory (ContractName="Itesoft.ProductionManager.DataIngestion.Contracts.IIngestionDataAccessFactory") --> Itesoft.ProductionManager.DataIngestion.BLL.DataIngestionService
It 's seemed that several MEF exports are injected in the Container but only when they are runned in ncrunch. Is the handling of the AssemblyInitializeAttribute is different with NCrunch ?
If I run the test one by one in ncrunch, they are all ok, if i run all the tests at a time with 'Run test in new task runnerProcess' they are all KO.
How can i have more informations on what's happen ?
Thanks in advance
CConnes