private void RegisterScenarioContainer(TinyIoCContainer container, IMockFactory mockFactory) { if (mockFactory.GetType() == typeof(NullMockFactory)) { container.Register <IContainer>((c, p) => new TinyContainer(c.GetChildContainer())); this.Log() .DebugFormat("Registered {ScenarioContainer} for IContainer", "TinyContainer"); } else { container.Register <IContainer>((c, p) => new TinyMockingContainer(mockFactory, c.GetChildContainer())); this.Log() .DebugFormat("Registered {ScenarioContainer} for IContainer with mock factory {MockFactory}", "TinyMockingContainer", mockFactory.MockProviderName); } }
private static void RegisterScenarioContainer(ContainerBuilder builder, IMockFactory mockFactory) { if (mockFactory.GetType() == typeof(NullMockFactory)) { builder.Register <IContainer>(c => new AutofacContainer(c.Resolve <ILifetimeScope>().BeginLifetimeScope())); nameof(ContainerBuilderExtensions).Log().DebugFormat("Registered {ScenarioContainer} for IContainer", "TinyContainer"); } else { builder.RegisterSource(new AnyConcreteTypeNotAlreadyRegisteredSource()); builder.RegisterSource(new AutofacMockRegistrationHandler(mockFactory)); builder.Register <IContainer>(c => new AutofacContainer(c.Resolve <ILifetimeScope>().BeginLifetimeScope())); nameof(ContainerBuilderExtensions).Log().DebugFormat("Registered {ScenarioContainer} for IContainer with mock factory {MockFactory}", "TinyMockingContainer", mockFactory.MockProviderName); } }