public void AutofacResolver_DoesNot_Resolve_NonRegistered_ContactRepository_Test()
        {
            var builder = new ContainerBuilder();
            var container = builder.Build();

            var resolver = new AutofacResolver(container);
            var instance = resolver.GetService(typeof(IContactRepository));

            Assert.IsNull(instance);
        }
        public void AutofacResolver_Resolves_Registered_ContactRepository_Test()
        {
            var builder = new ContainerBuilder();
            builder.RegisterType<InMemoryContactRepository>().As<IContactRepository>();
            var container = builder.Build();

            var resolver = new AutofacResolver(container);
            var instance = resolver.GetService(typeof(IContactRepository));

            Assert.IsNotNull(instance);
        }
        public void AutofacResolver_Resolves_Registered_Both_Instaces_Of_IContactRepository()
        {
            var builder = new ContainerBuilder();
            builder.RegisterType<InMemoryContactRepository>().As<IContactRepository>();
            builder.RegisterType<FileContactRepository>().As<IContactRepository>();
            var container = builder.Build();

            var config = new HttpConfiguration();
            var resolver = new AutofacResolver(container);

            config.DependencyResolver = resolver;
            var repositories = config.DependencyResolver.GetServices(typeof(IContactRepository));

            repositories.Count().ShouldEqual(2);
        }
        public static void Configure(HttpConfiguration config)
        {
            config.Routes.MapHttpRoute(
                "default", "{controller}/{id}",
                new { id = RouteParameter.Optional });

            var builder = new ContainerBuilder();
            builder.RegisterType<FakeFriendRepository>().As<IFriendRepository>();
            builder.RegisterType<FriendDocumentWriter>().As<ICollectionJsonDocumentWriter<Friend>>();
            builder.RegisterType<FriendDocumentReader>().As<ICollectionJsonDocumentReader<Friend>>();
            builder.RegisterApiControllers(typeof(ServiceConfiguration).Assembly);

            var container = builder.Build();
            var resolver = new WebApiContrib.IoC.Autofac.AutofacResolver(container);
            
            config.DependencyResolver = resolver;
        }