/// <summary>
        /// Obtain the key/value pairs for a ContentViewActivity.
        /// </summary>
        /// <param name="contentView">ContentViewActivity to turn into key/value pairs.</param>
        /// <returns>Key/value pairs representing this ContentViewActivity.</returns>
        internal static IEnumerable<KeyValuePair<string, string>> GetParameters(ContentViewActivity contentView)
        {
            yield return KeyValuePair.Create("t", "pageview");

            foreach (var pair in GetSharedParameters(contentView))
                yield return pair;
        }
        public void ContentViewActivity_Constructor_With_All_Parameters_Sets_Correct_Properties()
        {
            var documentLocation = new Uri("http://unitest.csharpanalytics.com/some/sample/page?id=1");

            var activity = new ContentViewActivity(documentLocation, "Document Title", "A content description", "/document/path", "newhostname.csharpanalytics.com");

            Assert.AreEqual(documentLocation.AbsoluteUri, activity.DocumentLocation.AbsoluteUri);
            Assert.AreEqual("Document Title", activity.DocumentTitle);
            Assert.AreEqual("A content description", activity.ContentDescription);
            Assert.AreEqual("/document/path", activity.DocumentPath);
            Assert.AreEqual("newhostname.csharpanalytics.com", activity.DocumentHostName);
        }
        public void ContentViewActivity_Constructor_With_Minimum_Parameters_Sets_Correct_Properties()
        {
            var documentLocation = new Uri("http://unitest.csharpanalytics.com/some/sample/page?id=1");
            var activity = new ContentViewActivity(documentLocation, "Sample Page");

            Assert.AreEqual(documentLocation.AbsolutePath, activity.DocumentLocation.AbsolutePath);
            Assert.AreEqual("Sample Page", activity.DocumentTitle);

            Assert.IsNull(activity.DocumentHostName);
            Assert.IsNull(activity.DocumentPath);
            Assert.IsNull(activity.ContentDescription);
        }
        public void MeasurementActivityTracker_GetParameter_For_ContentViewActivity_Returns_Correct_Values()
        {
            var location = new Uri("http://unittest.csharpanalytics.com/some/path");
            var activity = new ContentViewActivity(location, "Document Title", "A content description.", "/document/path", "hostname.csharpanalytics.com");

            var parameters = MeasurementActivityTracker.GetParameters(activity).ToDictionary(k => k.Key, v => v.Value);

            Assert.AreEqual(6, parameters.Keys.Count);
            Assert.AreEqual("pageview", parameters["t"]);
            Assert.AreEqual(location.AbsoluteUri, parameters["dl"]);
            Assert.AreEqual("Document Title", parameters["dt"]);
            Assert.AreEqual("A content description.", parameters["cd"]);
            Assert.AreEqual("/document/path", parameters["dp"]);
            Assert.AreEqual("hostname.csharpanalytics.com", parameters["dh"]);
        }
        /// <summary>
        /// Obtain the key/value pairs shared by all ContentViewActivity classes.
        /// </summary>
        /// <param name="contentView">ContentViewActivity to turn into key/value pairs.</param>
        /// <returns>Key/value pairs representing this ContentViewActivity.</returns>
        internal static IEnumerable<KeyValuePair<string, string>> GetSharedParameters(ContentViewActivity contentView)
        {
            if (contentView.DocumentLocation != null)
                yield return KeyValuePair.Create("dl", contentView.DocumentLocation.OriginalString);

            if (!String.IsNullOrEmpty(contentView.DocumentHostName))
                yield return KeyValuePair.Create("dh", contentView.DocumentHostName);

            if (!String.IsNullOrEmpty(contentView.DocumentPath))
                yield return KeyValuePair.Create("dp", contentView.DocumentPath);

            if (!String.IsNullOrEmpty(contentView.DocumentTitle))
                yield return KeyValuePair.Create("dt", contentView.DocumentTitle);

            if (!String.IsNullOrEmpty(contentView.ContentDescription))
                yield return KeyValuePair.Create("cd", contentView.ContentDescription);
        }
        /// <summary>
        /// Obtain the key/value pairs for a ContentViewActivity.
        /// </summary>
        /// <param name="contentView">ContentViewActivity to turn into key/value pairs.</param>
        /// <returns>Key/value pairs representing this ContentViewActivity.</returns>
        internal static IEnumerable<KeyValuePair<string, string>> GetParameters(ContentViewActivity contentView)
        {
            yield return KeyValuePair.Create("t", "pageview");

            foreach (var parameter in GetCommonParameters(contentView))
                yield return parameter;

            if (contentView.DocumentLocation != null)
                yield return KeyValuePair.Create("dl", contentView.DocumentLocation.OriginalString);

            if (!String.IsNullOrEmpty(contentView.DocumentHostName))
                yield return KeyValuePair.Create("dh", contentView.DocumentHostName);

            if (!String.IsNullOrEmpty(contentView.DocumentPath))
                yield return KeyValuePair.Create("dp", contentView.DocumentPath);

            if (!String.IsNullOrEmpty(contentView.DocumentTitle))
                yield return KeyValuePair.Create("dt", contentView.DocumentTitle);

            if (!String.IsNullOrEmpty(contentView.ContentDescription))
                yield return KeyValuePair.Create("cd", contentView.ContentDescription);
        }