Add unit test for CancelAllDialogs and fix eventName and eventValue could be null (#3536)

This commit is contained in:
Tom Laird-McConnell 2020-03-11 11:25:51 -07:00 коммит произвёл GitHub
Родитель f4975229df
Коммит 6835cb5862
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 107 добавлений и 3 удалений

Просмотреть файл

@ -71,11 +71,11 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
if (dc.Parent == null)
{
return await dc.CancelAllDialogsAsync(true, EventName.GetValue(dcState), this.EventValue.GetValue(dcState), cancellationToken).ConfigureAwait(false);
return await dc.CancelAllDialogsAsync(true, EventName?.GetValue(dcState), this.EventValue?.GetValue(dcState), cancellationToken).ConfigureAwait(false);
}
else
{
var turnResult = await dc.Parent.CancelAllDialogsAsync(true, EventName.GetValue(dcState), this.EventValue.GetValue(dcState), cancellationToken).ConfigureAwait(false);
var turnResult = await dc.Parent.CancelAllDialogsAsync(true, EventName?.GetValue(dcState), this.EventValue?.GetValue(dcState), cancellationToken).ConfigureAwait(false);
turnResult.ParentEnded = true;
return turnResult;
}

Просмотреть файл

@ -47,7 +47,7 @@ namespace Microsoft.Bot.Builder.Dialogs
/// <param name="telemetryProperties">Additional properties to be logged to telemetry with the LuisResult event.</param>
/// <param name="telemetryMetrics">Additional metrics to be logged to telemetry with the LuisResult event.</param>
/// <returns>Analysis of utterance.</returns>
public virtual async Task<RecognizerResult> RecognizeAsync(DialogContext dialogContext, Activity activity, CancellationToken cancellationToken = default, Dictionary<string, string> telemetryProperties = null, Dictionary<string, double> telemetryMetrics = null)
public virtual Task<RecognizerResult> RecognizeAsync(DialogContext dialogContext, Activity activity, CancellationToken cancellationToken = default, Dictionary<string, string> telemetryProperties = null, Dictionary<string, double> telemetryMetrics = null)
{
throw new NotImplementedException();
}

Просмотреть файл

@ -47,6 +47,12 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Tests
await TestUtils.RunTestScript(ResourceExplorer);
}
[TestMethod]
public async Task Action_CancelAllDialogs()
{
await TestUtils.RunTestScript(ResourceExplorer);
}
[TestMethod]
public async Task Action_ChoiceInput()
{

Просмотреть файл

@ -0,0 +1,98 @@
{
"$schema": "../../../../schemas/sdk.schema",
"$kind": "Microsoft.Test.Script",
"dialog": {
"$schema": "../../app.schema",
"$kind": "Microsoft.AdaptiveDialog",
"recognizer": {
"$kind": "Microsoft.RegexRecognizer",
"intents": [
{
"intent": "CancelIntent",
"pattern": "(?i)cancel|never mind"
}
]
},
"triggers": [
{
"$kind": "Microsoft.OnBeginDialog",
"actions": [
{
"$schema": "../../app.schema",
"$kind": "Microsoft.AdaptiveDialog",
"recognizer": {
"$kind": "Microsoft.RegexRecognizer",
"intents": [
{
"intent": "CancelIntent",
"pattern": "(?i)cancel|never mind"
}
]
},
"triggers": [
{
"$kind": "Microsoft.OnBeginDialog",
"actions": [
{
"$kind": "Microsoft.SendActivity",
"activity": "Why did the chicken cross the road?"
},
{
"$kind": "Microsoft.EndTurn"
},
{
"$kind": "Microsoft.SendActivity",
"activity": "To get to the other side"
}
]
},
{
"$kind": "Microsoft.OnIntent",
"intent": "CancelIntent",
"actions": [
{
"$kind": "Microsoft.SendActivity",
"activity": "Canceled"
},
{
"$kind": "Microsoft.CancelAllDialogs"
}
]
}
]
},
{
"$kind": "Microsoft.SendActivity",
"activity": "What am I doing here?"
}
]
}
]
},
"script": [
{
"$kind": "Microsoft.Test.UserSays",
"text": "hi"
},
{
"$kind": "Microsoft.Test.AssertReply",
"text": "Why did the chicken cross the road?"
},
{
"$kind": "Microsoft.Test.UserSays",
"text": "cancel"
},
{
"$kind": "Microsoft.Test.AssertReply",
"text": "Canceled"
},
{
"$kind": "Microsoft.Test.UserSays",
"text": "hi"
},
{
"$kind": "Microsoft.Test.AssertReply",
"text": "Why did the chicken cross the road?"
}
]
}