public void CanUpdateSettingsFromServer() { var config = new ExceptionlessConfiguration(DependencyResolver.Default) { ApiKey = "LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw", Settings = { ["LocalSetting"] = "1", ["LocalSettingToOverride"] = "1" } }; var submissionClient = new Mock <ISubmissionClient>(); submissionClient.Setup(m => m.PostEvents(It.IsAny <IEnumerable <Event> >(), config, It.IsAny <IJsonSerializer>())) .Callback(() => SettingsManager.CheckVersion(1, config)) .Returns(() => new SubmissionResponse(202, "Accepted")); submissionClient.Setup(m => m.GetSettings(config, 0, It.IsAny <IJsonSerializer>())) .Returns(() => new SettingsResponse(true, new SettingsDictionary { { "Test", "Test" }, { "LocalSettingToOverride", "2" } }, 1)); config.Resolver.Register <ISubmissionClient>(submissionClient.Object); var client = new ExceptionlessClient(config); Assert.Equal(2, client.Configuration.Settings.Count); Assert.False(client.Configuration.Settings.ContainsKey("Test")); Assert.Equal("1", client.Configuration.Settings["LocalSettingToOverride"]); client.SubmitEvent(new Event { Type = "Log", Message = "Test" }); client.ProcessQueue(); Assert.True(client.Configuration.Settings.ContainsKey("Test")); Assert.Equal("2", client.Configuration.Settings["LocalSettingToOverride"]); Assert.Equal(3, client.Configuration.Settings.Count); var storage = config.Resolver.GetFileStorage() as InMemoryObjectStorage; Assert.NotNull(storage); Assert.NotNull(config.GetQueueName()); Assert.True(storage.Exists(Path.Combine(config.GetQueueName(), "server-settings.json"))); config.Settings.Clear(); config.ApplySavedServerSettings(); Assert.True(client.Configuration.Settings.ContainsKey("Test")); Assert.Equal("2", client.Configuration.Settings["LocalSettingToOverride"]); Assert.Equal(2, client.Configuration.Settings.Count); }
public void CanUpdateSettingsFromServer() { var config = new ExceptionlessConfiguration(DependencyResolver.Default); config.ApiKey = "e3d51ea621464280bbcb79c11fd6483e"; config.Settings["LocalSetting"] = "1"; config.Settings["LocalSettingToOverride"] = "1"; var submissionClient = new Mock<ISubmissionClient>(); submissionClient.Setup(m => m.Submit(It.IsAny<IEnumerable<Event>>(), config, It.IsAny<IJsonSerializer>())) .Callback(() => SettingsManager.CheckVersion(1, config)) .Returns(() => new SubmissionResponse(202, "Accepted")); submissionClient.Setup(m => m.GetSettings(config, It.IsAny<IJsonSerializer>())) .Returns(() => new SettingsResponse(true, new SettingsDictionary { { "Test", "Test" }, { "LocalSettingToOverride", "2" } }, 1)); config.Resolver.Register<ISubmissionClient>(submissionClient.Object); var client = new ExceptionlessClient(config); Assert.Equal(2, client.Configuration.Settings.Count); Assert.False(client.Configuration.Settings.ContainsKey("Test")); Assert.Equal("1", client.Configuration.Settings["LocalSettingToOverride"]); client.SubmitEvent(new Event { Type = "Log", Message = "Test" }); client.ProcessQueue(); Assert.True(client.Configuration.Settings.ContainsKey("Test")); Assert.Equal("2", client.Configuration.Settings["LocalSettingToOverride"]); Assert.Equal(3, client.Configuration.Settings.Count); var storage = config.Resolver.GetFileStorage() as InMemoryFileStorage; Assert.True(storage.Exists(config.GetQueueName() + "\\server-settings.json")); config.Settings.Clear(); config.ApplySavedServerSettings(); Assert.True(client.Configuration.Settings.ContainsKey("Test")); Assert.Equal("2", client.Configuration.Settings["LocalSettingToOverride"]); Assert.Equal(2, client.Configuration.Settings.Count); }