public void AutofacInstanceCountDepScopedTest() { CountableAutofacComponent.ResetInstanceCount(); IAutofacContainer container = ConfigureAutofacThenMef(); var childContainer = container.BeginLifetimeScope(); var countableDep = childContainer.Resolve <IDependOnCountableAutofac>(); Assert.AreEqual(1, countableDep.Component.InstanceCount); }
public void ResolveAutofacFromMefByCtorWithScopeTest() { IAutofacContainer container = ConfigureAutofacThenMef(); var autofacComponent = container.Resolve <IAutofacComponent>(); container = container.BeginLifetimeScope(); var builder = new ContainerBuilder(); builder.RegisterInstance(autofacComponent); builder.Update(container.ComponentRegistry); var component = container.Resolve <IMefDependingOnAutofac>(); Assert.IsNotNull(component); Assert.IsNotNull(component.AutofacComponent); Assert.AreEqual(autofacComponent, component.AutofacComponent); }
public void ResolveAutofacFromMefByPropWithScope2Test() { IAutofacContainer container = ConfigureMefThenAutofac(); var autofacComponent = container.Resolve <IAutofacComponent>(); container = container.BeginLifetimeScope(); container.EnableCompositionIntegration(); var builder = new ContainerBuilder(); builder.RegisterInstance(autofacComponent); builder.Update(container.ComponentRegistry); var component = container.Resolve <IMefDependingOnAutofac2>(); Assert.IsNotNull(component); Assert.IsNotNull(component.AutofacComponent); Assert.AreEqual(autofacComponent, component.AutofacComponent); }