示例#1
0
        public void DerivedResolverTypesCanStillBeCurrentResolver()
        {
            var container = new ContainerBuilder().Build();
            var resolver  = new DerivedAutofacDependencyResolver(container);

            DependencyResolver.SetResolver(resolver);
            Assert.Equal(resolver, AutofacDependencyResolver.Current);
            Assert.NotNull(resolver.GetService(typeof(object)));
            Assert.Single(resolver.GetServices(typeof(object)));
        }
        public void DerivedResolverTypesCanStillBeCurrentResolver()
        {
            var container = new ContainerBuilder().Build();
            var resolver  = new DerivedAutofacDependencyResolver(container);

            DependencyResolver.SetResolver(resolver);
            Assert.AreEqual(resolver, AutofacDependencyResolver.Current, "You should be able to derive from AutofacDependencyResolver and still use the Current property.");
            Assert.That(resolver.GetService(typeof(object)), Is.Not.Null);
            Assert.That(resolver.GetServices(typeof(object)), Has.Length.EqualTo(1));
        }