public void Init() { mocks = new MockRepository(); serviceProvider = new StubMonoRailServices(); var viewSourceLoader = new FileAssemblyViewSourceLoader("MonoRail.Tests.Views"); viewSourceLoader.Service(this.serviceProvider); serviceProvider.ViewSourceLoader = viewSourceLoader; serviceProvider.AddService(typeof(IViewSourceLoader), viewSourceLoader); Configure(); controllerContext = new ControllerContext(); propertyBag = controllerContext.PropertyBag; controllerContext.LayoutNames = new [] { "default" }; output = new StringWriter(); server = new StubServerUtility(); routingEngine = MockRepository.GenerateMock <IRoutingEngine>(); var urlBuilder = new DefaultUrlBuilder(server, routingEngine); serviceProvider.UrlBuilder = urlBuilder; serviceProvider.AddService(typeof(IUrlBuilder), urlBuilder); InitUrlInfo("", "home", "index"); response = engineContext.Response; }
public void Init() { mocks = new MockRepository(); factory = new SparkViewFactory(); engineContext = mocks.CreateMock<IEngineContext>(); server = new MockServerUtility(); request = mocks.CreateMock<IRequest>(); response = mocks.CreateMock<IResponse>(); controller = mocks.CreateMock<IController>(); controllerContext = mocks.CreateMock<IControllerContext>(); routingEngine = mocks.CreateMock<IRoutingEngine>(); output = new StringWriter(); helpers = new HelperDictionary(); propertyBag = new Dictionary<string, object>(); flash = new Flash(); session = new Dictionary<string, object>(); requestParams = new NameValueCollection(); contextItems = new Dictionary<string, object>(); SetupResult.For(engineContext.Server).Return(server); SetupResult.For(engineContext.Request).Return(request); SetupResult.For(engineContext.Response).Return(response); SetupResult.For(engineContext.CurrentController).Return(controller); SetupResult.For(engineContext.CurrentControllerContext).Return(controllerContext); SetupResult.For(engineContext.Flash).Return(flash); SetupResult.For(engineContext.Session).Return(session); SetupResult.For(engineContext.Items).Return(contextItems); SetupResult.For(request.Params).Return(requestParams); SetupResult.For(controllerContext.LayoutNames).Return(new[] { "default" }); SetupResult.For(controllerContext.Helpers).Return(helpers); SetupResult.For(controllerContext.PropertyBag).Return(propertyBag); SetupResult.For(routingEngine.IsEmpty).Return(true); var urlBuilder = new DefaultUrlBuilder(server, routingEngine); var serviceProvider = mocks.CreateMock<IServiceProvider>(); var viewSourceLoader = new FileAssemblyViewSourceLoader("Views"); SetupResult.For(serviceProvider.GetService(typeof(IViewSourceLoader))).Return(viewSourceLoader); SetupResult.For(serviceProvider.GetService(typeof(ILoggerFactory))).Return(new NullLogFactory()); SetupResult.For(serviceProvider.GetService(typeof(ISparkViewEngine))).Return(null); SetupResult.For(serviceProvider.GetService(typeof(IUrlBuilder))).Return(urlBuilder); SetupResult.For(serviceProvider.GetService(typeof(IViewComponentFactory))).Return(null); mocks.Replay(serviceProvider); SetupResult.For(engineContext.GetService(null)).IgnoreArguments().Do( new Func<Type, object>(serviceProvider.GetService)); factory.Service(serviceProvider); manager = new DefaultViewEngineManager(); manager.RegisterEngineForExtesionLookup(factory); manager.RegisterEngineForView(factory); }
public void Init() { mocks = new MockRepository(); serviceProvider = new StubMonoRailServices(); var viewSourceLoader = new FileAssemblyViewSourceLoader("MonoRail.Tests.Views"); viewSourceLoader.Service(this.serviceProvider); serviceProvider.ViewSourceLoader = viewSourceLoader; serviceProvider.AddService(typeof(IViewSourceLoader), viewSourceLoader); Configure(); controllerContext = new ControllerContext(); propertyBag = controllerContext.PropertyBag; controllerContext.LayoutNames = new []{"default"}; output = new StringWriter(); server = new StubServerUtility(); routingEngine = MockRepository.GenerateMock<IRoutingEngine>(); var urlBuilder = new DefaultUrlBuilder(server, routingEngine); serviceProvider.UrlBuilder = urlBuilder; serviceProvider.AddService(typeof(IUrlBuilder), urlBuilder); InitUrlInfo("", "home", "index"); response = engineContext.Response; }
/// <summary> /// Services the specified provider. /// </summary> /// <param name="provider">The provider.</param> public void Service(IServiceProvider provider) { var config = (IMonoRailConfiguration)provider.GetService(typeof(IMonoRailConfiguration)); useExtensions = config.UrlConfig.UseExtensions; serverUtil = (IServerUtility)provider.GetService(typeof(IServerUtility)); routingEng = (IRoutingEngine)provider.GetService(typeof(IRoutingEngine)); }
public AuthenticationClient( IAccountRepository accountRepository, IProfileService profileService, IRoutingEngine routingEngine) { _accountRepository = accountRepository; _profileService = profileService; _routingEngine = routingEngine; }
public RoutableRequestContext(IRebelApplicationContext applicationContext, ComponentRegistrations components, IRoutingEngine routingEngine) { Mandate.ParameterNotNull(applicationContext, "applicationContext"); Mandate.ParameterNotNull(components, "components"); Mandate.ParameterNotNull(routingEngine, "routingEngine"); Application = applicationContext; RegisteredComponents = components; RoutingEngine = routingEngine; }
public RoutableRequestContext(IRebelApplicationContext applicationContext, ComponentRegistrations components, IRoutingEngine routingEngine) { Mandate.ParameterNotNull(applicationContext, "applicationContext"); Mandate.ParameterNotNull(components, "components"); Mandate.ParameterNotNull(routingEngine, "routingEngine"); Application = applicationContext; RegisteredComponents = components; RoutingEngine = routingEngine; }
/// <summary> /// Resolves the url for the specified id. /// </summary> /// <param name="routingEngine"></param> /// <param name="id">The id.</param> /// <returns></returns> public static string GetUrl(this IRoutingEngine routingEngine, HiveId id) { Mandate.ParameterNotEmpty(id, "id"); var applicationContext = DependencyResolver.Current.GetService <IRebelApplicationContext>(); var hive = applicationContext.Hive.GetReader <IContentStore>(id.ToUri()); if (hive != null) { var key = CacheKey.Create(new UrlCacheKey(id)); var item = hive.HiveContext.GenerationScopedCache.GetOrCreate(key, () => { using (var uow = hive.CreateReadonly()) { //var entity = uow.Repositories.Get<TypedEntity>(id); var entity = uow.Repositories.OfRevisionType(FixedStatusTypes.Published).InIds(id).FirstOrDefault(); if (entity == null) { throw new NullReferenceException("Could not find a TypedEntity in the repository for a content item with id " + id.ToFriendlyString()); } return(routingEngine.GetUrlForEntity(entity)); } }); var urlResult = item.Value.Item; ////return from scoped cache so we don't have to lookup in the same session //var urlResult = applicationContext.FrameworkContext.ScopedCache.GetOrCreateTyped<UrlResolutionResult>("nice-url-" + id, () => // { // using (var uow = hive.CreateReadonly()) // { // var entity = uow.Repositories.Get<TypedEntity>(id); // if (entity == null) // throw new NullReferenceException("Could not find a TypedEntity in the repository for a content item with id " + id.ToFriendlyString()); // return routingEngine.GetUrlForEntity(entity); // } // }); if (urlResult.IsSuccess()) { return(urlResult.Url); } //return a hashed url with the status return("#" + urlResult.Status); } return(id.ToString()); }
public DefaultBackOfficeRequestContext(IRebelApplicationContext applicationContext, HttpContextBase httpContext, ComponentRegistrations components, IPackageContext packageContext, IRoutingEngine routingEngine) : base(applicationContext, components, routingEngine) { //create the IO resolvers var urlHelper = new UrlHelper(httpContext.Request.RequestContext); DocumentTypeIconResolver = new DocumentTypeIconFileResolver(httpContext.Server, applicationContext.Settings, urlHelper); DocumentTypeThumbnailResolver = new DocumentTypeThumbnailFileResolver(httpContext.Server, applicationContext.Settings, urlHelper); ApplicationIconResolver = new ApplicationIconFileResolver(httpContext.Server, applicationContext.Settings, urlHelper); PackageContext = packageContext; }
public DefaultBackOfficeRequestContext(IRebelApplicationContext applicationContext, HttpContextBase httpContext, ComponentRegistrations components, IPackageContext packageContext, IRoutingEngine routingEngine) : base(applicationContext, components, routingEngine) { //create the IO resolvers var urlHelper = new UrlHelper(httpContext.Request.RequestContext); DocumentTypeIconResolver = new DocumentTypeIconFileResolver(httpContext.Server, applicationContext.Settings, urlHelper); DocumentTypeThumbnailResolver = new DocumentTypeThumbnailFileResolver(httpContext.Server, applicationContext.Settings, urlHelper); ApplicationIconResolver = new ApplicationIconFileResolver(httpContext.Server, applicationContext.Settings, urlHelper); PackageContext = packageContext; }
public void Configure() { var assembly = Assembly.GetAssembly(typeof (SetupDefaultConfig)); ErrorsLog = new TestErrorsLog(); Configuration.Default(new StructureMapContainer()) .Register(assembly) .SetErrorPresenter<TestErrorsLog>() .DefaultShowAs("window"); _routingEngine = IoC.Get<IRoutingEngine>(); RouteLog = new TestRouteLog(); _routingEngine.AddProcessor(RouteLog); ErrorsLog = IoC.Get<IErrorPresenter>() as TestErrorsLog; }
public FakeRoutableRequestContext(IUmbracoApplicationContext application, IRoutingEngine engine) { _engine = engine; Application = application; }
public FakeRoutableRequestContext(IRebelApplicationContext application, IRoutingEngine engine) { _engine = engine; Application = application; }
public FakeBackOfficeRequestContext(IRebelApplicationContext application, IRoutingEngine engine) : base(application, engine) { }
/// <summary> /// Initializes a new instance of the <see cref="DefaultUrlBuilder"/> class. /// </summary> /// <param name="serverUtil">The server util.</param> /// <param name="routingEng">The routing eng.</param> public DefaultUrlBuilder(IServerUtility serverUtil, IRoutingEngine routingEng) { this.serverUtil = serverUtil; this.routingEng = routingEng; }
public void Init() { mocks = new MockRepository(); factory = new SparkViewFactory(); engineContext = mocks.CreateMock <IEngineContext>(); server = new MockServerUtility(); request = mocks.CreateMock <IRequest>(); response = mocks.CreateMock <IResponse>(); controller = mocks.CreateMock <IController>(); controllerContext = mocks.CreateMock <IControllerContext>(); routingEngine = mocks.CreateMock <IRoutingEngine>(); output = new StringWriter(); helpers = new HelperDictionary(); propertyBag = new Dictionary <string, object>(); flash = new Flash(); session = new Dictionary <string, object>(); requestParams = new NameValueCollection(); contextItems = new Dictionary <string, object>(); SetupResult.For(engineContext.Server).Return(server); SetupResult.For(engineContext.Request).Return(request); SetupResult.For(engineContext.Response).Return(response); SetupResult.For(engineContext.CurrentController).Return(controller); SetupResult.For(engineContext.CurrentControllerContext).Return(controllerContext); SetupResult.For(engineContext.Flash).Return(flash); SetupResult.For(engineContext.Session).Return(session); SetupResult.For(engineContext.Items).Return(contextItems); SetupResult.For(request.Params).Return(requestParams); SetupResult.For(controllerContext.LayoutNames).Return(new[] { "default" }); SetupResult.For(controllerContext.Helpers).Return(helpers); SetupResult.For(controllerContext.PropertyBag).Return(propertyBag); SetupResult.For(routingEngine.IsEmpty).Return(true); var urlBuilder = new DefaultUrlBuilder(server, routingEngine); var serviceProvider = mocks.CreateMock <IServiceProvider>(); var viewSourceLoader = new FileAssemblyViewSourceLoader("Views"); SetupResult.For(serviceProvider.GetService(typeof(IViewSourceLoader))).Return(viewSourceLoader); SetupResult.For(serviceProvider.GetService(typeof(ILoggerFactory))).Return(new NullLogFactory()); SetupResult.For(serviceProvider.GetService(typeof(ISparkViewEngine))).Return(null); SetupResult.For(serviceProvider.GetService(typeof(IUrlBuilder))).Return(urlBuilder); SetupResult.For(serviceProvider.GetService(typeof(IViewComponentFactory))).Return(null); mocks.Replay(serviceProvider); SetupResult.For(engineContext.GetService(null)).IgnoreArguments().Do( new Func <Type, object>(serviceProvider.GetService)); factory.Service(serviceProvider); manager = new DefaultViewEngineManager(); manager.RegisterEngineForExtesionLookup(factory); manager.RegisterEngineForView(factory); }
public FakeBackOfficeRequestContext(IUmbracoApplicationContext application, IRoutingEngine engine) : base(application, engine) { }