public void Call_TrackEvent_WithMetricInEvent() { var telemetry = new Telemetry(_client); const string eventName = "EventName"; const string telemetryMetricEventKey = "A"; const double telemetryMetricEventValue = 5; var telemetryMetrics = new TelemetryMetrics() { [telemetryMetricEventKey] = telemetryMetricEventValue }; telemetry.TrackEvent(eventName, null, telemetryMetrics); _client.Received().TrackEvent(eventName, Arg.Is <Dictionary <string, string> >(data => data == null || data.Count == 0), Arg.Is <Dictionary <string, double> >(metrics => metrics != null && metrics.Count == 1 && // ReSharper disable once CompareOfFloatsByEqualityOperator metrics[telemetryMetricEventKey] == telemetryMetricEventValue) ); }
public void Copy_Data_From_Constructor() { var metrics = new TelemetryMetrics() { ["A"] = 4 }; var createdMetrics = new TelemetryMetrics(metrics); Check.That(createdMetrics.GetDictionary()).Not.IsSameReferenceAs(metrics.GetDictionary()).And .ContainsExactly(metrics.GetDictionary()); }
public void Call_TrackMetric_WithDimensions() { var telemetry = new Telemetry(_client); const string metricName = "MetricName"; var values = new TelemetryMetrics() { ["Dim1"] = 4, ["Dim2"] = 2 }; telemetry.TrackMetric(metricName, "dimension", values); _client.Received().TrackMetric(metricName, "dimension", Arg.Is <Dictionary <string, double> >(v => v != null && v.Count == 2 && v["Dim1"] == 4.0 && v["Dim2"] == 2.0 )); }
public TelemetryMetrics(TelemetryMetrics metrics = null) : base(metrics?.GetDictionary()) { }