private static RazorViewEngineOptions GetViewEngineOptions() { var defaultSetup = new RazorViewEngineOptionsSetup(); var options = new RazorViewEngineOptions(); defaultSetup.Configure(options); return(options); }
private static RazorViewEngineOptions GetViewEngineOptions() { var defaultSetup = new RazorViewEngineOptionsSetup(Mock.Of <IHostingEnvironment>()); var options = new RazorViewEngineOptions(); defaultSetup.Configure(options); return(options); }
private static RazorViewEngineOptions GetViewEngineOptions() { var defaultSetup = new RazorViewEngineOptionsSetup( Mock.Of <IHostingEnvironment>(), NullLoggerFactory.Instance, Options.Options.Create(new MvcCompatibilityOptions())); var options = new RazorViewEngineOptions(); defaultSetup.Configure(options); return(options); }
public void RazorViewEngineOptionsSetup_SetsPreprocessorSymbols(string environment, string expectedConfiguration) { // Arrange var options = new RazorViewEngineOptions(); var hostingEnv = new Mock<IHostingEnvironment>(); hostingEnv.SetupGet(e => e.EnvironmentName) .Returns(environment); var optionsSetup = new RazorViewEngineOptionsSetup(hostingEnv.Object); // Act optionsSetup.Configure(options); // Assert Assert.Equal(new[] { expectedConfiguration }, options.ParseOptions.PreprocessorSymbolNames); }
public void RazorViewEngineOptionsSetup_SetsUpFileProvider() { // Arrange var options = new RazorViewEngineOptions(); var appEnv = new Mock<IApplicationEnvironment>(); appEnv.SetupGet(e => e.ApplicationBasePath) .Returns(Directory.GetCurrentDirectory()); var optionsSetup = new RazorViewEngineOptionsSetup(appEnv.Object); // Act optionsSetup.Configure(options); // Assert Assert.NotNull(options.FileProvider); Assert.IsType<PhysicalFileProvider>(options.FileProvider); }
public void RazorViewEngineOptionsSetup_SetsOptimizationLevel( string environment, OptimizationLevel expectedOptimizationLevel) { // Arrange var options = new RazorViewEngineOptions(); var hostingEnv = new Mock<IHostingEnvironment>(); hostingEnv.SetupGet(e => e.EnvironmentName) .Returns(environment); var optionsSetup = new RazorViewEngineOptionsSetup(hostingEnv.Object); // Act optionsSetup.Configure(options); // Assert Assert.Equal(expectedOptimizationLevel, options.CompilationOptions.OptimizationLevel); }
public void RazorViewEngineOptionsSetup_SetsUpFileProvider() { // Arrange var options = new RazorViewEngineOptions(); var appEnv = new Mock<IApplicationEnvironment>(); appEnv.SetupGet(e => e.ApplicationBasePath) .Returns(Directory.GetCurrentDirectory()); var hostingEnv = new Mock<IHostingEnvironment>(); hostingEnv.SetupGet(e => e.EnvironmentName) .Returns("Development"); var optionsSetup = new RazorViewEngineOptionsSetup(appEnv.Object, hostingEnv.Object); // Act optionsSetup.Configure(options); // Assert var fileProvider = Assert.Single(options.FileProviders); Assert.IsType<PhysicalFileProvider>(fileProvider); }
public void RazorViewEngineOptionsSetup_SetsUpFileProvider() { // Arrange var options = new RazorViewEngineOptions(); var expected = Mock.Of<IFileProvider>(); var hostingEnv = new Mock<IHostingEnvironment>(); hostingEnv.SetupGet(e => e.ContentRootFileProvider) .Returns(expected); hostingEnv.SetupGet(e => e.EnvironmentName) .Returns("Development"); var optionsSetup = new RazorViewEngineOptionsSetup(hostingEnv.Object); // Act optionsSetup.Configure(options); // Assert var fileProvider = Assert.Single(options.FileProviders); Assert.Same(expected, fileProvider); }