Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        public void RazorViewEngineOptionsSetup_SetsPreprocessorSymbols(string environment, string expectedConfiguration)
        {
            // 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(environment);
            var optionsSetup = new RazorViewEngineOptionsSetup(appEnv.Object, hostingEnv.Object);

            // Act
            optionsSetup.Configure(options);

            // Assert
            Assert.Equal(new[] { expectedConfiguration }, options.ParseOptions.PreprocessorSymbolNames);
        }
Esempio n. 3
0
        public void RazorViewEngineOptionsSetup_SetsOptimizationLevel(
            string environment,
            OptimizationLevel expectedOptimizationLevel)
        {
            // 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(environment);
            var optionsSetup = new RazorViewEngineOptionsSetup(appEnv.Object, hostingEnv.Object);

            // Act
            optionsSetup.Configure(options);

            // Assert
            Assert.Equal(expectedOptimizationLevel, options.CompilationOptions.OptimizationLevel);
        }
Esempio n. 4
0
        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);
        }