public void InitializedWithDefaults() { ManagementOptions opts = ManagementOptions.GetInstance(); Assert.False(opts.Enabled.HasValue); Assert.Equal("/", opts.Path); }
public void BindsConfigurationCorrectly() { var appsettings = @" { 'management': { 'endpoints': { 'enabled': false, 'sensitive': false, 'path': '/management', 'info' : { 'enabled': true, 'sensitive': true, 'id': '/infomanagement' } } } }"; var path = TestHelpers.CreateTempFile(appsettings); string directory = Path.GetDirectoryName(path); string fileName = Path.GetFileName(path); ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder.SetBasePath(directory); configurationBuilder.AddJsonFile(fileName); var config = configurationBuilder.Build(); ManagementOptions opts = ManagementOptions.GetInstance(config); Assert.False(opts.Enabled); Assert.False(opts.Sensitive); Assert.Equal("/management", opts.Path); }
public void BindsConfigurationCorrectly() { var appsettings = new Dictionary <string, string>() { ["management:endpoints:enabled"] = "false", ["management:endpoints:path"] = "/management", ["management:endpoints:info:enabled"] = "true", ["management:endpoints:info:id"] = "/infomanagement" }; ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder.AddInMemoryCollection(appsettings); var config = configurationBuilder.Build(); ManagementOptions opts = ManagementOptions.GetInstance(config); Assert.False(opts.Enabled); Assert.Equal("/management", opts.Path); }
public void ThrowsIfConfigNull() { IConfiguration config = null; Assert.Throws <ArgumentNullException>(() => ManagementOptions.GetInstance(config)); }