public void ApplyEnvironmentSettingsUsesTheCorrectKeysAndProperties()
        {
            var originalEnvironment = new WebHostEnvironment
            {
                ApplicationName         = WebHostDefaults.ApplicationKey,
                EnvironmentName         = WebHostDefaults.EnvironmentKey,
                ContentRootPath         = WebHostDefaults.ContentRootKey,
                WebRootPath             = WebHostDefaults.WebRootKey,
                ContentRootFileProvider = Mock.Of <IFileProvider>(),
                WebRootFileProvider     = Mock.Of <IFileProvider>(),
            };

            var settings = new Dictionary <string, string>();
            var webHostBuilderEnvironment = new WebHostEnvironment();

            originalEnvironment.ApplyEnvironmentSettings(new TestWebHostBuilder(settings, webHostBuilderEnvironment));

            Assert.Equal(WebHostDefaults.ApplicationKey, settings[WebHostDefaults.ApplicationKey]);
            Assert.Equal(WebHostDefaults.EnvironmentKey, settings[WebHostDefaults.EnvironmentKey]);
            Assert.Equal(WebHostDefaults.ContentRootKey, settings[WebHostDefaults.ContentRootKey]);
            Assert.Equal(WebHostDefaults.WebRootKey, settings[WebHostDefaults.WebRootKey]);

            Assert.Equal(WebHostDefaults.ApplicationKey, webHostBuilderEnvironment.ApplicationName);
            Assert.Equal(WebHostDefaults.EnvironmentKey, webHostBuilderEnvironment.EnvironmentName);
            Assert.Equal(WebHostDefaults.ContentRootKey, webHostBuilderEnvironment.ContentRootPath);
            Assert.Equal(WebHostDefaults.WebRootKey, webHostBuilderEnvironment.WebRootPath);

            Assert.Same(originalEnvironment.ContentRootFileProvider, webHostBuilderEnvironment.ContentRootFileProvider);
            Assert.Same(originalEnvironment.WebRootFileProvider, webHostBuilderEnvironment.WebRootFileProvider);
        }
Exemplo n.º 2
0
        public void ApplyEnvironmentSettingsUsesTheCorrectKeys()
        {
            var env = new WebHostEnvironment
            {
                ApplicationName = WebHostDefaults.ApplicationKey,
                EnvironmentName = WebHostDefaults.EnvironmentKey,
                ContentRootPath = WebHostDefaults.ContentRootKey,
                WebRootPath     = WebHostDefaults.WebRootKey,
            };

            var settings = new Dictionary <string, string>();

            env.ApplyEnvironmentSettings(new TestWebHostBuilder(settings));

            Assert.Equal(WebHostDefaults.ApplicationKey, settings[WebHostDefaults.ApplicationKey]);
            Assert.Equal(WebHostDefaults.EnvironmentKey, settings[WebHostDefaults.EnvironmentKey]);
            Assert.Equal(WebHostDefaults.ContentRootKey, settings[WebHostDefaults.ContentRootKey]);
            Assert.Equal(WebHostDefaults.WebRootKey, settings[WebHostDefaults.WebRootKey]);
        }