コード例 #1
0
        public void DeleteValueTest()
        {
            var value = new KeyValuePair<string, string>(Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
            var settings = new JsonSettings(GetMockFileSystem(SettingsPath), SettingsPath);

            Assert.Equal(null, settings.GetValue(value.Key));

            settings.SetValue(value.Key, value.Value);
            Assert.Equal(value.Value, settings.GetValue(value.Key));

            // Delete existing value
            Assert.Equal(true, settings.DeleteValue(value.Key));

            Assert.Equal(null, settings.GetValue(value.Key));

            // Delete non-existing value
            Assert.False(settings.DeleteValue(value.Key));
        }
コード例 #2
0
        public void SetGetValueTest()
        {
            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 }
            };

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

            foreach (KeyValuePair<string, JToken> value in values)
            {
                Assert.Equal(null, settings.GetValue(value.Key));

                settings.SetValue(value.Key, value.Value);

                Assert.Equal(value.Value, settings.GetValue(value.Key));
            }
        }
コード例 #3
0
ファイル: JsonSettingsFacts.cs プロジェクト: 40a/kudu
        public void NullOrEmptyTest()
        {
            var key = Guid.NewGuid().ToString();
            FileSystemHelpers.Instance = GetMockFileSystem(SettingsPath);
            var settings = new JsonSettings(SettingsPath);

            Assert.Equal(null, settings.GetValue(key));

            settings.SetValue(key, String.Empty);
            Assert.Equal(String.Empty, settings.GetValue(key));

            settings.SetValue(key, null);
            Assert.Equal(null, settings.GetValue(key));
        }
コード例 #4
0
        public void SetGetValueTest()
        {
            var value = new KeyValuePair<string, string>(Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
            var settings = new JsonSettings(GetMockFileSystem(SettingsPath), SettingsPath);

            Assert.Equal(null, settings.GetValue(value.Key));

            settings.SetValue(value.Key, value.Value);

            Assert.Equal(value.Value, settings.GetValue(value.Key));
        }