public async void GIVENDisposedSentimentInstrumentationMiddleware_WHENOnTurnAsyncIsInvoked_THENExceptionIsBeingThrown(
            SentimentInstrumentationMiddlewareSettings settings)
        {
            // Arrange
            var instrumentation = new SentimentInstrumentationMiddleware(this.telemetryClient, settings);

            instrumentation.Dispose();

            // Act
            // Assert
            await Assert.ThrowsAsync <ObjectDisposedException>(() => instrumentation.OnTurnAsync(null, null))
            .ConfigureAwait(false);
        }
        public async void GIVENEmptyTurnContext_WHENOnTurnAsyncIsInvoked_THENExceptionIsBeingThrown(
            SentimentInstrumentationMiddlewareSettings settings)
        {
            // Arrange
            var instrumentation = new SentimentInstrumentationMiddleware(this.telemetryClient, settings);
            const ITurnContext emptyTurnContext = null;
            NextDelegate       nextDelegate     = Task.FromCanceled;

            // Act
            // Assert
            await Assert.ThrowsAsync <ArgumentNullException>(() => instrumentation.OnTurnAsync(emptyTurnContext, nextDelegate))
            .ConfigureAwait(false);
        }
        public async void GIVENNextTurn_WHENOnTurnAsyncIsInvoked_THENNextTurnIsBeingInvoked(
            ITurnContext turnContext,
            SentimentInstrumentationMiddlewareSettings settings)
        {
            // Arrange
            var instrumentation = new SentimentInstrumentationMiddleware(this.telemetryClient, settings);
            var nextTurnInvoked = false;

            // Act
            await instrumentation.OnTurnAsync(turnContext, token => Task.Run(() => nextTurnInvoked = true, token))
            .ConfigureAwait(false);

            // Assert
            nextTurnInvoked.Should().Be(true);
        }
        public async void GIVENTurnContextWithAnyActivity_WHENOnTurnAsyncIsInvoked_THENSentimentRetrievedEventTelemetryIsBeingSent(
            string activityType,
            int expectedNumberOfInvocations,
            Activity activity,
            ITurnContext turnContext,
            ISentimentClient sentimentClient,
            InstrumentationSettings settings)
        {
            // Arrange
            activity.Type      = activityType;
            activity.ReplyToId = null;
            Mock.Get(turnContext)
            .SetupGet(c => c.Activity)
            .Returns(activity);
            var middleware = new SentimentInstrumentationMiddleware(this.telemetryClient, sentimentClient, settings);

            // Act
            await middleware.OnTurnAsync(turnContext, null)
            .ConfigureAwait(false);

            // Assert
            Mock.Get(sentimentClient).Verify(sc => sc.GetSentiment(It.IsAny <IActivityAdapter>()), Times.Exactly(expectedNumberOfInvocations));
            this.mockTelemetryChannel.Verify(tc => tc.Send(It.IsAny <EventTelemetry>()), Times.Exactly(expectedNumberOfInvocations));
        }