Exemplo n.º 1
0
        public void SetUp()
        {
            engine = new Fakes.FakeEngine(new Type[] { typeof(ContentHandlerTestsPage), typeof(ContentHandlerTestsPart), typeof(Fakes.FakeNodeAdapter) });
            //engine.Resolve<Fakes.FakeNodeAdapter>().Engine = engine;
            handler = new ContentHandler(engine);
            context = new Fakes.FakeWebContextWrapper();
            context.HttpContext.User = SecurityUtilities.CreatePrincipal("Admin");

            startPage = new ContentHandlerTestsPage {
                Title = "Start page"
            };
            engine.Persister.Save(startPage);
            page = new ContentHandlerTestsPage {
                Title = "Page in question"
            };
            page.AddTo(startPage);
            engine.Persister.Save(page);

            engine.AddComponentInstance <IWebContext>(context);
            engine.AddComponentInstance <IUrlParser>(new Fakes.FakeUrlParser(startPage: startPage));
            var persister         = engine.Persister;
            var activator         = engine.Resolve <ContentActivator>();
            var versionRepository = TestSupport.CreateVersionRepository(ref persister, ref activator, new Type[] { typeof(ContentHandlerTestsPage), typeof(ContentHandlerTestsPart) });

            engine.AddComponentInstance <ContentVersionRepository>(versionRepository);
            engine.AddComponentInstance <VersionManager>(versionManager = TestSupport.SetupVersionManager(engine.Persister, versionRepository));
            (engine.Resolve <IContentAdapterProvider>() as N2.Plugin.IAutoStart).Start();
            engine.Resolve <IContentAdapterProvider>().ResolveAdapter <N2.Edit.NodeAdapter>(typeof(ContentItem)).Engine = engine;
            engine.AddComponentInstance(new HtmlSanitizer(new N2.Configuration.HostSection()));
            engine.AddComponentInstance <IEditUrlManager>(new FakeEditUrlManager());
            engine.AddComponentInstance(new ConfigurationManagerWrapper());
            engine.AddComponentInstance <ILanguageGateway>(new FakeLanguageGateway());

            engine.AddComponentInstance(new DraftRepository(versionRepository, new FakeCacheWrapper()));
        }
Exemplo n.º 2
0
		public void SetUp()
		{
			engine = new Fakes.FakeEngine(new Type[] { typeof(ContentHandlerTestsPage), typeof(ContentHandlerTestsPart), typeof(Fakes.FakeNodeAdapter) });
			//engine.Resolve<Fakes.FakeNodeAdapter>().Engine = engine;
			handler = new ContentHandler(engine);
			context = new Fakes.FakeWebContextWrapper();
			context.HttpContext.User = SecurityUtilities.CreatePrincipal("Admin");

			startPage = new ContentHandlerTestsPage { Title = "Start page" };
			engine.Persister.Save(startPage);
			page = new ContentHandlerTestsPage { Title = "Page in question" };
			page.AddTo(startPage);
			engine.Persister.Save(page);
			
			engine.AddComponentInstance<IWebContext>(context);
			engine.AddComponentInstance<IUrlParser>(new Fakes.FakeUrlParser(startPage: startPage));
			var persister = engine.Persister;
			var activator = engine.Resolve<ContentActivator>();
			var versionRepository = TestSupport.CreateVersionRepository(ref persister, ref activator, new Type[] { typeof(ContentHandlerTestsPage), typeof(ContentHandlerTestsPart) });
			engine.AddComponentInstance<ContentVersionRepository>(versionRepository);
			engine.AddComponentInstance<VersionManager>(versionManager = TestSupport.SetupVersionManager(engine.Persister, versionRepository));
			(engine.Resolve<IContentAdapterProvider>() as N2.Plugin.IAutoStart).Start();
			engine.Resolve<IContentAdapterProvider>().ResolveAdapter<N2.Edit.NodeAdapter>(typeof(ContentItem)).Engine = engine;
			engine.AddComponentInstance(new HtmlSanitizer(new N2.Configuration.HostSection()));
			engine.AddComponentInstance<IEditUrlManager>(new FakeEditUrlManager());
			engine.AddComponentInstance(new ConfigurationManagerWrapper());
			engine.AddComponentInstance<ILanguageGateway>(new FakeLanguageGateway());

			engine.AddComponentInstance(new DraftRepository(versionRepository, new FakeCacheWrapper()));
		}
Exemplo n.º 3
0
        public void AssignedItem_IsAddedAsChild_WithPropertyNameAsItemName()
        {
            var item = (DecoratedItem)engine.Resolve <ContentActivator>().CreateInstance(typeof(DecoratedItem), null, null, asProxy: true);

            var child = new OtherItem();

            item.TheItem = child;

            item.TheItem.ShouldBe(child);
            item.Children.Single().ShouldBe(child);
            child.Name.ShouldBe("TheItem");
            child.ZoneName.ShouldBe(null);
        }