public void Setup() { fileSystem = MockRepository.GenerateStub <IFileSystem>(); razorCompiler = MockRepository.GenerateStub <IRazorCompiler>(); razorCompiler.Stub(x => x.Compile(null, null)).IgnoreArguments().Return(new CompiledRazorTemplate(null, null)); engine = new RazorViewRenderingEngine(fileSystem, razorCompiler); RazorEngineCompileSettings compilerSettings = new RazorEngineCompileSettings(); engine.Initialize(ViewsDir, compilerSettings); }
public void Setup() { IFileSystem fileSystem = new WindowsFileSystem(); IRazorCompiler razorCompiler = new InMemoryRazorCompiler(); engine = new RazorViewRenderingEngine(fileSystem, razorCompiler); RazorEngineCompileSettings razorEngineCompileSettings = new RazorEngineCompileSettings(); razorEngineCompileSettings.DefaultNamespace = "Syborg.Tests"; razorEngineCompileSettings.DefaultClassName = "SyborgTestRazorTemplate"; razorEngineCompileSettings.NamespaceImports.Add("System"); razorEngineCompileSettings.NamespaceImports.Add("System.Collections"); razorEngineCompileSettings.NamespaceImports.Add("System.Collections.Generic"); razorEngineCompileSettings.DefaultBaseClass = typeof(RazorTemplateBase).FullName; razorEngineCompileSettings.ReferenceAssemblies.Add(typeof(HtmlString).Assembly); razorEngineCompileSettings.DebugMode = DebugMode; engine.Initialize("Views", razorEngineCompileSettings); }
public SyborgTestHttpModuleAppHost() { IFileSystem fileSystem = new WindowsFileSystem(); IApplicationInfo applicationInfo = new ApplicationInfo(); ITimeService timeService = new RealTimeService(); IRazorCompiler razorCompiler = new InMemoryRazorCompiler(); IRazorViewRenderingEngine viewRenderingEngine = new RazorViewRenderingEngine(fileSystem, razorCompiler); IWebServerConfiguration config = new WebServerConfiguration(); FileMimeTypesMap fileMimeTypesMap = new FileMimeTypesMap().RegisterStandardMimeTypes(); Initialize(config, fileSystem, applicationInfo, timeService, fileMimeTypesMap, viewRenderingEngine); IFileCache fileCache = new FileCache(); string webAppRootDir; if (!WebServerConfiguration.WebServerDevelopmentMode) { #if NCRUNCH webAppRootDir = @"D:\hg\ScalableMaps\WebApp\ScalableMaps\ScalableMaps.Web2"; #else webAppRootDir = ApplicationInfo.GetAppDirectoryPath(".."); #endif } else { webAppRootDir = ApplicationInfo.GetAppDirectoryPath(".."); } ContentCommand contentCommand = RegisterWebContent(webAppRootDir, fileCache, config); TestStreamCommand streamCommand = new TestStreamCommand(); AddRoute(new RegexWebRequestRoute("^Content/(?<path>.+)$", HttpMethod.GET, contentCommand)); AddRoute(new RegexWebRequestRoute("^stream/(?<path>.+)$", HttpMethod.GET, streamCommand)); AddPolicies(new IWebPolicy[] { new SecureResponseHeadersPolicy() }); }
public void Setup() { IFileSystem fileSystem = new WindowsFileSystem(); IApplicationInfo applicationInfo = new ApplicationInfo(); ITimeService timeService = new RealTimeService(); ISignal serverStopSignal = new ManualResetSignal(false); IWebServerConfiguration configuration = new WebServerConfiguration(); IRazorCompiler razorCompiler = new InMemoryRazorCompiler(); IRazorViewRenderingEngine viewRenderingEngine = new RazorViewRenderingEngine(fileSystem, razorCompiler); IWebServerController webServerController = new WebServerController(serverStopSignal); IFileMimeTypesMap fileMimeTypesMap = new FileMimeTypesMap(); IFileCache fileCache = new FileCache(); List <IWebRequestRoute> routes = new List <IWebRequestRoute>(); string contentRootDirectory = Path.Combine(TestContext.CurrentContext.TestDirectory, "sample-content"); ContentCommand contentCommand = new ContentCommand(contentRootDirectory, fileSystem, fileCache); routes.Add(new RegexWebRequestRoute("^content/(?<path>.+)$", HttpMethod.GET, contentCommand)); // ReSharper disable once CollectionNeverUpdated.Local List <IWebPolicy> policies = new List <IWebPolicy>(); const string ExternalUrl = "http://localhost"; const int Port = 12345; testServiceUrl = "{0}:{1}/".Fmt(ExternalUrl, Port); host = new TestHost( configuration, ExternalUrl, Port, null, fileSystem, applicationInfo, timeService, viewRenderingEngine, fileMimeTypesMap, webServerController, routes, policies); host.Start(); IWebConfiguration webConfiguration = new WebConfiguration("Syborg.Tests"); restClientFactory = new RestClientFactory(webConfiguration); }