public BasicTester() { _hostRoot = Path.Combine(Directory.GetCurrentDirectory(), "Templates"); _pak1 = Path.Combine(_hostRoot, "Pak1"); _pak2 = Path.Combine(_hostRoot, "Pak2"); _hostHomeView = new Template(Path.Combine(_hostRoot, "Home", "Home.spark"), _hostRoot, FubuSparkConstants.HostOrigin); _hostApplicationView = new Template(Path.Combine(_hostRoot, "Shared", "application.spark"), _hostRoot, FubuSparkConstants.HostOrigin); _hostFooterPartialView = new Template(Path.Combine(_hostRoot, "Shared", "_footer.spark"), _hostRoot, FubuSparkConstants.HostOrigin); _pak1HomeView = new Template(Path.Combine(_pak1, "Home", "Home.spark"), _hostRoot, "Pak1"); _pak1NamePartialView = new Template(Path.Combine(_pak1, "Home", "_name.spark"), _hostRoot, "Pak1"); _pak2HomeView = new Template(Path.Combine(_pak2, "Home", "Home.spark"), _hostRoot, "Pak2"); _pak2ApplicationView = new Template(Path.Combine(_pak2, "Shared", "application.spark"), _hostRoot, "Pak2"); _pak2ThemeView = new Template(Path.Combine(_pak2, "Shared", "theme.spark"), _hostRoot, "Pak2"); var templates = new List <ITemplate> { _hostHomeView, _hostApplicationView, _hostFooterPartialView, _pak1HomeView, _pak1NamePartialView, _pak2HomeView, _pak2ApplicationView, _pak2ThemeView }; var viewPathPolicy = new ViewPathPolicy(); templates.Each(viewPathPolicy.Apply); _viewFolder = new TemplateViewFolder(templates); }
protected override void beforeEach() { const string viewPath = "/_Package1_/Handlers/Models/SerieSL.spark"; var appRoot = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Templates"); var packageRoot = Path.Combine(appRoot, "App", "fubu-packages", "Package1", "WebContent"); var binding1 = new Template(Path.Combine(packageRoot, "Handlers", "Shared", "bindings.xml"), packageRoot, "Package1"); var binding2 = new Template(Path.Combine(appRoot, "Shared", "bindings.xml"), appRoot, TemplateConstants.HostOrigin); var viewPathPolicy = new ViewPathPolicy <ITemplate>(); viewPathPolicy.Apply(binding1); viewPathPolicy.Apply(binding2); _viewFolder = MockFor <IViewFolder>(); _viewFolder.Expect(x => x.GetViewSource(binding1.ViewPath)).Return(new FileSystemViewFile(binding1.FilePath)); _viewFolder.Expect(x => x.GetViewSource(binding2.ViewPath)).Return(new FileSystemViewFile(binding2.FilePath)); _request = new BindingRequest(_viewFolder) { ViewPath = viewPath }; _templateRegistry = MockFor <ISparkTemplateRegistry>(); _templateRegistry.Expect(x => x.BindingsForView(viewPath)).Return(new[] { binding1, binding2 }); }
public ExtendedTester() { var testRoot = Path.Combine(Directory.GetCurrentDirectory(), "Templates"); var pathApp = Path.Combine(testRoot, "App"); var pathPackage1 = Path.Combine(pathApp, "fubu-packages", "Package1", "WebContent"); var pathPackage2 = Path.Combine(testRoot, "Package2"); var allTemplates = new TemplateRegistry <IRazorTemplate>(); var razorSettings = new RazorEngineSettings(); var razorSet = razorSettings.Search; new ContentFolder(TemplateConstants.HostOrigin, pathApp).FindFiles(razorSet) .Union(new ContentFolder("Package1", pathPackage1).FindFiles(razorSet) .Union(new ContentFolder("Package2", pathPackage2).FindFiles(razorSet))) .Each(x => { if (x.Provenance == TemplateConstants.HostOrigin && x.Path.StartsWith(pathPackage1)) { return; } allTemplates.Register(new Template(x.Path, x.ProvenancePath, x.Provenance)); }); var viewPathPolicy = new ViewPathPolicy <IRazorTemplate>(); allTemplates.Each(x => { viewPathPolicy.Apply(x); x.Descriptor = new ViewDescriptor <IRazorTemplate>(x); }); var commonNamespaces = new CommonViewNamespaces(); commonNamespaces.AddForType <string>(); _templateFactory = new TemplateFactoryCache(commonNamespaces, razorSettings, new TemplateCompiler(), new RazorTemplateGenerator()); _pak1TemplateRegistry = new TemplateRegistry <IRazorTemplate>(allTemplates.ByOrigin(Package1)); _pak2TemplateRegistry = new TemplateRegistry <IRazorTemplate>(allTemplates.ByOrigin(Package2)); _appTemplateRegistry = new TemplateRegistry <IRazorTemplate>(allTemplates.FromHost()); _serviceLocator = MockRepository.GenerateMock <IServiceLocator>(); var sharingGraph = new SharingGraph(); sharingGraph.Dependency("Package1", ContentFolder.Application); sharingGraph.Dependency("Package2", ContentFolder.Application); var templateDirectory = new TemplateDirectoryProvider <IRazorTemplate>(new SharedPathBuilder(), allTemplates, sharingGraph); _sharedTemplateLocator = new SharedTemplateLocator <IRazorTemplate>(templateDirectory, allTemplates, new RazorTemplateSelector()); var partialRenderer = new PartialRenderer(_sharedTemplateLocator, _templateFactory); _serviceLocator.Expect(x => x.GetInstance(Arg.Is(typeof(IPartialRenderer)))).Return(partialRenderer); _serviceLocator.Expect(x => x.GetInstance(typeof(IOutputWriter))).Return(MockRepository.GenerateMock <IOutputWriter>()); }
public void can_get_shared_view_paths_for_origin() { var policy = new ViewPathPolicy <ITemplate>(); _templates.Each(policy.Apply); var origin = templateAt(1).Origin; //from pak1 which has dependency on pak2 var pak2SharedLocation = FileSystem.Combine("_Pak2", "Home", Shared); ClassUnderTest.SharedViewPathsForOrigin(origin).ShouldContain(pak2SharedLocation); }
public ExtendedTester() { var testRoot = Path.Combine(Directory.GetCurrentDirectory(), "Templates"); var pathApp = Path.Combine(testRoot, "App"); var pathPackage1 = Path.Combine(pathApp, "fubu-packages", "Package1", "WebContent"); var pathPackage2 = Path.Combine(testRoot, "Package2"); var allTemplates = new TemplateRegistry <IRazorTemplate>(); var razorSet = new RazorEngineSettings().Search; new ContentFolder(TemplateConstants.HostOrigin, pathApp).FindFiles(razorSet) .Union(new ContentFolder("Package1", pathPackage1).FindFiles(razorSet) .Union(new ContentFolder("Package2", pathPackage2).FindFiles(razorSet))) .Each(x => { if (x.Provenance == TemplateConstants.HostOrigin && x.Path.StartsWith(pathPackage1)) { return; } allTemplates.Register(new Template(x.Path, x.ProvenancePath, x.Provenance)); }); var viewPathPolicy = new ViewPathPolicy <IRazorTemplate>(); allTemplates.Each(viewPathPolicy.Apply); var config = new TemplateServiceConfiguration { BaseTemplateType = typeof(FubuRazorView) }; _templateService = new FubuTemplateService(allTemplates, new TemplateService(config), new FileSystem()); _pak1TemplateRegistry = new TemplateRegistry <IRazorTemplate>(allTemplates.ByOrigin(Package1)); _pak2TemplateRegistry = new TemplateRegistry <IRazorTemplate>(allTemplates.ByOrigin(Package2)); _appTemplateRegistry = new TemplateRegistry <IRazorTemplate>(allTemplates.FromHost()); _serviceLocator = MockRepository.GenerateMock <IServiceLocator>(); var sharingGraph = new SharingGraph(); sharingGraph.Dependency("Package1", ContentFolder.Application); sharingGraph.Dependency("Package2", ContentFolder.Application); var templateDirectory = new TemplateDirectoryProvider <IRazorTemplate>(new SharedPathBuilder(), allTemplates, sharingGraph); _sharedTemplateLocator = new SharedTemplateLocator <IRazorTemplate>(templateDirectory, allTemplates, new RazorTemplateSelector()); }
public ExtendedTester() { var testRoot = Path.Combine(Directory.GetCurrentDirectory(), "Templates"); var pathApp = Path.Combine(testRoot, "App"); var pathPackage1 = Path.Combine(pathApp, "fubu-packages", "Package1", "WebContent"); var pathPackage2 = Path.Combine(testRoot, "Package2"); var allTemplates = new TemplateRegistry<IRazorTemplate>(); var razorSettings = new RazorEngineSettings(); var razorSet = razorSettings.Search; new ContentFolder(TemplateConstants.HostOrigin, pathApp).FindFiles(razorSet) .Union(new ContentFolder("Package1", pathPackage1).FindFiles(razorSet) .Union(new ContentFolder("Package2", pathPackage2).FindFiles(razorSet))) .Each(x => { if (x.Provenance == TemplateConstants.HostOrigin && x.Path.StartsWith(pathPackage1)) return; allTemplates.Register(new Template(x.Path, x.ProvenancePath, x.Provenance)); }); var viewPathPolicy = new ViewPathPolicy<IRazorTemplate>(); allTemplates.Each(x => { viewPathPolicy.Apply(x); x.Descriptor = new ViewDescriptor<IRazorTemplate>(x); }); var commonNamespaces = new CommonViewNamespaces(); commonNamespaces.AddForType<string>(); _templateFactory = new TemplateFactoryCache(commonNamespaces, razorSettings, new TemplateCompiler(), new RazorTemplateGenerator()); _pak1TemplateRegistry = new TemplateRegistry<IRazorTemplate>(allTemplates.ByOrigin(Package1)); _pak2TemplateRegistry = new TemplateRegistry<IRazorTemplate>(allTemplates.ByOrigin(Package2)); _appTemplateRegistry = new TemplateRegistry<IRazorTemplate>(allTemplates.FromHost()); _serviceLocator = MockRepository.GenerateMock<IServiceLocator>(); var sharingGraph = new SharingGraph(); sharingGraph.Dependency("Package1", ContentFolder.Application); sharingGraph.Dependency("Package2", ContentFolder.Application); var templateDirectory = new TemplateDirectoryProvider<IRazorTemplate>(new SharedPathBuilder(), allTemplates, sharingGraph); _sharedTemplateLocator = new SharedTemplateLocator<IRazorTemplate>(templateDirectory, allTemplates, new RazorTemplateSelector()); var partialRenderer = new PartialRenderer(_sharedTemplateLocator, _templateFactory); _serviceLocator.Expect(x => x.GetInstance(Arg.Is(typeof (IPartialRenderer)))).Return(partialRenderer); _serviceLocator.Expect(x => x.GetInstance(typeof (IOutputWriter))).Return(MockRepository.GenerateMock<IOutputWriter>()); }
public ExtendedTester() { var testRoot = Path.Combine(Directory.GetCurrentDirectory(), "Templates"); var pathApp = Path.Combine(testRoot, "App"); var pathPackage1 = Path.Combine(pathApp, "fubu-packages", "Package1", "WebContent"); var pathPackage2 = Path.Combine(testRoot, "Package2"); var packages = new List<IPackageInfo>(); var pack1 = new PackageInfo(new PackageManifest() { Name = Package1 }); var pack2 = new PackageInfo(new PackageManifest() { Name = Package2 }); pack1.RegisterFolder(BottleFiles.WebContentFolder, pathPackage1); pack2.RegisterFolder(BottleFiles.WebContentFolder, pathPackage2); packages.Add(pack1); packages.Add(pack2); var scanner = new TemplateFinder<Template>(new FileScanner(), packages){ HostPath = pathApp }; new DefaultRazorTemplateFinderConventions().Configure(scanner); var allTemplates = new TemplateRegistry<IRazorTemplate>(); allTemplates.AddRange(scanner.FindInPackages()); allTemplates.AddRange(scanner.FindInHost()); var viewPathPolicy = new ViewPathPolicy<IRazorTemplate>(); allTemplates.Each(viewPathPolicy.Apply); var config = new TemplateServiceConfiguration{ BaseTemplateType = typeof (FubuRazorView) }; _templateService = new FubuTemplateService(allTemplates, new TemplateService(config), new FileSystem()); _pak1TemplateRegistry = new TemplateRegistry<IRazorTemplate>(allTemplates.ByOrigin(Package1)); _pak2TemplateRegistry = new TemplateRegistry<IRazorTemplate>(allTemplates.ByOrigin(Package2)); _appTemplateRegistry = new TemplateRegistry<IRazorTemplate>(allTemplates.FromHost()); _serviceLocator = MockRepository.GenerateMock<IServiceLocator>(); var sharingGraph = new SharingGraph(); sharingGraph.Dependency("Package1", "Host"); sharingGraph.Dependency("Package2", "Host"); var templateDirectory = new TemplateDirectoryProvider<IRazorTemplate>(new SharedPathBuilder(), allTemplates, sharingGraph); _sharedTemplateLocator = new SharedTemplateLocator<IRazorTemplate>(templateDirectory, allTemplates, new RazorTemplateSelector()); }
public ExtendedTester() { var testRoot = Path.Combine(Directory.GetCurrentDirectory(), "Templates"); var pathApp = Path.Combine(testRoot, "App"); var pathPackage1 = Path.Combine(pathApp, "fubu-packages", "Package1", "WebContent"); var pathPackage2 = Path.Combine(testRoot, "Package2"); var globalPackage = Path.Combine(testRoot, "Global"); var templateRegistry = new TemplateRegistry <ITemplate>(); var sparkSet = new SparkEngineSettings().Search; _sharingGraph = new SharingGraph(); _sharingGraph.Global("Global"); _sharingGraph.CompileDependencies("Package1", "Package2"); new ContentFolder(TemplateConstants.HostOrigin, pathApp).FindFiles(sparkSet) .Union(new ContentFolder("Package1", pathPackage1).FindFiles(sparkSet) .Union(new ContentFolder("Package2", pathPackage2).FindFiles(sparkSet) .Union(new ContentFolder("Global", globalPackage).FindFiles(sparkSet)))) .Each(x => { if (x.Provenance == TemplateConstants.HostOrigin && x.Path.StartsWith(pathPackage1)) { return; } templateRegistry.Register(new Template(x.Path, x.ProvenancePath, x.Provenance)); }); var viewPathPolicy = new ViewPathPolicy <ITemplate>(); templateRegistry.Each(viewPathPolicy.Apply); _viewFolder = new TemplateViewFolder(templateRegistry); _templateDirectoryProvider = new TemplateDirectoryProvider <ITemplate>(new SharedPathBuilder(), templateRegistry, _sharingGraph); _engine = new SparkViewEngine { ViewFolder = _viewFolder, BindingProvider = new FubuBindingProvider(new SparkTemplateRegistry(templateRegistry)), PartialProvider = new FubuPartialProvider(_templateDirectoryProvider) }; _pak1TemplateRegistry = new TemplateRegistry <ITemplate>(templateRegistry.ByOrigin(Package1)); _pak2TemplateRegistry = new TemplateRegistry <ITemplate>(templateRegistry.ByOrigin(Package2)); _appTemplateRegistry = new TemplateRegistry <ITemplate>(templateRegistry.FromHost()); _globalTemplateRegistry = new TemplateRegistry <ITemplate>(templateRegistry.ByOrigin(Global)); }
public ExtendedTester() { var testRoot = Path.Combine(Directory.GetCurrentDirectory(), "Templates"); var pathApp = Path.Combine(testRoot, "App"); var pathPackage1 = Path.Combine(pathApp, "fubu-packages", "Package1", "WebContent"); var pathPackage2 = Path.Combine(testRoot, "Package2"); var allTemplates = new TemplateRegistry<IRazorTemplate>(); var razorSet = new RazorEngineSettings().Search; new ContentFolder(TemplateConstants.HostOrigin, pathApp).FindFiles(razorSet) .Union(new ContentFolder("Package1", pathPackage1).FindFiles(razorSet) .Union(new ContentFolder("Package2", pathPackage2).FindFiles(razorSet))) .Each(x => { if (x.Provenance == TemplateConstants.HostOrigin && x.Path.StartsWith(pathPackage1)) return; allTemplates.Register(new Template(x.Path, x.ProvenancePath, x.Provenance)); }); var viewPathPolicy = new ViewPathPolicy<IRazorTemplate>(); allTemplates.Each(viewPathPolicy.Apply); var config = new TemplateServiceConfiguration { BaseTemplateType = typeof(FubuRazorView) }; _templateService = new FubuTemplateService(allTemplates, new TemplateService(config), new FileSystem()); _pak1TemplateRegistry = new TemplateRegistry<IRazorTemplate>(allTemplates.ByOrigin(Package1)); _pak2TemplateRegistry = new TemplateRegistry<IRazorTemplate>(allTemplates.ByOrigin(Package2)); _appTemplateRegistry = new TemplateRegistry<IRazorTemplate>(allTemplates.FromHost()); _serviceLocator = MockRepository.GenerateMock<IServiceLocator>(); var sharingGraph = new SharingGraph(); sharingGraph.Dependency("Package1", ContentFolder.Application); sharingGraph.Dependency("Package2", ContentFolder.Application); var templateDirectory = new TemplateDirectoryProvider<IRazorTemplate>(new SharedPathBuilder(), allTemplates, sharingGraph); _sharedTemplateLocator = new SharedTemplateLocator<IRazorTemplate>(templateDirectory, allTemplates, new RazorTemplateSelector()); }
public ExtendedTester() { var testRoot = Path.Combine(Directory.GetCurrentDirectory(), "Templates"); var pathApp = Path.Combine(testRoot, "App"); var pathPackage1 = Path.Combine(pathApp, "fubu-packages", "Package1", "WebContent"); var pathPackage2 = Path.Combine(testRoot, "Package2"); var packages = new List <IPackageInfo>(); var pack1 = new PackageInfo(Package1); var pack2 = new PackageInfo(Package2); pack1.RegisterFolder(BottleFiles.WebContentFolder, pathPackage1); pack2.RegisterFolder(BottleFiles.WebContentFolder, pathPackage2); packages.Add(pack1); packages.Add(pack2); var scanner = new TemplateFinder(new FileScanner(), packages) { HostPath = pathApp }; // This is now conventionally applied in SparkEngine new DefaultTemplateFinderConventions().Configure(scanner); var allTemplates = new TemplateRegistry(); allTemplates.AddRange(scanner.FindInPackages()); allTemplates.AddRange(scanner.FindInHost()); var viewPathPolicy = new ViewPathPolicy(); allTemplates.Each(viewPathPolicy.Apply); _viewFolder = new TemplateViewFolder(allTemplates); _engine = new SparkViewEngine { ViewFolder = _viewFolder, BindingProvider = new FubuBindingProvider(new TemplateRegistry(allTemplates)) }; _pak1TemplateRegistry = new TemplateRegistry(allTemplates.ByOrigin(Package1)); _pak2TemplateRegistry = new TemplateRegistry(allTemplates.ByOrigin(Package2)); _appTemplateRegistry = new TemplateRegistry(allTemplates.FromHost()); }