Пример #1
0
        public IEnumerator TestLoadDefaultUser()
        {
            TestInitConditions();

            persistance.LoadDefaultUser();
            Assert.IsTrue(persistance.HasLoaded, "Persistance not loaded TestLoadDefaultUser");
            Assert.IsTrue(persistance.LoadedUserId.CompareTo(UserPersistance.DEFAULT_USER) == 0, "Persistance with wrong user at TestLoadDefaultUser");
            Assert.IsTrue(calledCallback, "Persistance did not call callback");
            Assert.IsFalse(persistance.HasStoredData(), "Persistance has stored data");
            Assert.IsFalse(persistance.HasUserStoredData(UserPersistance.DEFAULT_USER), "Persistance has stored data");

            yield return(null);
        }
Пример #2
0
        public IEnumerator TestDefaultStoreRetrieveValue()
        {
            string toStore = "hey";
            string key     = "key";

            int    toStore2 = 25;
            string key2     = "key2";

            TestStruct toStore3 = new TestStruct(45, "asdasd");
            string     key3     = "key3";

            bool   toStore4 = true;
            string key4     = "key4";


            string     toOverride  = "Override";
            int        toOverride2 = 234;
            TestStruct toOverride3 = new TestStruct(23543, "asdasf3e");

            bool toOverride4 = false;

            TestInitConditions();

            persistance.LoadDefaultUser();

            persistance.StoreValue <string>(key, toStore);
            persistance.StoreValue <int>(key2, toStore2);
            persistance.StoreValue <TestStruct>(key3, toStore3);
            persistance.StoreValue <bool>(key4, toStore4);

            Assert.IsTrue(persistance.Contains(key), "Invalid key");
            Assert.IsTrue(persistance.Contains(key2), "Invalid key");
            Assert.IsTrue(persistance.Contains(key3), "Invalid key");
            Assert.IsTrue(persistance.Contains(key4), "Invalid key");

            Assert.IsFalse(persistance.HasStoredData(), "Persistance has no stored data");
            Assert.IsFalse(persistance.HasUserStoredData(UserPersistance.DEFAULT_USER), "Persistance has default stored data");

            Assert.IsTrue(toStore.CompareTo(persistance.GetValue <string>(key)) == 0, "Invalid store/retrieve");
            Assert.IsTrue(toStore2 == persistance.GetValue <int>(key2), "Invalid store/retrieve");
            Assert.IsTrue(toStore3.Same(persistance.GetValue <TestStruct>(key3)), "Invalid store/retrieve");
            Assert.IsTrue(toStore4 == persistance.GetValue <bool>(key4), "Invalid store/retrieve");

            persistance.StoreValue <string>(key, toOverride);
            persistance.StoreValue <int>(key2, toOverride2);
            persistance.StoreValue <TestStruct>(key3, toOverride3);
            persistance.StoreValue <bool>(key4, toOverride4);
            persistance.Save();

            persistance = new UserPersistance(saveApp);
            persistance.LoadDefaultUser();

            Assert.IsTrue(toOverride.CompareTo(persistance.GetValue <string>(key)) == 0, "Invalid store/retrieve");
            Assert.IsTrue(toOverride2 == persistance.GetValue <int>(key2), "Invalid store/retrieve");
            Assert.IsTrue(toOverride3.Same(persistance.GetValue <TestStruct>(key3)), "Invalid store/retrieve");
            Assert.IsTrue(toOverride4 == persistance.GetValue <bool>(key4), "Invalid store/retrieve");

            Assert.IsTrue(persistance.HasStoredData(), "Persistance has no stored data");
            Assert.IsTrue(persistance.HasUserStoredData(UserPersistance.DEFAULT_USER), "Persistance has default stored data");

            yield return(null);
        }