Exemplo n.º 1
0
        public static void Default_2_LoadPreferencesAsync()
        {
            var preferenceFactory = PreferenceFactory.GetInstance();

            Assert.NotNull(preferenceFactory);
            var preferences = preferenceFactory.LoadPreferencesAsync().Result;

            Assert.NotNull(preferences);
            Assert.Equal("DefaultPreferences", preferences.ToString());
        }
Exemplo n.º 2
0
        public static void Preference_03_PutInt()
        {
            var preferenceFactory = PreferenceFactory.GetInstance();

            Assert.NotNull(preferenceFactory);
            var preferences = preferenceFactory.LoadPreferences();

            Assert.NotNull(preferences);
            preferences.Put("key", 1);
            Assert.NotNull(preferences);
        }
Exemplo n.º 3
0
        public static void Preference_05_PutString()
        {
            var preferenceFactory = PreferenceFactory.GetInstance();

            Assert.NotNull(preferenceFactory);
            var preferences = preferenceFactory.LoadPreferences();

            Assert.NotNull(preferences);
            preferences.Put("key", "test");
            Assert.NotNull(preferences);
        }
Exemplo n.º 4
0
        public static void Preference_14_Unicode()
        {
            var preferenceFactory = PreferenceFactory.GetInstance();

            Assert.NotNull(preferenceFactory);
            var preferences = preferenceFactory.LoadPreferences();

            Assert.NotNull(preferences);
            preferences.Put("unicode", "測試");
            Assert.NotNull(preferences);
            preferences.Commit();
        }
Exemplo n.º 5
0
        public static void Preference_11_ParseString()
        {
            var preferenceFactory = PreferenceFactory.GetInstance();

            Assert.NotNull(preferenceFactory);
            var preferences = preferenceFactory.LoadPreferences();

            Assert.NotNull(preferences);
            preferences.Put("key", "test");
            Assert.NotNull(preferences);
            Assert.Equal("test", preferences.ParseString("key"));
        }
Exemplo n.º 6
0
        public static void Preference_10_ParseLong_WithDefault()
        {
            var preferenceFactory = PreferenceFactory.GetInstance();

            Assert.NotNull(preferenceFactory);
            var preferences = preferenceFactory.LoadPreferences();

            Assert.NotNull(preferences);
            preferences.Put("key", 100000000000L);
            Assert.NotNull(preferences);
            Assert.Equal(100000000000L, preferences.ParseLong("key"));
            Assert.Equal(0L, preferences.ParseLong("key2"));
            Assert.Equal(200000000001L, preferences.ParseLong("key3", 200000000001L));
        }
Exemplo n.º 7
0
        public static void Preference_09_ParseInt_WithDefault()
        {
            var preferenceFactory = PreferenceFactory.GetInstance();

            Assert.NotNull(preferenceFactory);
            var preferences = preferenceFactory.LoadPreferences();

            Assert.NotNull(preferences);
            preferences.Put("key", 1);
            Assert.NotNull(preferences);
            Assert.Equal(1, preferences.ParseInt("key"));
            Assert.Equal(0, preferences.ParseInt("key2"));
            Assert.Equal(1, preferences.ParseInt("key3", 1));
        }
Exemplo n.º 8
0
        public static void Preference_08_ParseFloat_WithDefault()
        {
            var preferenceFactory = PreferenceFactory.GetInstance();

            Assert.NotNull(preferenceFactory);
            var preferences = preferenceFactory.LoadPreferences();

            Assert.NotNull(preferences);
            preferences.Put("key", 1.1F);
            Assert.NotNull(preferences);
            Assert.Equal(1.1F, preferences.ParseFloat("key"));
            Assert.Equal(0.0F, preferences.ParseFloat("key2"));
            Assert.Equal(1.1F, preferences.ParseFloat("key3", 1.1F));
        }
Exemplo n.º 9
0
        public static void Preference_07_ParseDouble_WithDefault()
        {
            var preferenceFactory = PreferenceFactory.GetInstance();

            Assert.NotNull(preferenceFactory);
            var preferences = preferenceFactory.LoadPreferences();

            Assert.NotNull(preferences);
            preferences.Put("key", 1.1D);
            Assert.NotNull(preferences);
            Assert.Equal(1.1D, preferences.ParseDouble("key"));
            Assert.Equal(0.0D, preferences.ParseDouble("key2"));
            Assert.Equal(1.1D, preferences.ParseDouble("key3", 1.1D));
        }
Exemplo n.º 10
0
        public static void Preference_06_ParseBool_WithDefault()
        {
            var preferenceFactory = PreferenceFactory.GetInstance();

            Assert.NotNull(preferenceFactory);
            var preferences = preferenceFactory.LoadPreferences();

            Assert.NotNull(preferences);
            preferences.Put("key", true);
            Assert.NotNull(preferences);
            Assert.True(preferences.ParseBool("key"));
            Assert.False(preferences.ParseBool("key2"));
            Assert.True(preferences.ParseBool("key3", true));
        }
Exemplo n.º 11
0
        public static void Preference_12_CommitAsync()
        {
            var preferenceFactory = PreferenceFactory.GetInstance();

            Assert.NotNull(preferenceFactory);
            var preferences = preferenceFactory.LoadPreferencesAsync().Result;

            Assert.NotNull(preferences);
            preferences.Put("key11", "test");
            Assert.NotNull(preferences);
            preferences.Put("key12", 1);
            preferences.Put("key13", 2.2D);
            preferences.Put("key14", true);
            preferences.CommitAsync().GetAwaiter().GetResult();
            Assert.NotNull(preferences);
            var preferences2 = preferenceFactory.LoadPreferencesAsync().Result;

            Assert.NotNull(preferences2);
            Assert.Equal("test", preferences2.ParseString("key11"));
            Assert.Equal(1, preferences2.ParseInt("key12"));
            Assert.Equal(2.2D, preferences2.ParseDouble("key13"));
            Assert.True(preferences2.ParseBool("key14"));
        }
Exemplo n.º 12
0
        public static void Preference_13_Clear()
        {
            var preferenceFactory = PreferenceFactory.GetInstance();

            Assert.NotNull(preferenceFactory);
            var preferences = preferenceFactory.LoadPreferences();

            Assert.NotNull(preferences);
            preferences.Put("key11", "test");
            Assert.NotNull(preferences);
            preferences.Put("key12", 1);
            preferences.Put("key13", 2.2D);
            preferences.Put("key14", true);
            preferences.Clear();
            preferences.Commit();
            Assert.NotNull(preferences);
            var preferences2 = preferenceFactory.LoadPreferences();

            Assert.NotNull(preferences2);
            Assert.Null(preferences2.ParseString("key11"));
            Assert.Equal(0, preferences2.ParseInt("key12"));
            Assert.Equal(0.0D, preferences2.ParseDouble("key13"));
            Assert.False(preferences2.ParseBool("key14"));
        }
Exemplo n.º 13
0
        public static void Default_0_GetInstance()
        {
            var preferenceFactory = PreferenceFactory.GetInstance();

            Assert.NotNull(preferenceFactory);
        }
Exemplo n.º 14
0
        public static void Default_1_GetInstance_WithType()
        {
            var preferenceFactory = PreferenceFactory.GetInstance <DefaultPreferenceFactory>();

            Assert.NotNull(preferenceFactory);
        }