示例#1
0
        public void GivenForBool_WhenSet_ThenBoolStored()
        {
            PlayerPrefs.SetInt(TestKey, 0);

            PowerPrefs.ForBool().Set(TestKey, true);

            Assert.That(PlayerPrefs.GetInt(TestKey, 100), Is.EqualTo(1));
        }
示例#2
0
        public void GivenForBool_WhenGet_ThenBoolRetrieved()
        {
            PlayerPrefs.SetInt(TestKey, 0);

            var actual = PowerPrefs.ForBool().Get(TestKey, true);

            Assert.That(actual, Is.False);
        }
示例#3
0
        public void GivenForString_WhenGet_ThenStringRetrieved()
        {
            var expected = "someOldValue";

            PlayerPrefs.SetString(TestKey, expected);

            var actual = PowerPrefs.ForString().Get(TestKey, "");

            Assert.That(actual, Is.EqualTo(expected));
        }
示例#4
0
        public void GivenForInt_WhenSet_ThenIntStored()
        {
            var expected = 100;

            PlayerPrefs.SetInt(TestKey, 10);

            PowerPrefs.ForInt().Set(TestKey, expected);

            Assert.That(PlayerPrefs.GetInt(TestKey, 10), Is.EqualTo(expected));
        }
示例#5
0
        public void GivenForInt_WhenGet_ThenIntRetrieved()
        {
            var expected = 10;

            PlayerPrefs.SetInt(TestKey, expected);

            var actual = PowerPrefs.ForInt().Get(TestKey, 100);

            Assert.That(actual, Is.EqualTo(expected));
        }
示例#6
0
        public void GivenForFloat_WhenSet_ThenFloatStored()
        {
            var expected = 100f;

            PlayerPrefs.SetFloat(TestKey, 10f);

            PowerPrefs.ForFloat().Set(TestKey, expected);

            Assert.That(PlayerPrefs.GetFloat(TestKey, 10f), Is.EqualTo(expected));
        }
示例#7
0
        public void GivenForChar_WhenSet_ThenCharStoredAsString()
        {
            var expected = 'a';

            PlayerPrefs.SetString(TestKey, "someOldValue");

            PowerPrefs.ForChar().Set(TestKey, expected);

            Assert.That(PlayerPrefs.GetString(TestKey, "")[0], Is.EqualTo(expected));
        }
示例#8
0
        public void GivenForDateTime_WhenGet_ThenDateTimeRetrieved()
        {
            var expected = new DateTime(123456);

            PlayerPrefs.SetString(TestKey, expected.Ticks.ToString());

            var actual = PowerPrefs.ForDateTime().Get(TestKey, new DateTime(10));

            Assert.That(actual, Is.EqualTo(expected));
        }
示例#9
0
        public void GivenForDouble_WhenGet_ThenDoubleRetrieved()
        {
            var expected = 123;

            PlayerPrefs.SetString(TestKey, expected.ToString());

            var actual = PowerPrefs.ForDouble().Get(TestKey, -1);

            Assert.That(actual, Is.EqualTo(expected));
        }
示例#10
0
        public void GivenForChar_WhenGet_ThenCharRetrieved()
        {
            var expected = 'd';

            PlayerPrefs.SetString(TestKey, expected.ToString());

            var actual = PowerPrefs.ForChar().Get(TestKey, 'x');

            Assert.That(actual, Is.EqualTo(expected));
        }
示例#11
0
        public void GivenForString_WhenSet_ThenStringStored()
        {
            var expected = "someNewValue";

            PlayerPrefs.SetString(TestKey, "someOldValue");

            PowerPrefs.ForString().Set(TestKey, expected);

            Assert.That(PlayerPrefs.GetString(TestKey, ""), Is.EqualTo(expected));
        }
示例#12
0
        public void GivenForDateTime_WhenSet_ThenDateTimeStoredAsString()
        {
            var expected = new DateTime(11111);

            PlayerPrefs.SetString(TestKey, "55");

            PowerPrefs.ForDateTime().Set(TestKey, expected);

            var actual = new DateTime(long.Parse(PlayerPrefs.GetString(TestKey, "-1")));

            Assert.That(actual, Is.EqualTo(expected));
        }
示例#13
0
        public void GivenForDouble_WhenSet_ThenDoubleStoredAsString()
        {
            var expected = 22;

            PlayerPrefs.SetString(TestKey, "55");

            PowerPrefs.ForDouble().Set(TestKey, expected);

            var actual = double.Parse(PlayerPrefs.GetString(TestKey, "-1"));

            Assert.That(actual, Is.EqualTo(expected));
        }
示例#14
0
 void Awake()
 {
     accessor = PowerPrefs.ForInt().KeyAccessor(KeyCounter);
     CounterChanged(accessor.Get());
 }
示例#15
0
 public void InputValueChanged(string input)
 {
     PowerPrefs.ForString().Set(KeyInput, input);
 }
示例#16
0
        void Awake()
        {
            var inputValue = PowerPrefs.ForString().Get(KeyInput, "Default");

            inputField.text = inputValue;
        }