コード例 #1
0
        private static RazorViewEngineOptions GetViewEngineOptions()
        {
            var defaultSetup = new RazorViewEngineOptionsSetup();
            var options      = new RazorViewEngineOptions();

            defaultSetup.Configure(options);

            return(options);
        }
コード例 #2
0
        private static RazorViewEngineOptions GetViewEngineOptions()
        {
            var defaultSetup = new RazorViewEngineOptionsSetup(Mock.Of <IHostingEnvironment>());
            var options      = new RazorViewEngineOptions();

            defaultSetup.Configure(options);

            return(options);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
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);
        }
コード例 #6
0
        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);
        }
コード例 #7
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);
        }
コード例 #8
0
        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);
        }