public void TestDefaultNullValue() { var key = "aKeyThatDoesNotExist"; PlayerPrefsV2.DeleteKey(key); // ensure it does not exist // WHYYYY would you doo that Unity: Assert.AreEqual("", UnityEngine.PlayerPrefs.GetString(key, defaultValue: null)); Assert.AreEqual(null, PlayerPrefsV2.GetString(key, defaultValue: null)); }
public void TestGetAndSetEncyptedString() { var key = "b1"; var value = "val 1"; var password = "******"; PlayerPrefsV2.DeleteKey(key); Assert.AreEqual(null, PlayerPrefsV2.GetStringDecrypted(key, null, password)); PlayerPrefsV2.SetStringEncrypted(key, value, password); Assert.AreEqual(value, PlayerPrefsV2.GetStringDecrypted(key, null, password)); Assert.AreNotEqual(value, PlayerPrefsV2.GetStringDecrypted(key, null, "incorrect password")); Assert.AreNotEqual(value, PlayerPrefsV2.GetString(key, null)); PlayerPrefsV2.DeleteKey(key); }
private T InternalGet <T>(string key, T defaultValue) { if (!PlayerPrefsV2.HasKey(key)) { return(defaultValue); } var value = PlayerPrefsV2.GetString(key); var wrapper = jsonReader.Read <ValueWrapper>(value); if (wrapper == null) { Log.e($"Entry not a ValueWrapper but instead: '{value}'"); return(defaultValue); } return(wrapper.GetValueAs <T>()); }