public void AssembliesNull_Should_Throws()
        {
            var services           = new ServiceCollection();
            var myLifetimeRegistry = new MyLifetimeRegistry();

            myLifetimeRegistry.AutoRegister(services, null);
        }
 public void TestInitialize()
 {
     services           = new ServiceCollection();
     myLifetimeRegistry = new MyLifetimeRegistry();
     myLifetimeRegistry.AutoRegister(services, new[] {
         typeof(MyLifetimeRegistrySpec).Assembly
     });
     provider = services.BuildServiceProvider();
 }
        public void TestCleanup()
        {
            var lifetimeRegisterInfoCache = myLifetimeRegistry.Cache;
            var classTypeInfos            = lifetimeRegisterInfoCache.ToClassTypeInfos().Where(x => x.Name.StartsWith("Foo")).ToList();

            foreach (var classTypeInfo in classTypeInfos)
            {
                classTypeInfo.ToJson(true).Log();
            }
            myLifetimeRegistry = null;
        }
        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);
            }
        }
        public void ServicesNull_Should_Throws()
        {
            var myLifetimeRegistry = new MyLifetimeRegistry();

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