public IEnumerator AppendAsync()
    {
        var data = "new data " + Guid.NewGuid().ToString();

        Autoya.Persist_Update(AutoyaFilePersistTestsFileDomain, AutoyaFilePersistTestsFileName, data);

        var loadedData = string.Empty;

        var appendData = "append data " + Guid.NewGuid().ToString();

        Autoya.Persist_Append(
            AutoyaFilePersistTestsFileDomain,
            AutoyaFilePersistTestsFileName,
            appendData,
            () =>
        {
            loadedData = Autoya.Persist_Load(AutoyaFilePersistTestsFileDomain, AutoyaFilePersistTestsFileName);
        },
            reason => { }
            );

        yield return(WaitUntil(
                         () => loadedData == data + appendData,
                         () => { throw new TimeoutException("too late."); }
                         ));
    }
    public IEnumerator Update()
    {
        var data = "new data " + Guid.NewGuid().ToString();

        var result = Autoya.Persist_Update(AutoyaFilePersistTestsFileDomain, AutoyaFilePersistTestsFileName, data);

        True(result, "not successed.");
        yield break;
    }
    public IEnumerator CreateFileThenDeleteFileThenFileNamesInDomain()
    {
        Autoya.Persist_Update("testdomain", "testfile", "test");
        Autoya.Persist_Delete("testdomain", "testfile");
        var fileNamesInDomain = Autoya.Persist_FileNamesInDomain("testdomain");

        True(fileNamesInDomain.Length == 0, "not match.");
        yield break;
    }
    public IEnumerator Delete()
    {
        var data = "new data " + Guid.NewGuid().ToString();

        Autoya.Persist_Update(AutoyaFilePersistTestsFileDomain, AutoyaFilePersistTestsFileName, data);

        var deleted = Autoya.Persist_Delete(AutoyaFilePersistTestsFileDomain, AutoyaFilePersistTestsFileName);

        True(deleted, "failed to delete.");
        yield break;
    }
    public IEnumerator Load()
    {
        var data = "new data " + Guid.NewGuid().ToString();

        Autoya.Persist_Update(AutoyaFilePersistTestsFileDomain, AutoyaFilePersistTestsFileName, data);

        var loadedData = Autoya.Persist_Load(AutoyaFilePersistTestsFileDomain, AutoyaFilePersistTestsFileName);

        True(loadedData == data, "data does not match. loadedData:" + loadedData);
        yield break;
    }
    /*
     *      sync series.
     */
    [MTest] public void Update()
    {
        Action onMainThread = () => {
            var data = "new data " + Guid.NewGuid().ToString();

            var result = Autoya.Persist_Update(AutoyaFilePersistTestsFileDomain, AutoyaFilePersistTestsFileName, data);
            Assert(result, "not successed.");
        };

        RunOnMainThread(onMainThread);
    }
    [MTest] public void CreateFileThenDeleteFileThenFileNamesInDomain()
    {
        Action onMainThread = () => {
            Autoya.Persist_Update("testdomain", "testfile", "test");
            Autoya.Persist_Delete("testdomain", "testfile");
            var fileNamesInDomain = Autoya.Persist_FileNamesInDomain("testdomain");
            Assert(fileNamesInDomain.Length == 0, "not match.");
        };

        RunOnMainThread(onMainThread);
    }
    public IEnumerable IsMustBeExist()
    {
        var data = "new data " + Guid.NewGuid().ToString();

        Autoya.Persist_Update(AutoyaFilePersistTestsFileDomain, AutoyaFilePersistTestsFileName, data);

        var result = Autoya.Persist_IsExist(AutoyaFilePersistTestsFileDomain, AutoyaFilePersistTestsFileName);

        True(!result, "should not be exist.");
        yield break;
    }
    public IEnumerator FileNamesInDomain()
    {
        var data = "new data " + Guid.NewGuid().ToString();

        Autoya.Persist_Update(AutoyaFilePersistTestsFileDomain, AutoyaFilePersistTestsFileName, data);

        var fileNamesInDomain = Autoya.Persist_FileNamesInDomain(AutoyaFilePersistTestsFileDomain);

        True(fileNamesInDomain.Length == 1, "not match.");

        yield break;
    }
    [MTest] public void FileNamesInDomain()
    {
        Action onMainThread = () => {
            var data = "new data " + Guid.NewGuid().ToString();
            Autoya.Persist_Update(AutoyaFilePersistTestsFileDomain, AutoyaFilePersistTestsFileName, data);

            var fileNamesInDomain = Autoya.Persist_FileNamesInDomain(AutoyaFilePersistTestsFileDomain);
            Assert(fileNamesInDomain.Length == 1, "not match.");
        };

        RunOnMainThread(onMainThread);
    }
    [MTest] public void Delete()
    {
        Action onMainThread = () => {
            var data = "new data " + Guid.NewGuid().ToString();

            Autoya.Persist_Update(AutoyaFilePersistTestsFileDomain, AutoyaFilePersistTestsFileName, data);

            var deleted = Autoya.Persist_Delete(AutoyaFilePersistTestsFileDomain, AutoyaFilePersistTestsFileName);
            Assert(deleted, "failed to delete.");
        };

        RunOnMainThread(onMainThread);
    }
    [MTest] public void Load()
    {
        Action onMainThread = () => {
            var data = "new data " + Guid.NewGuid().ToString();

            Autoya.Persist_Update(AutoyaFilePersistTestsFileDomain, AutoyaFilePersistTestsFileName, data);

            var loadedData = Autoya.Persist_Load(AutoyaFilePersistTestsFileDomain, AutoyaFilePersistTestsFileName);
            Assert(loadedData == data, "data does not match. loadedData:" + loadedData);
        };

        RunOnMainThread(onMainThread);
    }
    public IEnumerator UpdateAsync()
    {
        var data      = "new data " + Guid.NewGuid().ToString();
        var succeeded = false;

        Autoya.Persist_Update(
            AutoyaFilePersistTestsFileDomain,
            AutoyaFilePersistTestsFileName,
            data,
            () =>
        {
            succeeded = true;
        },
            reason => { }
            );

        yield return(WaitUntil(
                         () => succeeded,
                         () => { throw new TimeoutException("too late."); }
                         ));
    }
    public IEnumerator DeleteByDomainAsync()
    {
        var data = "new data " + Guid.NewGuid().ToString();

        Autoya.Persist_Update(AutoyaFilePersistTestsFileDomain, AutoyaFilePersistTestsFileName + "1", data);
        Autoya.Persist_Update(AutoyaFilePersistTestsFileDomain, AutoyaFilePersistTestsFileName + "2", data);
        Autoya.Persist_Update(AutoyaFilePersistTestsFileDomain, AutoyaFilePersistTestsFileName + "3", data);

        var deleted = false;

        Autoya.Persist_DeleteByDomain(
            AutoyaFilePersistTestsFileDomain,
            () =>
        {
            deleted = true;
        },
            reason => { }
            );

        yield return(WaitUntil(
                         () => deleted,
                         () => { throw new TimeoutException("too late."); }
                         ));
    }
