Exemplo n.º 1
0
        public void AddRange_should_add_initializer_types_to_collection_from_list()
        {
            // Arrange
            var initializerTypeList = new InitializerTypeList
                                          {
                                              typeof (InitializerDummy),
                                              typeof (InitializerDummy),
                                              typeof (InitializerDummy)
                                          };

            var moreInitializers = new List<Type>
                                       {
                                           typeof (InitializerStub),
                                           typeof (InitializerStub)
                                       };

            // Act
            initializerTypeList.AddRange(moreInitializers);

            // Assert
            initializerTypeList.Count.ShouldEqual(5);
            initializerTypeList[0].ShouldEqual(typeof(InitializerDummy));
            initializerTypeList[1].ShouldEqual(typeof(InitializerDummy));
            initializerTypeList[2].ShouldEqual(typeof(InitializerDummy));
            initializerTypeList[3].ShouldEqual(typeof(InitializerStub));
            initializerTypeList[4].ShouldEqual(typeof(InitializerStub));
        }
Exemplo n.º 2
0
        public List<IInitializer> FindInitializersInAppDomain(AppDomain appDomain)
        {
            var initializerTypeList = new InitializerTypeList();
            var initializerList = new List<IInitializer>();

            foreach (var assembly in appDomain.GetFilteredAssemblies())
                initializerTypeList.AddRange(
                    _filter.FindInitializers(assembly));

            foreach (var initializerType in initializerTypeList)
                initializerList.Add(
                    (IInitializer)Activator.CreateInstance(initializerType));

            return initializerList;
        }