public void GetServicesReturnsEmptyEnumerableForUnregisteredService()
        {
            var container = new ContainerBuilder().Build();
            var resolver = new AutofacWebApiDependencyResolver(container);

            var services = resolver.GetServices(typeof(object));

            Assert.Equal(0, services.Count());
        }
Esempio n. 2
0
        public void GetServicesReturnsEmptyEnumerableForUnregisteredService()
        {
            var container = new ContainerBuilder().Build();
            var resolver  = new AutofacWebApiDependencyResolver(container);

            var services = resolver.GetServices(typeof(object));

            Assert.Empty(services);
        }
        public void GetServicesReturnsRegisteredService()
        {
            var builder = new ContainerBuilder();
            builder.Register(c => new object());
            var container = builder.Build();
            var resolver = new AutofacWebApiDependencyResolver(container);

            var services = resolver.GetServices(typeof(object));

            Assert.Equal(1, services.Count());
        }
Esempio n. 4
0
        public void GetServicesReturnsRegisteredService()
        {
            var builder = new ContainerBuilder();

            builder.Register(c => new object());
            var container = builder.Build();
            var resolver  = new AutofacWebApiDependencyResolver(container);

            var services = resolver.GetServices(typeof(object));

            Assert.Single(services);
        }
Esempio n. 5
0
        public void BeginScopeUsesConfigurationActionIfAny()
        {
            var builder = new ContainerBuilder();

            builder.Register(c => new object());
            var container       = builder.Build();
            var resolver        = new AutofacWebApiDependencyResolver(container, containerBuilder => containerBuilder.Register(c => new object()));
            var services        = resolver.GetServices(typeof(object));
            var servicesInScope = resolver.BeginScope().GetServices(typeof(object));

            Assert.NotEqual(services.Count(), servicesInScope.Count());
        }
Esempio n. 6
0
        public void GetServicesReturnsRegisteredServices()
        {
            var builder = new ContainerBuilder();

            builder.Register(c => new object());
            builder.Register(c => new object());
            var container = builder.Build();
            var resolver  = new AutofacWebApiDependencyResolver(container);

            var services = resolver.GetServices(typeof(object));

            Assert.That(services.Count(), Is.EqualTo(2));
        }
 public IEnumerable <object> GetServices(Type serviceType)
 {
     return(_autofacWebApiDependencyResolver.GetServices(serviceType));
 }
Esempio n. 8
0
 /// <see cref="IDependencyResolver.GetServices"/>
 public IEnumerable <object> GetServices(Type serviceType)
 {
     return(_resolver.GetServices(serviceType));
 }