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 templateRegistry = new TemplateRegistry<ITemplate>(); var sparkSet = new SparkEngineSettings().Search; new ContentFolder(TemplateConstants.HostOrigin, pathApp).FindFiles(sparkSet) .Union(new ContentFolder("Package1", pathPackage1).FindFiles(sparkSet) .Union(new ContentFolder("Package2", pathPackage2).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); _engine = new SparkViewEngine { ViewFolder = _viewFolder, BindingProvider = new FubuBindingProvider(new SparkTemplateRegistry(templateRegistry)) }; _pak1TemplateRegistry = new TemplateRegistry<ITemplate>(templateRegistry.ByOrigin(Package1)); _pak2TemplateRegistry = new TemplateRegistry<ITemplate>(templateRegistry.ByOrigin(Package2)); _appTemplateRegistry = new TemplateRegistry<ITemplate>(templateRegistry.FromHost()); }
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 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()); }