Ejemplo n.º 15
0
    public IEnumerator RemoveUnnecessaryStoredAssetBundleListOnBoot()
    {
        // 事前に保存済みのデータを消す、これでほかのテストの影響を受けない初期化されたデータだけができる。
        Autoya.Persist_DeleteByDomain(AppSettings.APP_STORED_RUNTIME_MANIFEST_DOMAIN);
        Autoya.Persist_DeleteByDomain(AssetBundlesSettings.ASSETBUNDLES_LIST_STORED_DOMAIN);

        var dataPath = Application.persistentDataPath;

        Autoya.TestEntryPoint(dataPath);
        {
            var loginDone = false;
            Autoya.Auth_SetOnAuthenticated(
                () =>
            {
                loginDone = true;
            }
                );

            yield return(WaitUntil(
                             () =>
            {
                return loginDone;
            },
                             () => { throw new TimeoutException("timeout."); }
                             ));
        }
        var abReady = false;

        Autoya.AssetBundle_DownloadAssetBundleListsIfNeed(
            results =>
        {
            abReady = true;
        },
            (code, reason, status) =>
        {
            Debug.LogError("failed to download ABList, code:" + code + " reason:" + reason);
        }
            );
        while (!abReady)
        {
            yield return(null);
        }

        var defaultGeneratedABListIdentities = Autoya.AssetBundle_AssetBundleLists().Select(list => list.identity).ToArray();

        // このあとまたAutoyaを起動するので、ABListがあるdomainに存在するファイルに、独自の「アプリのアプデでいらなくなった」という状態のリストを追加する。
        var dummyListIdentity = "dummy_reomved";
        var removedABListStr  = "{\"identity\":\"" + dummyListIdentity + "\",\"target\":\"iOS\",\"version\":\"1.0.0\",\"assetBundles\":[{\"bundleName\":\"sample\",\"assetNames\":[\"Assets/AutoyaTests/RuntimeData/AssetBundles/SubResources/sample.txt\"],\"dependsBundleNames\":[],\"crc\":1672014196,\"hash\":\"720461ec2bb1aecd2ce41903f3a7d205\",\"size\":754}]}";

        Autoya.Persist_Update(AssetBundlesSettings.ASSETBUNDLES_LIST_STORED_DOMAIN, "dummyList.json", removedABListStr);

        Autoya.TestEntryPoint(dataPath);

        {
            var loginDone = false;
            Autoya.Auth_SetOnAuthenticated(
                () =>
            {
                loginDone = true;
            }
                );

            yield return(WaitUntil(
                             () =>
            {
                return loginDone;
            },
                             () => { throw new TimeoutException("timeout."); }
                             ));
        }

        abReady = false;

        Autoya.AssetBundle_DownloadAssetBundleListsIfNeed(
            results =>
        {
            abReady = true;
        },
            (code, reason, status) =>
        {
            Debug.LogError("failed to download ABList, code:" + code + " reason:" + reason);
        }
            );

        while (!abReady)
        {
            yield return(null);
        }

        // dummy abList should be deleted.
        var lists            = Autoya.AssetBundle_AssetBundleLists();
        var storedIdentities = lists.Select(list => list.identity).ToArray();

        Assert.True(!storedIdentities.Contains(dummyListIdentity), "contained.");

        // all identites are matched.
        foreach (var defaultGeneratedABListIdentitiy in defaultGeneratedABListIdentities)
        {
            Assert.True(storedIdentities.Contains(defaultGeneratedABListIdentitiy), "not contained.");
        }

        foreach (var storedIdentity in storedIdentities)
        {
            Assert.True(defaultGeneratedABListIdentities.Contains(storedIdentity), "not contained.");
        }
    }