예제 #1
0
        public void AssembliesNull_Should_Throws()
        {
            var services           = new ServiceCollection();
            var myLifetimeRegistry = new MyLifetimeRegistry();

            myLifetimeRegistry.AutoRegister(services, null);
        }
예제 #2
0
 public void TestInitialize()
 {
     services           = new ServiceCollection();
     myLifetimeRegistry = new MyLifetimeRegistry();
     myLifetimeRegistry.AutoRegister(services, new[] {
         typeof(MyLifetimeRegistrySpec).Assembly
     });
     provider = services.BuildServiceProvider();
 }
예제 #3
0
        public void RegisterAfter_Should_Replace()
        {
            var services = new ServiceCollection();

            var myLifetimesHelper = new MyLifetimeRegistry();

            myLifetimesHelper.AutoRegister(services, new[] {
                typeof(IMyLifetime).Assembly,
                typeof(MyLifetimeRegistrySpec).Assembly
            });

            services.AddSingleton <FooTransient>();
            var newProvider = services.BuildServiceProvider();

            using (var scope = newProvider.CreateScope())
            {
                var theFoo  = scope.ServiceProvider.GetService <FooTransient>();
                var theFoo2 = scope.ServiceProvider.GetService <FooTransient>();
                Assert.AreSame(theFoo, theFoo2);
            }
        }
예제 #4
0
 public void AssembliesNull_Should_Throws()
 {
     myLifetimeRegistry.AutoRegister(services, null);
 }
예제 #5
0
        public void ServicesNull_Should_Throws()
        {
            var myLifetimeRegistry = new MyLifetimeRegistry();

            myLifetimeRegistry.AutoRegister(null, new List <Assembly>());
        }