Beispiel #1
0
        public void Created_resolver_does_not_contain_fallback_resolver_when_there_is_no_parent([MinimalInfo(HasParent = false)] IProvidesResolutionInfo resInfo,
                                                                                                ResolverFactory sut)
        {
            // Act
            var resolver = sut.CreateResolver(resInfo);

            // Assert
            var types = GetListOfResolverTypesUsed(resolver);

            Assert.That(types, Does.Not.Contain(typeof(FallbackResolverProxy)));
        }
Beispiel #2
0
        public void Created_resolver_contains_regular_resolver([MinimalInfo] IProvidesResolutionInfo resInfo,
                                                               ResolverFactory sut)
        {
            // Act
            var resolver = sut.CreateResolver(resInfo);

            // Assert
            var types = GetListOfResolverTypesUsed(resolver);

            Assert.That(types, Contains.Item(typeof(Resolver)));
        }
Beispiel #3
0
        public void Created_resolver_contains_name_injecting_resolver([MinimalInfo] IProvidesResolutionInfo resInfo,
                                                                      ResolverFactory sut)
        {
            // Act
            var resolver = sut.CreateResolver(resInfo);

            // Assert
            var types = GetListOfResolverTypesUsed(resolver);

            Assert.That(types, Contains.Item(typeof(RegisteredNameInjectingResolverProxy)));
        }
Beispiel #4
0
        public void Created_resolver_does_not_contain_caching_resolver_when_caching_is_disabled([MinimalInfo] IProvidesResolutionInfo resInfo,
                                                                                                ResolverFactory sut)
        {
            // Arrange
            SetOptions(resInfo, new ContainerOptions(useInstanceCache: false));

            // Act
            var resolver = sut.CreateResolver(resInfo);

            // Assert
            var types = GetListOfResolverTypesUsed(resolver);

            Assert.That(types, Does.Not.Contain(typeof(CachingResolverProxy)));
        }
Beispiel #5
0
        public void Created_resolver_does_not_contain_dynamic_resolution_resolver_when_the_option_is_not_enabled([MinimalInfo(HasParent = false)] IProvidesResolutionInfo resInfo,
                                                                                                                 ResolverFactory sut)
        {
            // Arrange
            SetOptions(resInfo, new ContainerOptions(selfRegisterAResolver: false));

            // Act
            var resolver = sut.CreateResolver(resInfo);

            // Assert
            var types = GetListOfResolverTypesUsed(resolver);

            Assert.That(types, Does.Not.Contain(typeof(DynamicRecursionResolverProxy)));
        }
Beispiel #6
0
        public void Created_resolver_contains_dynamic_resolution_resolver_when_the_option_is_enabled([MinimalInfo] IProvidesResolutionInfo resInfo,
                                                                                                     ResolverFactory sut)
        {
            // Arrange
            SetOptions(resInfo, new ContainerOptions(selfRegisterAResolver: true));

            // Act
            var resolver = sut.CreateResolver(resInfo);

            // Assert
            var types = GetListOfResolverTypesUsed(resolver);

            Assert.That(types, Contains.Item(typeof(DynamicRecursionResolverProxy)));
        }
Beispiel #7
0
        public void Created_resolver_does_not_contain_instance_dictionary_resolver_when_the_option_is_not_enabled([MinimalInfo(HasParent = false)] IProvidesResolutionInfo resInfo,
                                                                                                                  ResolverFactory sut)
        {
            // Arrange
            SetOptions(resInfo, new ContainerOptions(supportResolvingNamedInstanceDictionaries: false));

            // Act
            var resolver = sut.CreateResolver(resInfo);

            // Assert
            var types = GetListOfResolverTypesUsed(resolver);

            Assert.That(types, Does.Not.Contain(typeof(NamedInstanceDictionaryResolverProxy)));
        }
Beispiel #8
0
        public void Created_resolver_does_not_contain_circlar_dependency_resolver_when_the_option_is_not_enabled([MinimalInfo(HasParent = false)] IProvidesResolutionInfo resInfo,
                                                                                                                 ResolverFactory sut)
        {
            // Arrange
            SetOptions(resInfo, new ContainerOptions(throwOnCircularDependencies: false));

            // Act
            var resolver = sut.CreateResolver(resInfo);

            // Assert
            var types = GetListOfResolverTypesUsed(resolver);

            Assert.That(types, Does.Not.Contain(typeof(CircularDependencyPreventingResolverProxy)));
        }
Beispiel #9
0
        public void Created_resolver_contains_unregistered_service_resolver_when_the_option_is_enabled([MinimalInfo] IProvidesResolutionInfo resInfo,
                                                                                                       ResolverFactory sut)
        {
            // Arrange
            SetOptions(resInfo, new ContainerOptions(resolveUnregisteredTypes: true));

            // Act
            var resolver = sut.CreateResolver(resInfo);

            // Assert
            var types = GetListOfResolverTypesUsed(resolver);

            Assert.That(types, Contains.Item(typeof(UnregisteredServiceResolverProxy)));
        }
Beispiel #10
0
        public void Created_resolver_does_not_contain_unregistered_service_resolver_in_parent_resolver([MinimalInfo] IProvidesResolutionInfo resInfo,
                                                                                                       [MinimalInfo] IProvidesResolutionInfo parentResInfo,
                                                                                                       ResolverFactory sut)
        {
            // Arrange
            SetOptions(resInfo, new ContainerOptions(resolveUnregisteredTypes: true));
            SetOptions(parentResInfo, new ContainerOptions(resolveUnregisteredTypes: true));
            Mock.Get(resInfo).SetupGet(x => x.Parent).Returns(parentResInfo);

            // Act
            var resolver = sut.CreateResolver(resInfo);

            // Assert
            var fallbackResolver = GetListOfResolversUsed(resolver).OfType <FallbackResolverProxy>().FirstOrDefault();

            Assert.That(fallbackResolver, Is.Not.Null);
            var parentResolver      = fallbackResolver.FallbackResolver;
            var parentResolverTypes = GetListOfResolverTypesUsed(parentResolver);

            Assert.That(parentResolverTypes, Does.Not.Contain(typeof(UnregisteredServiceResolverProxy)));
        }