public void Constructor_InitializesWithDefaults() { var opts = new DiskSpaceContributorOptions(); Assert.Equal(".", opts.Path); Assert.Equal(10 * 1024 * 1024, opts.Threshold); }
public void Contstructor_BindsConfigurationCorrectly() { var appsettings = @" { 'management': { 'endpoints': { 'health' : { 'enabled': true, 'diskspace' : { 'path': 'foobar', 'threshold': 5 } } } } }"; 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(); var opts = new DiskSpaceContributorOptions(config); Assert.Equal("foobar", opts.Path); Assert.Equal(5, opts.Threshold); }
public void Constructor_BindsConfigurationCorrectly() { var appsettings = new Dictionary <string, string>() { ["management:endpoints:health:enabled"] = "true", ["management:endpoints:health:diskspace:path"] = "foobar", ["management:endpoints:health:diskspace:threshold"] = "5" }; var configurationBuilder = new ConfigurationBuilder(); configurationBuilder.AddInMemoryCollection(appsettings); var config = configurationBuilder.Build(); var opts = new DiskSpaceContributorOptions(config); Assert.Equal("foobar", opts.Path); Assert.Equal(5, opts.Threshold); }