Esempio n. 1
0
        public void MeasurementUriBuilderTests_BuildUri_Emits_SessionControl_end_At_End()
        {
            var config         = MeasurementTestHelpers.Configuration;
            var sessionManager = MeasurementTestHelpers.CreateSessionManager();
            var builder        = new MeasurementUriBuilder(config, sessionManager, MeasurementTestHelpers.CreateEnvironment());

            sessionManager.End();
            var actual = builder.BuildUri(new EventActivity("Action", "Category"));

            StringAssert.Contains(actual.Query, "sc=end");
        }
Esempio n. 2
0
        public void MeasurementUriBuilderTests_BuildUri_Emits_No_SessionControl_After_Start()
        {
            var config         = MeasurementTestHelpers.Configuration;
            var sessionManager = MeasurementTestHelpers.CreateSessionManager();
            var builder        = new MeasurementUriBuilder(config, sessionManager, MeasurementTestHelpers.CreateEnvironment());

            sessionManager.Hit();
            var actual = builder.BuildUri(new ScreenViewActivity("Page2"));

            var parameters = actual.Query.Split('&').Select(p => p.Split('=')).ToDictionary(k => k[0], v => v.Length == 0 ? null : v[1]);

            CollectionAssert.DoesNotContain(parameters.Keys, "sc");
        }
Esempio n. 3
0
        public void MeasurementTracker_Track_Carries_Forward_Last_Transaction()
        {
            var actual  = new List <Uri>();
            var tracker = new MeasurementTracker(MeasurementTestHelpers.Configuration, MeasurementTestHelpers.CreateSessionManager(), MeasurementTestHelpers.CreateEnvironment(), actual.Add);

            var transaction = new TransactionActivity {
                OrderId = "123", Currency = "GBP"
            };

            tracker.Track(new MeasurementActivityEntry(transaction));

            var transactionItem = new TransactionItemActivity("ABC", "Unit Test", 1.23m, 4);

            tracker.Track(new MeasurementActivityEntry(transactionItem));

            Assert.AreEqual(transaction, transactionItem.Transaction);
            StringAssert.Contains(actual.Last().OriginalString, "ti=123");
        }
Esempio n. 4
0
        public void MeasurementTracker_Track_Does_Not_Buffer_While_Opted_Out()
        {
            var actual         = new List <Uri>();
            var sessionManager = MeasurementTestHelpers.CreateSessionManager();
            var tracker        = new MeasurementTracker(MeasurementTestHelpers.Configuration, sessionManager, MeasurementTestHelpers.CreateEnvironment(), actual.Add);

            sessionManager.VisitorStatus = VisitorStatus.OptedOut;
            tracker.Track(new MeasurementActivityEntry(new AppViewActivity("OptedOut")));
            sessionManager.VisitorStatus = VisitorStatus.Active;
            tracker.Track(new MeasurementActivityEntry(new AppViewActivity("OptedIn")));

            Assert.AreEqual(1, actual.Count);
            StringAssert.Contains(actual[0].OriginalString, "cd=OptedIn");
        }
Esempio n. 5
0
        public void MeasurementTracker_Track_Does_Not_Send_Request_When_Opted_Out()
        {
            var actual         = new List <Uri>();
            var sessionManager = MeasurementTestHelpers.CreateSessionManager();
            var tracker        = new MeasurementTracker(MeasurementTestHelpers.Configuration, sessionManager, MeasurementTestHelpers.CreateEnvironment(), actual.Add);

            sessionManager.VisitorStatus = VisitorStatus.OptedOut;
            tracker.Track(new MeasurementActivityEntry(new AppViewActivity("Testing")));

            Assert.AreEqual(0, actual.Count);
        }
Esempio n. 6
0
        public void MeasurementTracker_Track_Sends_Request()
        {
            var actual  = new List <Uri>();
            var tracker = new MeasurementTracker(MeasurementTestHelpers.Configuration, MeasurementTestHelpers.CreateSessionManager(), MeasurementTestHelpers.CreateEnvironment(), actual.Add);

            tracker.Track(new MeasurementActivityEntry(new AppViewActivity("Testing")));

            Assert.AreEqual(1, actual.Count);
        }
