public void GlobalDefaultConfigurationShouldNotBeEffectiveIfThereIsLocalDefault() { using (NewRemoteDocumentStore(databaseName: "Northwind")) { var server = servers[0]; var systemDatabase = server.SystemDatabase; var database = AsyncHelpers.RunSync(() => server.Server.GetDatabaseInternal("Northwind")); var retriever = database.ConfigurationRetriever; var globalSettings = new GlobalSettingsDocument { Settings = { { Constants.SizeSoftLimitInKB, "10" }, { Constants.SizeHardLimitInKB, "11" }, { Constants.DocsSoftLimit, "12" }, { Constants.DocsHardLimit, "13" } } }; systemDatabase.Documents.Put(Constants.Global.GlobalSettingsDocumentKey, null, RavenJObject.FromObject(globalSettings), new RavenJObject(), null); database.Configuration.Settings[Constants.SizeSoftLimitInKB] = "20"; database.Configuration.Settings[Constants.SizeHardLimitInKB] = "21"; database.Configuration.Settings[Constants.DocsHardLimit] = "22"; database.Configuration.Settings[Constants.DocsSoftLimit] = "23"; Assert.Equal("20", retriever.GetEffectiveConfigurationSetting(Constants.SizeSoftLimitInKB)); Assert.Equal("21", retriever.GetEffectiveConfigurationSetting(Constants.SizeHardLimitInKB)); Assert.Equal("22", retriever.GetEffectiveConfigurationSetting(Constants.DocsHardLimit)); Assert.Equal("23", retriever.GetEffectiveConfigurationSetting(Constants.DocsSoftLimit)); } }
private void LoadGlobalSettings() { var json = systemDatabase.Documents.Get(Constants.Global.GlobalSettingsDocumentKey, null); globalSettings = json != null?json.ToJson().JsonDeserialization <GlobalSettingsDocument>() : new GlobalSettingsDocument(); GlobalSettingsDocumentProtector.Unprotect(globalSettings); }
public ConfigurationSettingRetriever(DocumentDatabase systemDatabase) { this.systemDatabase = systemDatabase; systemDatabase.Notifications.OnDocumentChange += (database, notification, meta) => { if (notification.Id != Constants.Global.GlobalSettingsDocumentKey) return; globalSettings = null; }; }