Example #1
0
        public void MefDependencyResolver_DoesNot_Resolve_NonRegistered_ContactRepository_Test()
        {
            var resolver = MefDependencyResolver.CreateWithDefaultConventions(new Assembly[0]);

            var instance = resolver.GetService(typeof(IContactRepository));

            instance.ShouldBeNull();
        }
Example #2
0
        public void MefDependencyResolver_Resolves_Registered_Both_Instaces_Of_IContactRepository_Test()
        {
            var resolver = MefDependencyResolver.CreateWithDefaultConventions(new[] { Assembly.GetAssembly(typeof(IContactRepository)) });

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

            repositories.Count().ShouldEqual(2);
        }
Example #3
0
        public void MefDependencyResolver_Resolves_Registered_ContactRepository_Test()
        {
            var resolver = MefDependencyResolver.CreateWithDefaultConventions(new[] { Assembly.GetAssembly(typeof(IContactRepository)) });

            var instance = resolver.GetService(typeof(IContactRepository));

            instance.ShouldNotBeNull();
        }
Example #4
0
        public void MefDependencyResolver_In_HttpConfig_DoesNot_Resolve_NonRegistered_ContactRepositories_Test()
        {
            var config   = new HttpConfiguration();
            var resolver = MefDependencyResolver.CreateWithDefaultConventions(new Assembly[0]);

            config.DependencyResolver = resolver;

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

            repositories.Count().ShouldEqual(0);
        }
Example #5
0
        public void MefDependencyResolver_In_HttpConfig_DoesNot_Resolve_PipelineType_But_Fallback_To_DefaultResolver_Test()
        {
            var config   = new HttpConfiguration();
            var resolver = MefDependencyResolver.CreateWithDefaultConventions(new Assembly[0]);

            config.DependencyResolver = resolver;

            var instance = config.Services.GetService(typeof(IHttpActionSelector));

            instance.ShouldNotBeNull();
        }
Example #6
0
        public void MefDependencyResolver_In_HttpConfig_Resolves_Registered_ContactRepository_ThroughHost_Test()
        {
            var config   = new HttpConfiguration();
            var resolver = MefDependencyResolver.CreateWithDefaultConventions(new[] { Assembly.GetAssembly(typeof(IContactRepository)) });

            config.DependencyResolver = resolver;

            var server = new HttpServer(config);
            var client = new HttpClient(server);

            client.GetAsync("http://anything/api/contacts").ContinueWith(task =>
            {
                var response = task.Result;
                response.Content.ShouldNotBeNull();
            });
        }