Exemplo n.º 1
0
 public static void Override(DITDependencyConstructor create)
 {
     Create = create;
 }
Exemplo n.º 2
0
        public void CreateInstance_should_fire_initializers_when_typeMapper_unitialized()
        {
            // Arrange
            var typeMapper = S<ITypeMapper>();

            var filter = S<IInitializerFilter>();

            var initializer_1 = M<IInitializer>();
            initializer_1.Expect(i => i.InitializeTypeMapper(typeMapper));

            var initializer_2 = M<IInitializer>();
            initializer_2.Expect(i => i.InitializeTypeMapper(typeMapper));

            var locator = S<IInitializerLocator>();
            locator.Expect(loc => loc.FindInitializersInAppDomain())
                .Return(new List<IInitializer> { initializer_1, initializer_2 });

            var ditDependencyCtor = new DITDependencyConstructor
            {
                TypeMapper = () => typeMapper,
                InitializerFilter = () => filter,
                InitializerLocator = f => locator
            };

            DITDependencyCtor.Override(ditDependencyCtor);

            var dit = new DIT();

            // Act
            dit.CreateInstance<Type>();

            // Assert
            initializer_1.VerifyAllExpectations();
            initializer_2.VerifyAllExpectations();
        }
Exemplo n.º 3
0
        public void CreateInstance_should_search_for_initializers_when_typeMapper_uninitialized()
        {
            // Arrange
            var typeMapper = S<ITypeMapper>();

            var filter = S<IInitializerFilter>();

            var locator = M<IInitializerLocator>();
            locator.Expect(loc => loc.FindInitializersInAppDomain())
                .Return(new List<IInitializer>());

            var ditDependencyCtor = new DITDependencyConstructor
                                        {
                                            TypeMapper = () => typeMapper,
                                            InitializerFilter = () => filter,
                                            InitializerLocator = f => locator
                                        };

            DITDependencyCtor.Override(ditDependencyCtor);

            var dit = new DIT();

            // Act
            dit.CreateInstance(typeof (Type));

            // Assert
            locator.VerifyAllExpectations();
        }