コード例 #1
0
        public void ImportSettingsShouldUpdateAndFireEvent()
        {
            int firedCount = 0;

            var settings = new SettingsContainer(string.Empty);

            settings.ValueChanged += (s, e) => firedCount++;

            settings.SetValue("A", "A");
            settings.SetValue("B", 1);
            settings.SetValue("C", true);

            firedCount.ShouldBeEquivalentTo(3);

            var importSource = new JsonObject();

            importSource.SetNamedString("A", "x");
            importSource.SetNamedNumber("B", 2);
            importSource.SetNamedBoolean("C", true);

            settings.Import(importSource);

            firedCount.ShouldBeEquivalentTo(5);

            settings.GetString("A").ShouldBeEquivalentTo("x");
            settings.GetInteger("B").ShouldBeEquivalentTo(2);
            settings.GetBoolean("C").ShouldBeEquivalentTo(true);
        }