Ejemplo n.º 1
0
        public void checkBehaviorGoedleWebRequestAnalyticsNoTrackWhenApiKeyIsEmpty()
        {
            _gio_object = new GoedleAnalytics("", _app_key, _user_id, _app_version, _GA_TRACKIND_ID, _app_name, _GA_CD_1, _GA_CD_2, _GA_CD_EVENT, _gio_http_client, _gw, _guh, _staging, _tracking);

            string stringContent = null;

            _guh.add(Arg.Do <string>(x => stringContent = x));
            _gw.isHttpError.Returns(false);
            _gw.isNetworkError.Returns(false);

            _gio_object.trackGroup("class", "school", _guh);
            _gio_object.track("event", _guh);
            _gio_object.track("event", "event_id", _guh);
            _gio_object.track("event", "event_id", "50", _guh);
            _gio_object.set_user_id("test_user", _guh);
            _gw.Received(0).SendWebRequest();

            _gio_object = new GoedleAnalytics(" ", _app_key, _user_id, _app_version, _GA_TRACKIND_ID, _app_name, _GA_CD_1, _GA_CD_2, _GA_CD_EVENT, _gio_http_client, _gw, _guh, _staging, _tracking);

            stringContent = null;
            _guh.add(Arg.Do <string>(x => stringContent = x));
            _gw.isHttpError.Returns(false);
            _gw.isNetworkError.Returns(false);
            _gio_object.track("event", _guh);

            _gio_object = new GoedleAnalytics(null, _app_key, _user_id, _app_version, _GA_TRACKIND_ID, _app_name, _GA_CD_1, _GA_CD_2, _GA_CD_EVENT, _gio_http_client, _gw, _guh, _staging, _tracking);

            stringContent = null;
            _guh.add(Arg.Do <string>(x => stringContent = x));
            _gw.isHttpError.Returns(false);
            _gw.isNetworkError.Returns(false);
            _gio_object.track("event", _guh);
        }
Ejemplo n.º 2
0
        public void checkBehaviorGoedleWebRequestAnalyticsGroupPOST()
        {
            _gio_object = new GoedleAnalytics(_api_key, _app_key, _user_id, _app_version, _GA_TRACKIND_ID, _app_name, _GA_CD_1, _GA_CD_2, _GA_CD_EVENT, _gio_http_client, _gw, _guh, _staging, _tracking);

            string stringContent = null;

            _guh.add(Arg.Do <string>(x => stringContent = x));

            _gw.isHttpError.Returns(false);
            _gw.isNetworkError.Returns(false);
            _gio_object.trackGroup("class", "school", _guh);
            var result = JSON.Parse(stringContent);

            Assert.AreEqual(result["event"].Value, "group");
            Assert.AreEqual(result["event_id"].Value, "class");
            Assert.AreEqual(result["event_value"].Value, "school");

            _gw.Received(2).SendWebRequest();
            _gw.Received(2).SetRequestHeader(Arg.Is <string>("Content-Type"), Arg.Is <string>("application/json"));
            _gw.Received(2).SetRequestHeader(Arg.Is <string>("Authorization"), Arg.Any <string>());
        }