示例#1
0
        public void Add_Event_Id_If_Telemetry_Properties_Supplied()
        {
            var supportProperties = new RequestTelemetry();

            ApplicationInsightsInstrumentor.EnrichTelemetryProperties(_eventId, null, supportProperties);

            supportProperties.Properties.Count.Should().Be(1);
            supportProperties.Properties.TryGetValue("EventId", out var eventIdValue);
            eventIdValue.Should().Be(_eventId.ToString());
        }
示例#2
0
        public void Not_Add_Event_Id_Property_If_Telemetry_Properties_Not_Supplied()
        {
            var supportPropertiesMock = new Mock <ISupportProperties>();

            supportPropertiesMock.Setup(m => m.Properties).Returns((IDictionary <string, string>)null);

            ApplicationInsightsInstrumentor.EnrichTelemetryProperties(_eventId, null, supportPropertiesMock.Object);

            supportPropertiesMock.Verify(d => d.Properties.Add(It.IsAny <KeyValuePair <string, string> >()), Times.Never);
        }
示例#3
0
        public void Add_Additional_Telemetry_Properties_If_Custom_Properties_Supplied(string customPropertyKey, object customPropertyValue, string expectedCustomPropertyValue)
        {
            var supportProperties = new RequestTelemetry();

            var customProperties = new Dictionary <string, object>
            {
                { customPropertyKey, customPropertyValue }
            };

            ApplicationInsightsInstrumentor.EnrichTelemetryProperties(_eventId, customProperties, supportProperties);

            supportProperties.Properties.Count.Should().Be(2);
            supportProperties.Properties.TryGetValue("EventId", out var eventIdValue);
            eventIdValue.Should().Be(_eventId.ToString());

            supportProperties.Properties.TryGetValue(customPropertyKey, out var result);
            result.Should().Be(expectedCustomPropertyValue);
        }