Ejemplo n.º 1
0
        public void NonRegisteredServicesCanBeIEnumerableResolved()
        {
            var serviceProvider = new ServiceProvider();

            var serviceList = (IEnumerable<IService>)serviceProvider.GetService(typeof(IEnumerable<IService>));

            Assert.NotNull(serviceList);
            Assert.False(serviceList.Any(), "The serviceList should have no elements.");
        }
Ejemplo n.º 2
0
        public void RegisteredServicesCanBeIEnumerableResolved()
        {
            var serviceProvider = new ServiceProvider();
            var service = new Service();

            serviceProvider.Add(typeof(IService), service);

            var serviceList = (IEnumerable<IService>)serviceProvider.GetService(typeof(IEnumerable<IService>));

            Assert.NotNull(serviceList);
            var enumerator = serviceList.GetEnumerator();
            Assert.True(enumerator.MoveNext(), "The serviceList should have 1 element");
            Assert.Same(service, enumerator.Current);
            Assert.False(enumerator.MoveNext(), "The serviceList should have 1 element");
        }