public void TimedEventActivity_Constructor_With_All_Parameters_Sets_Correct_Properties() { var activity = new TimedEventActivity("category", "variable", TimeSpan.FromSeconds(1.5), "label"); Assert.AreEqual("category", activity.Category); Assert.AreEqual("variable", activity.Variable); Assert.AreEqual(TimeSpan.FromSeconds(1.5), activity.Time); Assert.AreEqual("label", activity.Label); }
/// <summary> /// Encode a TimedEventActivity using Utme escaping. /// </summary> /// <param name="timedEventActivity">TimedEventActivity being encoded.</param> /// <returns>Encoded set of values marked with prefix.</returns> public static string Encode(TimedEventActivity timedEventActivity) { var roundedTime = timedEventActivity.Time.TotalMilliseconds/10*10; var result = String.Join("*", new[] { timedEventActivity.Variable, timedEventActivity.Category, roundedTime.ToString(CultureInfo.InvariantCulture), timedEventActivity.Label }); if (String.IsNullOrWhiteSpace(result)) return String.Empty; return "14(90!" + result + ")(90!" + timedEventActivity.Time.TotalMilliseconds.ToString(CultureInfo.InvariantCulture) + ")"; }
internal static IEnumerable<KeyValuePair<string, string>> GetParameters(TimedEventActivity timedEvent) { yield return KeyValuePair.Create("utmt", "event"); yield return KeyValuePair.Create("utme", UtmeEncoder.Encode(timedEvent)); }
public void MeasurementActivityTracker_GetParameter_For_TimedEventActivity_Returns_Correct_Values() { var activity = new TimedEventActivity("cateogry", "variable", TimeSpan.FromMilliseconds(12345), "label"); var parameters = MeasurementActivityTracker.GetParameters(activity).ToDictionary(k => k.Key, v => v.Value); Assert.AreEqual(5, parameters.Keys.Count); Assert.AreEqual("timing", parameters["t"]); Assert.AreEqual("variable", parameters["utv"]); Assert.AreEqual("12345", parameters["utt"]); Assert.AreEqual("label", parameters["utl"]); }
/// <summary> /// Obtain the key/value pairs for a TimedEventActivity. /// </summary> /// <param name="timedEvent">TimedEventActivity to turn into key/value pairs.</param> /// <returns>Key/value pairs representing this TimedEventActivity.</returns> internal static IEnumerable<KeyValuePair<string, string>> GetParameters(TimedEventActivity timedEvent) { yield return KeyValuePair.Create("t", "timing"); foreach (var parameter in GetCommonParameters(timedEvent)) yield return parameter; if (!String.IsNullOrWhiteSpace(timedEvent.Category)) yield return KeyValuePair.Create("utc", timedEvent.Category); if (!String.IsNullOrWhiteSpace(timedEvent.Variable)) yield return KeyValuePair.Create("utv", timedEvent.Variable); if (!String.IsNullOrWhiteSpace(timedEvent.Label)) yield return KeyValuePair.Create("utl", timedEvent.Label); yield return KeyValuePair.Create("utt", timedEvent.Time.TotalMilliseconds.ToString("0", CultureInfo.InvariantCulture)); }
public void UrchinActivityTracker_GetParameter_For_TimedEventActivity_Returns_Correct_Utmt_Value() { var activity = new TimedEventActivity("category", "variable", TimeSpan.Zero); var results = UrchinActivityTracker.GetParameters(activity).ToDictionary(k => k.Key, v => v); CollectionAssert.Contains(results.Keys, "utmt"); Assert.AreEqual("event", results["utmt"].Value); }
public void UrchinActivityTracker_GetParameter_For_TimedEventActivity_Returns_Correct_Keys() { var activity = new TimedEventActivity("category", "variable", TimeSpan.FromSeconds(1.5), "label"); var results = UrchinActivityTracker.GetParameters(activity).ToDictionary(k => k.Key, v => v); var expectedKeys = new[] { "utmt", "utme" }; CollectionAssert.AreEquivalent(expectedKeys, results.Keys); }