Пример #1
0
        public IEnumerator TestIdentify()
        {
            PlayModeTestHelper.StartMockServer();

            JObject userInfo = new JObject();

            userInfo.Add("str", "foo");
            Tracker.Identify(userInfo);

            yield return(new WaitForSeconds(5));

            bool eventSent = false;

            while (true)
            {
                eventSent = PlayModeTestHelper.IsEventSent("identify");
                if (eventSent)
                {
                    break;
                }
                yield return(null);
            }
            Assert.True(eventSent);

            PlayModeTestHelper.StopMockServer();
        }
Пример #2
0
        public IEnumerator TestFetchWithCompletion()
        {
            string        json = @"
{
    ""response"": {
        ""messages"": [
            {
                ""action"": {
                    ""campaign_id"": ""sample_campaign"",
                    ""shorten_id"": ""sample_shorten"",
                    ""content"": {
                        ""inlined_variables"": [
                            {""name"": ""strvar"", ""value"": ""foo""}
                        ]
                    },
                    ""plugin_type"": ""remote_config""
                },
                ""campaign"": {
                    ""_id"": ""sample_campaign"",
                    ""service_action_type"": ""remote_config""
                }
            }
        ]
    }
}";
            ExpectedEvent e    = new ExpectedEvent("_fetch_variables", json);

            ExpectedEvent[] events = new ExpectedEvent[] { e };
            PlayModeTestHelper.StartMockServer(events);

            bool done = false;

            Variables.FetchWithCompletion((result) => {
                Assert.True(result);
                Variable var = Variables.GetVariable("strvar");
                Assert.AreEqual("foo", var.GetString("bar"));
                done = true;
            });

            bool eventSent = false;

            while (!eventSent || !done)
            {
                eventSent = PlayModeTestHelper.IsEventSent("_message_ready");
                yield return(null);
            }
            Assert.True(eventSent);
            Assert.True(done);

            PlayModeTestHelper.StopMockServer();
        }
Пример #3
0
        public IEnumerator TestFetch()
        {
            PlayModeTestHelper.StartMockServer();

            Variables.Fetch();

            bool eventSent = false;

            while (true)
            {
                eventSent = PlayModeTestHelper.IsEventSent("_fetch_variables");
                if (eventSent)
                {
                    break;
                }
                yield return(null);
            }
            Assert.True(eventSent);

            PlayModeTestHelper.StopMockServer();
        }
Пример #4
0
        public IEnumerator TestViewWithTitle()
        {
            PlayModeTestHelper.StartMockServer();

            Tracker.View("main", "title", null);

            bool eventSent = false;

            while (true)
            {
                eventSent = PlayModeTestHelper.IsEventSent("view");
                if (eventSent)
                {
                    break;
                }
                yield return(null);
            }
            Assert.True(eventSent);

            PlayModeTestHelper.StopMockServer();
        }
Пример #5
0
        public IEnumerator TestLogout()
        {
            PlayModeTestHelper.StartMockServer();

            App.RenewVisitorId();

            bool eventSent = false;

            while (true)
            {
                eventSent = PlayModeTestHelper.IsEventSent("plugin_native_app_identify");
                if (eventSent)
                {
                    break;
                }
                yield return(null);
            }
            Assert.True(eventSent);

            PlayModeTestHelper.StopMockServer();
        }
Пример #6
0
        public IEnumerator TestRegisterFCMToken()
        {
            PlayModeTestHelper.StartMockServer();

            App.RegisterFCMToken("fmctoken");

            bool eventSent = false;

            while (true)
            {
                eventSent = PlayModeTestHelper.IsEventSent("plugin_native_app_identify");
                if (eventSent)
                {
                    break;
                }
                yield return(null);
            }
            Assert.True(eventSent);

            PlayModeTestHelper.StopMockServer();
        }
Пример #7
0
        public IEnumerator TestViewWithTitleAndValues()
        {
            PlayModeTestHelper.StartMockServer();

            JObject values = new JObject();

            values.Add("value1", "foo");
            Tracker.View("main", "title", values);

            bool eventSent = false;

            while (true)
            {
                eventSent = PlayModeTestHelper.IsEventSent("view");
                if (eventSent)
                {
                    break;
                }
                yield return(null);
            }
            Assert.True(eventSent);

            PlayModeTestHelper.StopMockServer();
        }