Esempio n. 7
0
        public void MeasurementTracker_Track_Ends_Session()
        {
            var actual         = new List <Uri>();
            var sessionManager = MeasurementTestHelpers.CreateSessionManager();
            var tracker        = new MeasurementTracker(MeasurementTestHelpers.Configuration, sessionManager, MeasurementTestHelpers.CreateEnvironment(), actual.Add);

            tracker.Track(new MeasurementActivityEntry(new AppViewActivity("Testing"))
            {
                EndSession = true
            });

            Assert.AreEqual(SessionStatus.Ending, sessionManager.SessionStatus);
            StringAssert.Contains(actual.Last().OriginalString, "sc=end");
        }
Esempio n. 8
0
        public void MeasurementUriBuilderTests_BuildUri_Is_https_And_ssl_When_Using_SSL()
        {
            var config = MeasurementTestHelpers.Configuration;

            config.UseSsl = true;
            var builder = new MeasurementUriBuilder(config, MeasurementTestHelpers.CreateSessionManager(), MeasurementTestHelpers.CreateEnvironment());

            var actual = builder.BuildUri(new ScreenViewActivity("Home"));

            Assert.AreEqual("https", actual.Scheme);
            Assert.AreEqual("ssl.google-analytics.com", actual.Host);
        }
Esempio n. 9
0
        public void MeasurementUriBuilderTests_BuildUri_Emits_SessionControl_start_At_Start()
        {
            var config  = MeasurementTestHelpers.Configuration;
            var builder = new MeasurementUriBuilder(config, MeasurementTestHelpers.CreateSessionManager(), MeasurementTestHelpers.CreateEnvironment());

            var actual = builder.BuildUri(new ScreenViewActivity("Home"));

            StringAssert.Contains(actual.Query, "sc=start");
        }
Esempio n. 10
0
        public void MeasurementUriBuilderTests_BuildUri_Carries_Forward_Cd_Parameter()
        {
            var config  = MeasurementTestHelpers.Configuration;
            var builder = new MeasurementUriBuilder(config, MeasurementTestHelpers.CreateSessionManager(), MeasurementTestHelpers.CreateEnvironment());

            builder.BuildUri(new ScreenViewActivity("CarriedForward"));
            var actual = builder.BuildUri(new EventActivity("Action", "Category"));

            StringAssert.Contains(actual.Query, "cd=CarriedForward");
        }
        public void MeasurementUriBuilderTests_TrackingEndpointOverride_IsUsed_DontCare_UseSsl()
        {
            var config = MeasurementTestHelpers.Configuration;

            config.UseSsl = false;
            var trackingEnpointOverride = new Uri("https://www.sonova-ga-analytics.com/collect");

            config.TrackingEndpointOverride = trackingEnpointOverride;
            var builder = new MeasurementUriBuilder(config, MeasurementTestHelpers.CreateSessionManager(), MeasurementTestHelpers.CreateEnvironment());

            var actual = builder.BuildUri(new ScreenViewActivity("Home"));

            Assert.AreEqual(trackingEnpointOverride.Host, actual.Host);
            Assert.AreEqual(trackingEnpointOverride.Scheme, actual.Scheme);
        }
        public void MeasurementUriBuilderTests_BuildUri_Is_http_And_www_When_Not_Using_SSL()
        {
            var config = MeasurementTestHelpers.Configuration;

            config.UseSsl = false;
            var builder = new MeasurementUriBuilder(config, MeasurementTestHelpers.CreateSessionManager(), MeasurementTestHelpers.CreateEnvironment());

            var actual = builder.BuildUri(new MeasurementActivityEntry(new AppViewActivity("Home")));

            Assert.AreEqual("http", actual.Scheme);
            Assert.AreEqual("www.google-analytics.com", actual.Host);
        }