Make languagePolicy configurable in TestScript (#4794)

* change the appsetting parse logic

* typo

* refine

* add test

* add more tests

* add more comments

* refine code

* retrigger

* retrigger

* Make languagePolicy a property

* revert

* update schema

* update schema

* update schema

* update schema

* update schema

* update schema
This commit is contained in:
Hongyang Du (hond) 2020-10-21 11:21:46 +08:00 коммит произвёл GitHub
Родитель 3363f4a7af
Коммит cfd1e9c6e6
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
8 изменённых файлов: 2023 добавлений и 1989 удалений

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

@ -10,6 +10,11 @@
"title": "Dialog",
"description": "The root dialog to execute the test script against."
},
"languagePolicy": {
"type": "object",
"title": "Language policy",
"description": "Defines fall back languages to try per user input language."
},
"description": {
"type": "string",
"title": "Description",

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

@ -81,6 +81,17 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Testing
[JsonProperty("locale")]
public string Locale { get; set; } = "en-us";
/// <summary>
/// Gets or sets the language policy.
/// </summary>
/// <value>
/// the language policy.
/// </value>
[JsonProperty("languagePolicy")]
#pragma warning disable CA2227 // Collection properties should be read only
public LanguagePolicy LanguagePolicy { get; set; }
#pragma warning restore CA2227 // Collection properties should be read only
/// <summary>
/// Gets the mock data for Microsoft.HttpRequest.
/// </summary>
@ -149,9 +160,8 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Testing
/// <param name="testName">Name of the test.</param>
/// <param name="callback">The bot logic.</param>
/// <param name="adapter">optional test adapter.</param>
/// <param name="languagePolicy">The default language policy.</param>
/// <returns>Runs the exchange between the user and the bot.</returns>
public async Task ExecuteAsync(ResourceExplorer resourceExplorer, [CallerMemberName] string testName = null, BotCallbackHandler callback = null, TestAdapter adapter = null, LanguagePolicy languagePolicy = null)
public async Task ExecuteAsync(ResourceExplorer resourceExplorer, [CallerMemberName] string testName = null, BotCallbackHandler callback = null, TestAdapter adapter = null)
{
if (adapter == null)
{
@ -186,9 +196,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Testing
.UseResourceExplorer(resourceExplorer)
.UseLanguageGeneration();
if (languagePolicy != null)
if (LanguagePolicy != null)
{
dm.UseLanguagePolicy(languagePolicy);
dm.UseLanguagePolicy(LanguagePolicy);
}
callback = dm.OnTurnAsync;

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

@ -50,8 +50,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers.Tests
[Fact]
public async Task MultiLanguageRecognizerTest_LanguagePolicy()
{
var languagePolicy = new LanguagePolicy("en-gb");
await TestUtils.RunTestScript(_resourceExplorerFixture.ResourceExplorer, languagePolicy: languagePolicy);
await TestUtils.RunTestScript(_resourceExplorerFixture.ResourceExplorer);
}
}
}

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

@ -22,12 +22,12 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Tests
return Directory.EnumerateFiles(testFolder, "*.test.dialog", SearchOption.AllDirectories).Select(s => new object[] { Path.GetFileName(s) }).ToArray();
}
public static async Task RunTestScript(ResourceExplorer resourceExplorer, string resourceId = null, IConfiguration configuration = null, [CallerMemberName] string testName = null, LanguagePolicy languagePolicy = null)
public static async Task RunTestScript(ResourceExplorer resourceExplorer, string resourceId = null, IConfiguration configuration = null, [CallerMemberName] string testName = null)
{
var script = resourceExplorer.LoadType<TestScript>(resourceId ?? $"{testName}.test.dialog");
script.Configuration = configuration ?? new ConfigurationBuilder().AddInMemoryCollection().Build();
script.Description = script.Description ?? resourceId;
await script.ExecuteAsync(testName: testName, resourceExplorer: resourceExplorer, languagePolicy: languagePolicy).ConfigureAwait(false);
await script.ExecuteAsync(testName: testName, resourceExplorer: resourceExplorer).ConfigureAwait(false);
}
public static string GetProjectPath()

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

