Exemple #1
0
        public static void Setup(out IDefinitionManager definitions, out ContentActivator activator, out IItemNotifier notifier, out FakeSessionProvider sessionProvider, out ItemFinder finder, out SchemaExport schemaCreator, out InterceptingProxyFactory proxyFactory, params Type[] itemTypes)
        {
            var participators             = new ConfigurationBuilderParticipator[0];
            FakeWebContextWrapper context = new Fakes.FakeWebContextWrapper();
            DatabaseSection       config  = (DatabaseSection)ConfigurationManager.GetSection("n2/database");

            Setup(out definitions, out activator, out notifier, out sessionProvider, out finder, out schemaCreator, out proxyFactory, context, config, participators, itemTypes);
        }
        public override void SetUp()
        {
            base.SetUp();

            CreateDefaultStructure();
            webContext = new FakeWebContextWrapper("http://www.n2cms.com/");
            hostSection = new HostSection {Web = new WebElement {ObserveEmptyExtension = true}};
            parser = new UrlParser(persister, webContext, new Host(webContext, startItem.ID, startItem.ID), hostSection);
        }
Exemple #3
0
        public override void SetUp()
        {
            base.SetUp();

            wrapper = new FakeWebContextWrapper("http://www.n2cms.com/");

            host = new Host(wrapper, 1, 1);

            parser = CreateUrlParser();
        }
        public override void SetUp()
        {
            base.SetUp();

            webContext = new FakeWebContextWrapper("http://www.n2cms.com/");
            
            aItem = CreateOneItem<ItemA>(0, "root", null);
            aaItem = CreateOneItem<ItemAA>(0, "aa", aItem);
            abItem = CreateOneItem<ItemAB>(0, "ab", aItem);
            acItem = CreateOneItem<ItemAC>(0, "ac", aItem);
            aaaItem = CreateOneItem<ItemAAA>(0, "aaa", aItem);
            aabItem = CreateOneItem<ItemAAB>(0, "aab", aItem);
        }
Exemple #5
0
		public override void SetUp()
		{
			base.SetUp();

			var wrapper = new N2.Tests.Fakes.FakeWebContextWrapper();
			parser = TestSupport.Setup(persister, wrapper, new Host(wrapper, 1, 1));

			root = CreateOneItem<N2.Tests.Edit.LinkTracker.Items.TrackableItem>(1, "root", null);
			item1 = CreateOneItem<N2.Tests.Edit.LinkTracker.Items.TrackableItem>(2, "item1", root);
			item2 = CreateOneItem<N2.Tests.Edit.LinkTracker.Items.TrackableItem>(3, "item2", root);

			var errorHandler = new FakeErrorHandler();
			var monitor = new N2.Plugin.ConnectionMonitor();
			tracker = new Tracker(persister, detailRepository = new FakeRepository<ContentDetail>(), parser, monitor, errorHandler, new EditSection());
			monitor.SetConnected(Installation.SystemStatusLevel.UpAndRunning);
		}
Exemple #6
0
        public override void SetUp()
        {
            base.SetUp();

            var wrapper = new N2.Tests.Fakes.FakeWebContextWrapper();

            parser = new UrlParser(persister, wrapper, new Host(wrapper, 1, 1), new HostSection());

            root  = CreateOneItem <N2.Tests.Edit.LinkTracker.Items.TrackableItem>(1, "root", null);
            item1 = CreateOneItem <N2.Tests.Edit.LinkTracker.Items.TrackableItem>(2, "item1", root);
            item2 = CreateOneItem <N2.Tests.Edit.LinkTracker.Items.TrackableItem>(3, "item2", root);

            var errorHandler = new FakeErrorHandler();

            linkFactory = new Tracker(persister, null, parser, errorHandler);
            linkFactory.Start();
        }
