예제 #1
0
        public void FlushTest()
        {
            object[] valueArray =
            {
                (byte)10, (char)11, (short)12, (int)13, (ushort)14, (UInt32)15, (UInt64)16, (long)17, "18", (float)19.0f, (double)20.0
            };

            for (int i = 0, size = valueArray.Length; i < size; i++)
            {
                PreferenceUtil.Write("key" + i.ToString(), valueArray[i]);
            }

            PreferenceUtil.Flush();

            Type       prefUtilType         = typeof(PreferenceUtil);
            MethodInfo clearCacheMethodInfo = prefUtilType.GetMethod("ClearCache", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);

            clearCacheMethodInfo.Invoke(null, null);

            for (int i = 0, size = valueArray.Length; i < size; i++)
            {
                if (!PreferenceUtil.Read("key" + i.ToString(), out object tempObject))
                {
                    Assert.Fail();
                }
            }
        }
예제 #2
0
        public void ReadWriteTest()
        {
            object[] valueArray =
            {
                (byte)10, (char)11, (short)12, (int)13, (ushort)14, (UInt32)15, (UInt64)16, (long)17, "18", (float)19.0f, (double)20.0
            };

            for (int i = 0, size = valueArray.Length; i < size; i++)
            {
                PreferenceUtil.Write("key" + i.ToString(), valueArray[i]);
            }

            for (int i = 0, size = valueArray.Length; i < size; i++)
            {
                if (PreferenceUtil.Read("key" + i.ToString(), out object tempObject))
                {
                    if (!tempObject.GetType().Equals(valueArray[i].GetType()))
                    {
                        Assert.Fail();
                    }
                }
                else
                {
                    Assert.Fail();
                }
            }

            for (int i = 0, size = valueArray.Length; i < size; i++)
            {
                if (PreferenceUtil.Read("key" + i.ToString(), out Dummy test))
                {
                    Assert.Fail();
                }
            }
        }