public void ShouldGetEnumerableTargetWhenNoRegistrations()
        {
            ITargetContainer targets = CreateTargets();

            var result = Assert.IsType <EnumerableTarget>(targets.Fetch(typeof(IEnumerable <int>)));

            Assert.True(result.UseFallback);
        }
        public void ShouldGetEnumerableTargetAfterRegisterMultipleOfDifferentTypesWithCommonBase()
        {
            ITargetContainer targets = CreateTargets();

            targets.RegisterMultiple(new[] { Target.ForType <NoCtor>(), Target.ForType <DefaultCtor>() }, typeof(NoCtor));

            var result = Assert.IsType <EnumerableTarget>(targets.Fetch(typeof(IEnumerable <NoCtor>)));

            Assert.False(result.UseFallback);
            Assert.Equal(2, result.Targets.Count());
        }
        public void ShouldGetEnumerableTargetWithOneRegistration()
        {
            ITargetContainer targets = CreateTargets();

            targets.RegisterType <NoCtor>();

            var result = Assert.IsType <EnumerableTarget>(targets.Fetch(typeof(IEnumerable <NoCtor>)));

            Assert.False(result.UseFallback);
            Assert.Single(result.Targets);
        }
Exemplo n.º 4
0
        internal static object FetchDirect(this ITargetContainer targets, Type objectType)
        {
            var result = targets.Fetch(objectType);

            if (result != null)
            {
                return(FetchDirect(result, targets, objectType));
            }

            return(result);
        }
        public void ShouldGetEnumerableTargetWithThreeRegistrations()
        {
            ITargetContainer targets = CreateTargets();

            // yes - this does register three separate instances of the same type
            targets.RegisterType <NoCtor>();
            targets.RegisterType <NoCtor>();
            targets.RegisterType <NoCtor>();

            var result = Assert.IsType <EnumerableTarget>(targets.Fetch(typeof(IEnumerable <NoCtor>)));

            Assert.False(result.UseFallback);
            Assert.Equal(3, result.Targets.Count());
        }