コード例 #1
0
        public void GivenEmptyActivity_WhenTrackCustomEventIsInvoked_ThenExceptionIsBeingThrown(
            InstrumentationSettings settings)
        {
            // Arrange
            var             instrumentation = new CustomInstrumentation(this.telemetryClient, settings);
            const IActivity emptyActivity   = null;

            // Act
            // Assert
            Assert.Throws <ArgumentNullException>(() => instrumentation.TrackCustomEvent(emptyActivity));
        }
コード例 #2
0
        public void GivenAnyActivity_WhenTrackCustomEventIsInvoked_ThenEventTelemetryIsBeingSent(
            IMessageActivity activity,
            InstrumentationSettings settings)
        {
            // Arrange
            var instrumentation = new CustomInstrumentation(this.telemetryClient, settings);

            // Act
            instrumentation.TrackCustomEvent(activity);

            // Assert
            this.mockTelemetryChannel.Verify(
                tc => tc.Send(It.Is <EventTelemetry>(t =>
                                                     t.Name == EventTypes.CustomEvent)),
                Times.Once);
        }
コード例 #3
0
        public void GivenAnyActivityAnyEventNameAndAnyProperty_WhenTrackCustomEventIsInvoked_ThenEventTelemetryIsBeingSent(
            IMessageActivity activity,
            string eventName,
            string propertyKey,
            string propertyValue,
            InstrumentationSettings settings)
        {
            // Arrange
            var instrumentation = new CustomInstrumentation(this.telemetryClient, settings);
            var properties      = new Dictionary <string, string> {
                { propertyKey, propertyValue }
            };

            // Act
            instrumentation.TrackCustomEvent(activity, eventName, properties);

            // Assert
            this.mockTelemetryChannel.Verify(
                tc => tc.Send(It.Is <EventTelemetry>(t =>
                                                     t.Name == eventName &&
                                                     t.Properties[propertyKey] == propertyValue)),
                Times.Once);
        }