@ -93,6 +93,9 @@
],
"defaultResultProperty": "dialog.result"
},
"languagePolicy": {
"": [ "en-gb", "" ]
},
"locale": "",
"script": [
{

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -23,20 +23,6 @@
}
}
},
"Microsoft.AttachmentInput": {
"form": {
"helpLink": "https://aka.ms/bfc-ask-for-user-input",
"label": "Prompt for a file or an attachment",
"properties": {
"property": {
"intellisenseScopes": [
"variable-scopes"
]
}
},
"subtitle": "Attachment Input"
}
},
"Microsoft.BeginDialog": {
"form": {
"helpLink": "https://aka.ms/bfc-understanding-dialogs",
@ -84,54 +70,12 @@
"subtitle": "Cancel All Dialogs"
}
},
"Microsoft.ChoiceInput": {
"form": {
"helpLink": "https://aka.ms/bfc-ask-for-user-input",
"label": "Prompt with multi-choice",
"properties": {
"property": {
"intellisenseScopes": [
"variable-scopes"
]
}
},
"subtitle": "Choice Input"
}
},
"Microsoft.ConfirmInput": {
"form": {
"helpLink": "https://aka.ms/bfc-ask-for-user-input",
"label": "Prompt for confirmation",
"properties": {
"property": {
"intellisenseScopes": [
"variable-scopes"
]
}
},
"subtitle": "Confirm Input"
}
},
"Microsoft.ContinueLoop": {
"form": {
"label": "Continue loop",
"subtitle": "Continue loop"
}
},
"Microsoft.DateTimeInput": {
"form": {
"helpLink": "https://aka.ms/bfc-ask-for-user-input",
"label": "Prompt for a date or a time",
"properties": {
"property": {
"intellisenseScopes": [
"variable-scopes"
]
}
},
"subtitle": "Date Time Input"
}
},
"Microsoft.DebugBreak": {
"form": {
"label": "Debug Break"
@ -313,6 +257,169 @@
"subtitle": "Log Action"
}
},
"Microsoft.RepeatDialog": {
"form": {
"helpLink": "https://aka.ms/bfc-understanding-dialogs",
"label": "Repeat this dialog",
"order": [
"options",
"*"
],
"subtitle": "Repeat Dialog"
}
},
"Microsoft.ReplaceDialog": {
"form": {
"helpLink": "https://aka.ms/bfc-understanding-dialogs",
"label": "Replace this dialog",
"order": [
"dialog",
"options",
"*"
],
"subtitle": "Replace Dialog"
}
},
"Microsoft.SendActivity": {
"form": {
"helpLink": "https://aka.ms/bfc-send-activity",
"label": "Send a response",
"order": [
"activity",
"*"
],
"subtitle": "Send Activity"
}
},
"Microsoft.SetProperties": {
"form": {
"helpLink": "https://aka.ms/bfc-using-memory",
"label": "Set properties",
"properties": {
"assignments": {
"properties": {
"property": {
"intellisenseScopes": [
"variable-scopes"
]
}
}
}
},
"subtitle": "Set Properties"
}
},
"Microsoft.SetProperty": {
"form": {
"helpLink": "https://aka.ms/bfc-using-memory",
"label": "Set a property",
"properties": {
"property": {
"intellisenseScopes": [
"variable-scopes"
]
}
},
"subtitle": "Set Property"
}
},
"Microsoft.SignOutUser": {
"form": {
"label": "Sign out user",
"subtitle": "Signout User"
}
},
"Microsoft.SwitchCondition": {
"form": {
"helpLink": "https://aka.ms/bfc-controlling-conversation-flow",
"hidden": [
"default"
],
"label": "Branch: Switch (multiple options)",
"properties": {
"cases": {
"hidden": [
"actions"
]
},
"condition": {
"intellisenseScopes": [
"user-variables"
]
}
},
"subtitle": "Switch Condition"
}
},
"Microsoft.ThrowException": {
"form": {
"label": "Throw an exception",
"subtitle": "Throw an exception"
}
},
"Microsoft.TraceActivity": {
"form": {
"helpLink": "https://aka.ms/bfc-debugging-bots",
"label": "Emit a trace event",
"subtitle": "Trace Activity"
}
},
"Microsoft.AttachmentInput": {
"form": {
"helpLink": "https://aka.ms/bfc-ask-for-user-input",
"label": "Prompt for a file or an attachment",
"properties": {
"property": {
"intellisenseScopes": [
"variable-scopes"
]
}
},
"subtitle": "Attachment Input"
}
},
"Microsoft.ChoiceInput": {
"form": {
"helpLink": "https://aka.ms/bfc-ask-for-user-input",
"label": "Prompt with multi-choice",
"properties": {
"property": {
"intellisenseScopes": [
"variable-scopes"
]
}
},
"subtitle": "Choice Input"
}
},
"Microsoft.ConfirmInput": {
"form": {
"helpLink": "https://aka.ms/bfc-ask-for-user-input",
"label": "Prompt for confirmation",
"properties": {
"property": {
"intellisenseScopes": [
"variable-scopes"
]
}
},
"subtitle": "Confirm Input"
}
},
"Microsoft.DateTimeInput": {
"form": {
"helpLink": "https://aka.ms/bfc-ask-for-user-input",
"label": "Prompt for a date or a time",
"properties": {
"property": {
"intellisenseScopes": [
"variable-scopes"
]
}
},
"subtitle": "Date Time Input"
}
},
"Microsoft.NumberInput": {
"form": {
"helpLink": "https://aka.ms/bfc-ask-for-user-input",
@ -338,6 +445,27 @@
"subtitle": "OAuth Input"
}
},
"Microsoft.TextInput": {
"form": {
"helpLink": "https://aka.ms/bfc-ask-for-user-input",
"label": "Prompt for text",
"properties": {
"property": {
"intellisenseScopes": [
"variable-scopes"
]
}
},
"subtitle": "Text Input"
}
},
"Microsoft.RegexRecognizer": {
"form": {
"hidden": [
"entities"
]
}
},
"Microsoft.OnActivity": {
"form": {
"hidden": [
@ -601,133 +729,5 @@
],
"subtitle": "Unknown intent recognized"
}
},
"Microsoft.RegexRecognizer": {
"form": {
"hidden": [
"entities"
]
}
},
"Microsoft.RepeatDialog": {
"form": {
"helpLink": "https://aka.ms/bfc-understanding-dialogs",
"label": "Repeat this dialog",
"order": [
"options",
"*"
],
"subtitle": "Repeat Dialog"
}
},
"Microsoft.ReplaceDialog": {
"form": {
"helpLink": "https://aka.ms/bfc-understanding-dialogs",
"label": "Replace this dialog",
"order": [
"dialog",
"options",
"*"
],
"subtitle": "Replace Dialog"
}
},
"Microsoft.SendActivity": {
"form": {
"helpLink": "https://aka.ms/bfc-send-activity",
"label": "Send a response",
"order": [
"activity",
"*"
],
"subtitle": "Send Activity"
}
},
"Microsoft.SetProperties": {
"form": {
"helpLink": "https://aka.ms/bfc-using-memory",
"label": "Set properties",
"properties": {
"assignments": {
"properties": {
"property": {
"intellisenseScopes": [
"variable-scopes"
]
}
}
}
},
"subtitle": "Set Properties"
}
},
"Microsoft.SetProperty": {
"form": {
"helpLink": "https://aka.ms/bfc-using-memory",
"label": "Set a property",
"properties": {
"property": {
"intellisenseScopes": [
"variable-scopes"
]
}
},
"subtitle": "Set Property"
}
},
"Microsoft.SignOutUser": {
"form": {
"label": "Sign out user",
"subtitle": "Signout User"
}
},
"Microsoft.SwitchCondition": {
"form": {
"helpLink": "https://aka.ms/bfc-controlling-conversation-flow",
"hidden": [
"default"
],
"label": "Branch: Switch (multiple options)",
"properties": {
"cases": {
"hidden": [
"actions"
]
},
"condition": {
"intellisenseScopes": [
"user-variables"
]
}
},
"subtitle": "Switch Condition"
}
},
"Microsoft.TextInput": {
"form": {
"helpLink": "https://aka.ms/bfc-ask-for-user-input",
"label": "Prompt for text",
"properties": {
"property": {
"intellisenseScopes": [
"variable-scopes"
]
}
},
"subtitle": "Text Input"
}
},
"Microsoft.ThrowException": {
"form": {
"label": "Throw an exception",
"subtitle": "Throw an exception"
}
},
"Microsoft.TraceActivity": {
"form": {
"helpLink": "https://aka.ms/bfc-debugging-bots",
"label": "Emit a trace event",
"subtitle": "Trace Activity"
}
}
}