Beispiel #1
0
        public void ShouldLoadSomeServicesFromExecutingAssembly_CheckRegistrationByServiceType_LoadByType()
        {
            var services = new Microsoft.Extensions.DependencyInjection.ServiceCollection();

            services.AddAutoRegister(typeof(ServiceCollectionProviderTests));
            var provider       = services.BuildServiceProvider();
            var resolveService = provider.GetService <ISecondClass>();

            Assert.NotNull(resolveService);
            Assert.IsAssignableFrom <ISecondClass>(resolveService);
        }
Beispiel #2
0
        public void ShouldLoadSomeServicesFromExecutingAssembly_CheckRegistrationByImplementation_LoadByAssembly()
        {
            var services = new Microsoft.Extensions.DependencyInjection.ServiceCollection();

            services.AddAutoRegister(Assembly.GetAssembly(typeof(ServiceCollectionProviderTests)));
            var provider       = services.BuildServiceProvider();
            var resolveService = provider.GetService <FirstClass>();

            Assert.NotNull(resolveService);
            Assert.IsType <FirstClass>(resolveService);
        }