public void ConfigurationProvidesDefaultOptions() { var certFile = Path.GetTempFileName(); var keyFile = Path.GetTempFileName(); var pfxFile = Path.GetTempFileName(); var configFile = Path.GetTempFileName(); File.WriteAllText(configFile, @$ " [config] root [serve] port = 4242 directory = {Path.GetTempPath().Replace(" \ \ ", " \ \ \ \ ")} open-browser quiet = true verbose = on cert = {certFile.Replace(" \ \ ", " \ \ \ \ ")} key = {keyFile.Replace(" \ \ ", " \ \ \ \ ")} pfx = {pfxFile.Replace(" \ \ ", " \ \ \ \ ")} pfx-pwd = password gzip cors = yes header = X-H1: value header = X-H2: value mime = .cs=text/plain mime = .vb=text/plain mime = .fs=text/plain exclude-file = app.config exclude-file = appsettings.json reverse-proxy = /api/{{**all}}=http://localhost:5000
public void ConfigurationProvidesDefaultOptions() { var certFile = Path.GetTempFileName(); var keyFile = Path.GetTempFileName(); var pfxFile = Path.GetTempFileName(); var configFile = Path.GetTempFileName(); File.WriteAllText(configFile, @$ " [config] root [serve] port = 4242 directory = {Path.GetTempPath().Replace(" \ \ ", " \ \ \ \ ")} open-browser quiet = true verbose = on cert = {certFile.Replace(" \ \ ", " \ \ \ \ ")} key = {keyFile.Replace(" \ \ ", " \ \ \ \ ")} pfx = {pfxFile.Replace(" \ \ ", " \ \ \ \ ")} pfx-pwd = password gzip cors = yes header = X-H1: value header = X-H2: value mime = .cs=text/plain mime = .vb=text/plain mime = .fs=text/plain exclude-file = app.config exclude-file = appsettings.json path-base = foo "); var program = new TestProgram(); program.Run("--config-file", configFile); var options = program.Options; Assert.True(options != null, string.Join(Environment.NewLine, program.Errors)); Assert.Equal(4242, options.Port); Assert.Equal(Path.GetTempPath(), options.Directory); Assert.True(options.OpenBrowser); Assert.True(options.Quiet); Assert.True(options.Verbose); Assert.Equal(certFile, options.CertPemPath); Assert.Equal(keyFile, options.PrivateKeyPath); Assert.Equal(pfxFile, options.CertPfxPath); Assert.Equal("password", options.CertificatePassword); Assert.True(options.UseGzip); Assert.True(options.EnableCors); Assert.Equal("foo", options.PathBase); Assert.Contains("X-H1: value", options.Headers); Assert.Contains("X-H2: value", options.Headers); Assert.Contains(".cs=text/plain", options.MimeMappings); Assert.Contains(".vb=text/plain", options.MimeMappings); Assert.Contains(".fs=text/plain", options.MimeMappings); Assert.Contains("app.config", options.ExcludedFiles); Assert.Contains("appsettings.json", options.ExcludedFiles); }