Exemple #1
0
        public void SetGetValuesTest()
        {
            Random random = new Random((int)DateTime.Now.Ticks);
            var values = new Dictionary<string, JToken>
            {
                { Guid.NewGuid().ToString(), Guid.NewGuid().ToString() },
                { Guid.NewGuid().ToString(), random.Next() },
                { Guid.NewGuid().ToString(), random.Next() % 2 == 0 }
            };

            FileSystemHelpers.Instance = GetMockFileSystem(SettingsPath);

            var settings = new JsonSettings(SettingsPath);

            Assert.Equal(0, settings.GetValues().Count());

            settings.SetValues(values);

            Assert.Equal(values.Count, settings.GetValues().Count());

            foreach (KeyValuePair<string, JToken> value in settings.GetValues())
            {
                Assert.Equal(values[value.Key], value.Value);
            }

            // Update
            values[values.Keys.ElementAt(0)] = Guid.NewGuid().ToString();

            settings.SetValues(values);

            foreach (KeyValuePair<string, JToken> value in settings.GetValues())
            {
                Assert.Equal(values[value.Key], value.Value);
            }
        }
        public void SetGetValuesTest()
        {
            var values = new Dictionary<string, string>
            {
                { Guid.NewGuid().ToString(), Guid.NewGuid().ToString() },
                { Guid.NewGuid().ToString(), Guid.NewGuid().ToString() },
                { Guid.NewGuid().ToString(), Guid.NewGuid().ToString() }
            };

            var settings = new JsonSettings(GetMockFileSystem(SettingsPath), SettingsPath);

            Assert.Equal(0, settings.GetValues().Count());

            settings.SetValues(values);

            Assert.Equal(values.Count, settings.GetValues().Count());

            foreach (KeyValuePair<string, string> value in settings.GetValues())
            {
                Assert.Equal(values[value.Key], value.Value);
            }

            // Update
            values[values.Keys.ElementAt(0)] = Guid.NewGuid().ToString();

            settings.SetValues(values);

            foreach (KeyValuePair<string, string> value in settings.GetValues())
            {
                Assert.Equal(values[value.Key], value.Value);
            }
        }
Exemple #3
0
        public void SetGetJObjectTest()
        {
            var values = new Dictionary<string, JToken>
            {
                { Guid.NewGuid().ToString(), null },
                { Guid.NewGuid().ToString(), String.Empty },
                { Guid.NewGuid().ToString(), Guid.NewGuid().ToString() }
            };

            JObject json = new JObject();
            foreach (KeyValuePair<string, JToken> value in values)
            {
                json[value.Key] = value.Value;
            }

            FileSystemHelpers.Instance = GetMockFileSystem(SettingsPath);

            var settings = new JsonSettings(SettingsPath);

            Assert.Equal(0, settings.GetValues().Count());

            settings.SetValues(json);

            Assert.Equal(values.Count, settings.GetValues().Count());

            foreach (KeyValuePair<string, JToken> value in settings.GetValues())
            {
                Assert.Equal(json[value.Key], value.Value);
            }
        }
Exemple #4
0
        public void SetGetJObjectTest()
        {
            Random random = new Random((int)DateTime.Now.Ticks);
            var values = new Dictionary<string, JToken>
            {
                { Guid.NewGuid().ToString(), null },
                { Guid.NewGuid().ToString(), String.Empty },
                { Guid.NewGuid().ToString(), Guid.NewGuid().ToString() }
            };

            JObject json = new JObject();
            foreach (KeyValuePair<string, JToken> value in values)
            {
                json[value.Key] = value.Value;
            }

            var settings = new JsonSettings(GetMockFileSystem(SettingsPath), SettingsPath);

            Assert.Equal(0, settings.GetValues().Count());

            settings.SetValues(json);

            Assert.Equal(values.Count, settings.GetValues().Count());

            foreach (KeyValuePair<string, JToken> value in settings.GetValues())
            {
                Assert.Equal(json[value.Key], value.Value);
            }
        }