public async void GIVENEmptyActivity_WHENTrackMessageSentimentIsInvoked_THENExceptionIsBeingThrown( ISentimentClient sentimentClient, InstrumentationSettings settings) { // Arrange const IMessageActivity emptyActivity = null; var instrumentation = new SentimentInstrumentation(settings, this.telemetryClient, sentimentClient); // Act // Assert await Assert.ThrowsAsync <ArgumentNullException>(() => instrumentation.TrackMessageSentiment(emptyActivity)) .ConfigureAwait(false); }
public async void GIVENAnyActivity_WHENTrackEventIsInvoked_THENEventTelemetryIsBeingSent( double sentimentScore, IMessageActivity activity, ISentimentClient sentimentClient, InstrumentationSettings settings) { // Arrange var instrumentation = new SentimentInstrumentation(settings, this.telemetryClient, sentimentClient); Mock.Get(sentimentClient) .Setup(s => s.GetSentiment(It.IsAny <ActivityAdapter>())) .Returns(Task.FromResult <double?>(sentimentScore)); // Act await instrumentation.TrackMessageSentiment(activity) .ConfigureAwait(false); // Assert this.mockTelemetryChannel.Verify( tc => tc.Send(It.Is <EventTelemetry>(t => t.Name == EventTypes.MessageSentiment && t.Properties[SentimentConstants.Score] == sentimentScore.ToString(CultureInfo.InvariantCulture))), Times.Once); }