Skip to content
This repository was archived by the owner on Jan 5, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@ public TestScript()
[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>
Expand Down Expand Up @@ -149,9 +160,8 @@ public TestAdapter DefaultTestAdapter(ResourceExplorer resourceExplorer, [Caller
/// <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)
{
Expand Down Expand Up @@ -186,9 +196,9 @@ await adapter.ProcessActivityAsync(
.UseResourceExplorer(resourceExplorer)
.UseLanguageGeneration();

if (languagePolicy != null)
if (LanguagePolicy != null)
{
dm.UseLanguagePolicy(languagePolicy);
dm.UseLanguagePolicy(LanguagePolicy);
}

callback = dm.OnTurnAsync;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ public async Task MultiLanguageRecognizerTest_DefaultFallback()
[Fact]
public async Task MultiLanguageRecognizerTest_LanguagePolicy()
{
var languagePolicy = new LanguagePolicy("en-gb");
await TestUtils.RunTestScript(_resourceExplorerFixture.ResourceExplorer, languagePolicy: languagePolicy);
await TestUtils.RunTestScript(_resourceExplorerFixture.ResourceExplorer);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ public static IEnumerable<object[]> GetTestScripts(string relativeFolder)
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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@
],
"defaultResultProperty": "dialog.result"
},
"languagePolicy": {
"": [ "en-gb", "" ]
},
"locale": "",
"script": [
{
Expand Down
Loading