Esempio n. 1
0
        public void CreateServiceProvider()
        {
            var builder = new ContainerBuilder();

            builder.RegisterType <TestProxiedService>().As <IProxiedService>();
            var factory = new AutofacServiceProviderFactory();

            Should.Throw <ArgumentNullException>(() => factory.CreateServiceProvider(null));
            factory.CreateServiceProvider(builder).GetService <IProxiedService>().ShouldBeOfType <TestProxiedService>();
        }
Esempio n. 2
0
        public void CreateBuilder()
        {
            var services = new ServiceCollection();

            services.AddSingleton(Substitute.For <IModuleContainer>());
            services.AddTransient <IProxiedService, TestProxiedService>();
            var factory = new AutofacServiceProviderFactory();

            Should.Throw <ArgumentNullException>(() => factory.CreateBuilder(null));
            factory.CreateBuilder(services).Build().Resolve <IProxiedService>().ShouldBeOfType <TestProxiedService>();
        }