public static Container GetContainer() { var container = new Container(); var scopedLifestyle = new LifetimeScopeLifestyle(); container.RegisterPersistenceDependencies(scopedLifestyle); container.RegisterModelDependencies(scopedLifestyle); return container; }
public void InstanceProducerLifestyle_ForAScopedRegistration_HasTheExpectedDefaultScopedLifestyle() { // Arrange var expectedLifestyle = new LifetimeScopeLifestyle(); var container = new Container(); container.Options.DefaultScopedLifestyle = expectedLifestyle; container.Register<RealTimeProvider>(Lifestyle.Scoped); InstanceProducer producer = container.GetRegistration(typeof(RealTimeProvider)); // Act Lifestyle actualLifestyle = producer.Lifestyle; // Assert Assert.AreSame(expectedLifestyle, actualLifestyle); }
public void ScopedProxyLifestyleCreateRegistration_Always_WrapsTheScopeOfDefaultScopedLifestyle() { // Arrange var expectedLifestyle = new LifetimeScopeLifestyle(); var container = new Container(); container.Options.DefaultScopedLifestyle = expectedLifestyle; // Act var registration = Lifestyle.Scoped.CreateRegistration(typeof(NullLogger), container); var actualLifestyle = registration.Lifestyle; // Assert Assert.AreSame(expectedLifestyle, actualLifestyle); }