コード例 #1
0
ファイル: DidomiTests.cs プロジェクト: didomi/unity
        public IEnumerator RunAll(MonoBehaviour mono, bool remoteNotice = false)
        {
            this.mono = mono;
            _logs     = string.Empty;
            try
            {
                string apiKey   = remoteNotice ? "9bf8a7e4-db9a-4ff2-a45c-ab7d2b6eadba" : "c3cd5b46-bf36-4700-bbdc-4ee9176045aa";
                string noticeId = remoteNotice ? "Ar7NPQ72" : null;
                string localConfigurationPath    = null;
                string remoteConfigurationURL    = null;
                string providerId                = null;
                bool   disableDidomiRemoteConfig = !remoteNotice;
                string languageCode              = null;

                Debug.Log("Tests: Initializing sdk");
                _logs += $"{Environment.NewLine}Initializing sdk - ";

                Didomi didomi = Didomi.GetInstance();
                if (Application.platform == RuntimePlatform.Android && didomi.IsReady())
                {
                    throw new Exception("SDK was already initialized. To run the tests, close and restart the app without initializing SDK.");
                }

                didomi.Initialize(
                    apiKey,
                    localConfigurationPath,
                    remoteConfigurationURL,
                    providerId,
                    disableDidomiRemoteConfig,
                    languageCode,
                    noticeId);

                didomi.OnReady(
                    () => {
                    mono.StartCoroutine(RunTests(remoteNotice));
                }
                    );
                didomi.OnError(
                    () => {
                    _logs        += $"{Environment.NewLine}Error initializing SDK.";
                    testsComplete = true;
                }
                    );
            }
            catch (Exception ex)
            {
                _logs        += $"{Environment.NewLine}Exception : {ex.Message}";
                _logs        += $"{Environment.NewLine}Exception : {ex.StackTrace}";
                testsFailure  = true;
                testsComplete = true;
            }

            yield return(new WaitUntil(() => testsComplete));
        }