Exemplo n.º 1
0
        private static void ValidateStoredValues(Type type, MigrationScope migrationScope, SettingValue expectedValue)
        {
            var settings = ApplicationSettingsHelper.GetSettingsClassInstance(type);

            foreach (SettingsProperty property in settings.Properties)
            {
                string expected = CreateSettingValue(property, migrationScope, expectedValue);
                if (migrationScope == MigrationScope.User)
                {
                    if (SettingsPropertyExtensions.IsAppScoped(property))
                    {
                        continue;
                    }

                    string actual = (string)settings[property.Name];
                    Assert.AreEqual(expected, actual);
                }
                else
                {
                    if (SettingsPropertyExtensions.IsAppScoped(property))
                    {
                        string actual = (string)settings[property.Name];
                        Assert.AreEqual(expected, actual);
                    }

                    string shared = (string)ApplicationSettingsExtensions.GetSharedPropertyValue(settings, property.Name);
                    Assert.AreEqual(expected, shared);
                }
            }
        }
Exemplo n.º 2
0
        private void TestGetSharedSettings_NoneExist(Type settingsClass)
        {
            RemoveSettings(settingsClass);

            var settings = ApplicationSettingsHelper.GetSettingsClassInstance(settingsClass);

            settings.Reload();

            foreach (SettingsProperty property in settings.Properties)
            {
                var shared = settings.GetSharedPropertyValue(property.Name);
                Assert.AreEqual(property.DefaultValue, shared);

                if (SettingsPropertyExtensions.IsAppScoped(property))
                {
                    Assert.AreEqual(property.DefaultValue, settings[property.Name]);
                }
            }
        }
Exemplo n.º 3
0
        private void TestGetSharedSettings_Exists(Type settingsClass)
        {
            RemoveSettings(settingsClass);

            SystemConfigurationHelperTests.WriteSharedValuesToConfig(settingsClass, SettingValue.Current);
            var settings = ApplicationSettingsHelper.GetSettingsClassInstance(settingsClass);

            settings.Reload();

            foreach (SettingsProperty property in settings.Properties)
            {
                var    shared   = settings.GetSharedPropertyValue(property.Name);
                string expected = CreateSettingValue(property, MigrationScope.Shared, SettingValue.Current);
                Assert.AreEqual(expected, shared);

                if (SettingsPropertyExtensions.IsAppScoped(property))
                {
                    Assert.AreEqual(expected, settings[property.Name]);
                }
            }
        }