Exemple #7
0
        public override void SetUp()
        {
            base.SetUp();

            var wrapper = new N2.Tests.Fakes.FakeWebContextWrapper();

            parser = TestSupport.Setup(persister, wrapper, new Host(wrapper, 1, 1));

            root  = CreateOneItem <N2.Tests.Edit.LinkTracker.Items.TrackableItem>(1, "root", null);
            item1 = CreateOneItem <N2.Tests.Edit.LinkTracker.Items.TrackableItem>(2, "item1", root);
            item2 = CreateOneItem <N2.Tests.Edit.LinkTracker.Items.TrackableItem>(3, "item2", root);

            var errorHandler = new FakeErrorHandler();
            var monitor      = new N2.Plugin.ConnectionMonitor();

            linkFactory = new Tracker(persister, null, parser, monitor, errorHandler);
            monitor.SetConnected(Installation.SystemStatusLevel.UpAndRunning);
        }
        public override void SetUp()
        {
            base.SetUp();

            root = CreateOneItem<RegularPage>(1, "root", null);
            about = CreateOneItem<AboutUsSectionPage>(2, "about", root);
            executives = CreateOneItem<ExecutiveTeamPage>(3, "executives", about);
            search = CreateOneItem<SearchPage>(4, "search", root);

            var typeFinder = new FakeTypeFinder2();
            typeFinder.typeMap[typeof(ContentItem)] = this.NearbyTypes()
                .BelowNamespace("N2.Extensions.Tests.Mvc.Models").AssignableTo<ContentItem>().Union(typeof(ContentItem)).ToArray();
            typeFinder.typeMap[typeof(IController)] = this.NearbyTypes()
                .BelowNamespace("N2.Extensions.Tests.Mvc.Controllers").AssignableTo<IController>().Except(typeof(AnotherRegularController))
                .ToArray();

            var changer = new StateChanger();
            var definitions = new DefinitionManager(new[] { new DefinitionProvider(new DefinitionBuilder(new DefinitionMap(), typeFinder, new TransformerBase<IUniquelyNamed>[0], TestSupport.SetupEngineSection())) }, new ITemplateProvider[0], new ContentActivator(changer, null, new EmptyProxyFactory()), changer);
            httpContext = new FakeHttpContext();
            var webContext = new FakeWebContextWrapper(httpContext);
            var host = new Host(webContext, root.ID, root.ID);
            var parser = TestSupport.Setup(persister, webContext, host);
            controllerMapper = new ControllerMapper(typeFinder, definitions);
            Url.DefaultExtension = "";
            N2.Web.Url.ApplicationPath = "/";

            engine = mocks.DynamicMock<IEngine>();
            SetupResult.For(engine.Resolve<ITypeFinder>()).Return(typeFinder);
            SetupResult.For(engine.Definitions).Return(definitions);
            SetupResult.For(engine.UrlParser).Return(parser);
            SetupResult.For(engine.Persister).Return(persister);
            SetupResult.For(engine.Resolve<RequestPathProvider>()).Return(new RequestPathProvider(webContext, parser, new ErrorNotifier(), new HostSection()));
            var editUrlManager = new FakeEditUrlManager();
            SetupResult.For(engine.ManagementPaths).Return(editUrlManager);
            engine.Replay();

            route = new ContentRoute(engine, new MvcRouteHandler(), controllerMapper, null);

            routes = new RouteCollection { route };
        }
		public override void SetUp()
		{
			base.SetUp();

			root = CreateOneItem<PageItem>(1, "root", null);
			one = CreateOneItem<CustomExtensionItem>(2, "one", root);
			two = CreateOneItem<PageItem>(3, "two", one);
			CreateOneItem<DataItem>(4, "four", root);
			three = CreateOneItem<PageItem>(5, "three.3", root);

			webContext = new FakeWebContextWrapper();
			var hostSection = new HostSection { Web = new WebElement { Rewrite = rewriteMethod } };
			parser = new UrlParser(persister, webContext, new Host(webContext, root.ID, root.ID), new N2.Plugin.ConnectionMonitor(), hostSection);
			errorHandler = new FakeErrorHandler();
			engine = new FakeEngine();
			engine.Container.AddComponentInstance(null, typeof(IWebContext), webContext);
			engine.Container.AddComponentInstance(null, typeof(TargetingRadar), new TargetingRadar(hostSection, new DetectorBase[0]));
			adapterProvider = new ContentAdapterProvider(engine, new AppDomainTypeFinder());
			adapterProvider.Start();

			ReCreateDispatcherWithConfig(hostSection);
		}
Exemple #10
0
        public void ServerUrl_Returns_DifferentValues_InRequestForDifferentSites()
        {
            var oldEngine = Singleton<IEngine>.Instance;
            try
            {
                var engine = new FakeEngine();
                var webContext = new FakeWebContextWrapper();
                webContext.isWeb = true;
				engine.Container.AddComponentInstance("", typeof(IWebContext), webContext);
                Singleton<IEngine>.Instance = engine;

                webContext.Url = "http://site1/app";
                Assert.That(Url.ServerUrl, Is.EqualTo("http://site1"));
                webContext.Url = "http://site2/app";
                Assert.That(Url.ServerUrl, Is.EqualTo("http://site2"));
            }
            finally
            {
                Singleton<IEngine>.Instance = oldEngine;
            }
        }
Exemple #11
0
        public override void SetUp()
        {
            base.SetUp();

            var wrapper = new N2.Tests.Fakes.FakeWebContextWrapper();
            parser = new UrlParser(persister, wrapper, new Host(wrapper, 1, 1), new HostSection());

            root = CreateOneItem<N2.Tests.Edit.LinkTracker.Items.TrackableItem>(1, "root", null);
            item1 = CreateOneItem<N2.Tests.Edit.LinkTracker.Items.TrackableItem>(2, "item1", root);
            item2 = CreateOneItem<N2.Tests.Edit.LinkTracker.Items.TrackableItem>(3, "item2", root);

            var errorHandler = new FakeErrorHandler();
            linkFactory = new Tracker(persister, null, parser, errorHandler);
            linkFactory.Start();
        }
Exemple #12
0
        public void ServerUrl_Returns_FallbackValue_InThreadContext()
        {
            var oldEngine = Singleton<IEngine>.Instance;
            try
            {
                var engine = new FakeEngine();
                var webContext = new FakeWebContextWrapper();
                webContext.isWeb = true;
                engine.AddComponentInstance("", typeof(IWebContext), webContext);
                Singleton<IEngine>.Instance = engine;

                webContext.Url = "http://site1/app";
                Assert.That(Url.ServerUrl, Is.EqualTo("http://site1"));

                webContext.isWeb = false;
                webContext.Url = "http://site2/app";
                Assert.That(Url.ServerUrl, Is.EqualTo("http://site1"));
            }
            finally
            {
                Singleton<IEngine>.Instance = oldEngine;
            }
        }