本文整理汇总了C#中ExceptionlessConfiguration.ApplySavedServerSettings方法的典型用法代码示例。如果您正苦于以下问题:C# ExceptionlessConfiguration.ApplySavedServerSettings方法的具体用法?C# ExceptionlessConfiguration.ApplySavedServerSettings怎么用?C# ExceptionlessConfiguration.ApplySavedServerSettings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExceptionlessConfiguration
的用法示例。
在下文中一共展示了ExceptionlessConfiguration.ApplySavedServerSettings方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanUpdateSettingsFromServer
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);
}