Example #1
0
        public FakeEngine(params Type[] types)
        {
            AddComponentInstance <ITypeFinder>(new FakeTypeFinder(types));
            var definitionManager = TestSupport.SetupDefinitions(types.Where(t => typeof(ContentItem).IsAssignableFrom(t)).ToArray());

            AddComponentInstance <IDefinitionManager>(definitionManager);
            var adapterProvider = new ContentAdapterProvider(this, Resolve <ITypeFinder>());

            AddComponentInstance <IContentAdapterProvider>(adapterProvider);
            var itemRepository = new FakeContentItemRepository();

            AddComponentInstance <IRepository <ContentItem> >(itemRepository);
            AddComponentInstance <IContentItemRepository>(itemRepository);
            var webContext = new ThreadContext();

            AddComponentInstance <IWebContext>(webContext);
            var host = new Host(webContext, 1, 1);

            AddComponentInstance <IHost>(host);
            var security = new FakeSecurityManager();

            AddComponentInstance <ISecurityManager>(security);
            var source = new ContentSource(security, new [] { new DatabaseSource(host, itemRepository) });

            AddComponentInstance(source);
            AddComponentInstance <IPersister>(new ContentPersister(source, itemRepository));
            AddComponentInstance <IWebContext>(webContext);
            var proxyFactory = new InterceptingProxyFactory();

            AddComponentInstance <IProxyFactory>(proxyFactory);
            var activator = new ContentActivator(new N2.Edit.Workflow.StateChanger(), new ItemNotifier(), proxyFactory);

            AddComponentInstance <ContentActivator>(activator);
            activator.Initialize(definitionManager.GetDefinitions());
        }
 public void TestFixtureSetUp()
 {
     backup = AccessFilter.CurrentSecurityManager;
     FakeSecurityManager securityManager = new FakeSecurityManager();
     AccessFilter.CurrentSecurityManager = () => securityManager;
 }