Ejemplo n.º 1
0
        public void Type_List_Delegates_Combination()
        {
            Func <IEnumerable <Type> > types = () => new[] { typeof(TransientObject3), typeof(TransientObject2) };

            var resolver = new LazyResolver(types);

            resolver.AddTypeListDelegate(() => new[] { typeof(TransientObject1) });

            Resolution.Freeze();

            var instances1 = resolver.Objects;

            Assert.AreEqual(3, instances1.Count());
            Assert.IsTrue(instances1.Select(x => x.GetType()).ContainsAll(new[] { typeof(TransientObject1), typeof(TransientObject2), typeof(TransientObject3) }));
        }
        public void LazyResolverResolvesTypeProducers()
        {
            Func <IEnumerable <Type> > types = () => new[] { typeof(TransientObject3), typeof(TransientObject2) };

            var resolver = new LazyResolver(types);

            resolver.AddTypeListDelegate(() => new[] { typeof(TransientObject1) });

            Resolution.Freeze();

            var values = resolver.Objects;

            Assert.AreEqual(3, values.Count());
            Assert.IsTrue(values.Select(x => x.GetType())
                          .ContainsAll(new[] { typeof(TransientObject1), typeof(TransientObject2), typeof(TransientObject3) }));
        }