public void AddAutoMapperExtensionTransientWithAssemblySingleDelegateArgCollection() { using var container = new Container(); container.Options.DefaultScopedLifestyle = new ThreadScopedLifestyle(); // act container.AddAutoMapper( cfg => cfg.AsTransient()); var serviceDescriptor = container.GetCurrentRegistrations() .FirstOrDefault(r => r.ServiceType == typeof(IMapper)); // assert using (new AssertionScope()) { serviceDescriptor.Should().NotBeNull(); // ReSharper disable once PossibleNullReferenceException serviceDescriptor !.Lifestyle.Should().Be(Lifestyle.Transient); } }
public void AddAutoMapperExtensionDefaultWithAssemblyCollection() { // arrange using var container = new Container(); container.Options.DefaultScopedLifestyle = new ThreadScopedLifestyle(); // act container.AddAutoMapper(typeof(ServiceLifetimeTests).GetTypeInfo().Assembly); var serviceDescriptor = container.GetCurrentRegistrations() .FirstOrDefault(r => r.ServiceType == typeof(IMapper)); // assert using (new AssertionScope()) { serviceDescriptor.Should().NotBeNull(); // ReSharper disable once PossibleNullReferenceException serviceDescriptor !.Lifestyle.Should().Be(Lifestyle.Singleton); } }