Exemplo n.º 1
0
        public void GetService_UnknownService_ReturnsNull()
        {
            var container = CreateContainer();
            container.Register<IBar, Bar>();
            IDependencyResolver resolver = new LightInjectMvcDependencyResolver(container);

            var instance = resolver.GetService<IFoo>();

            Assert.IsNull(instance);
        }
Exemplo n.º 2
0
        public void GetServices_UnknownService_ReturnsEmptyEnumerable()
        {
            var container = CreateContainer();
            container.Register<IBar, Bar>();
            IDependencyResolver resolver = new LightInjectMvcDependencyResolver(container);

            var instances = resolver.GetServices<IFoo>();

            Assert.AreEqual(0, instances.Count());
        }
Exemplo n.º 3
0
        public void GetService_KnownService_ReturnsInstance()
        {
            var container = CreateContainer();
            container.Register<IFoo, Foo>();
            IDependencyResolver resolver = new LightInjectMvcDependencyResolver(container);

            var instance = resolver.GetService<IFoo>();

            Assert.IsInstanceOfType(instance, typeof(Foo));
        }
Exemplo n.º 4
0
        public void GetServices_MultipleServices_ReturnsAllInstances()
        {
            var container = CreateContainer();
            container.Register<IFoo, Foo>();
            container.Register<IFoo, AnotherFoo>("AnotherFoo");
            IDependencyResolver resolver = new LightInjectMvcDependencyResolver(container);

            var instances = resolver.GetServices<IFoo>();

            Assert.AreEqual(2, instances.Count());
        }