/// <summary> /// Calls the recognizer's `RecognizeAsync` method and validates appropriate telemetry properties are logged. /// </summary> /// <param name="text">The activity's text used run recognition against.</param> /// <param name="recognizer">The recognizer used to call `RecognizeAsync`.</param> /// <param name="telemetryClient">The telemetry client used to log telemetry.</param> /// <param name="callCount">How many times the telemetry client should have logged the `RecognizerResult` of our target recognizer.</param> /// <returns>Task representing the validation work done.</returns> internal static async Task RecognizeIntentAndValidateTelemetry(string text, AdaptiveRecognizer recognizer, Mock <IBotTelemetryClient> telemetryClient, int callCount) { var dc = TestUtils.CreateContext(text); var activity = dc.Context.Activity; var result = await recognizer.RecognizeAsync(dc, activity, CancellationToken.None); if (ValidateIntent.ContainsKey(text)) { ValidateIntent[text](result); } ValidateTelemetry(recognizer, telemetryClient, dc, activity, result, callCount); }
/// <summary> /// Calls the recognizer's `RecognizeAsync` method and validates appropriate telemetry properties are logged, /// using a custom activity, separate from the activity found in <see cref="DialogContext"/>. /// </summary> /// <param name="text">The activity's text used run recognition against.</param> /// <param name="recognizer">The recognizer used to call `RecognizeAsync`.</param> /// <param name="telemetryClient">The telemetry client used to log telemetry.</param> /// <param name="callCount">How many times the telemetry client should have logged the `RecognizerResult` of our target recognizer.</param> /// <returns>Task representing the validation work done.</returns> internal static async Task RecognizeIntentAndValidateTelemetry_WithCustomActivity(string text, AdaptiveRecognizer recognizer, Mock <IBotTelemetryClient> telemetryClient, int callCount) { var dc = TestUtils.CreateContext(string.Empty); var customActivity = Activity.CreateMessageActivity(); customActivity.Text = text; customActivity.Locale = Culture.English; var result = await recognizer.RecognizeAsync(dc, (Activity)customActivity, CancellationToken.None); if (ValidateIntent.ContainsKey(text)) { ValidateIntent[text](result); } ValidateTelemetry(recognizer, telemetryClient, dc, (Activity)customActivity, result, callCount); }