diff --git a/Microsoft.Bot.Builder.sln b/Microsoft.Bot.Builder.sln index ccbede4b6..1f7686638 100644 --- a/Microsoft.Bot.Builder.sln +++ b/Microsoft.Bot.Builder.sln @@ -166,6 +166,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Bot.Builder.Adapt EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Bot.Builder.TestProtocol", "tests\Microsoft.Bot.Builder.TestProtocol\Microsoft.Bot.Builder.TestProtocol.csproj", "{24CCB459-B4F6-484F-8BA4-946A4AB816FA}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Bot.Builder.Dialogs.Adaptive.Profiling", "tests\Microsoft.Bot.Builder.Dialogs.Adaptive.Profiling\Microsoft.Bot.Builder.Dialogs.Adaptive.Profiling.csproj", "{D9242899-AB3F-46BB-BAB4-386CB8EC535C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -670,6 +672,14 @@ Global {24CCB459-B4F6-484F-8BA4-946A4AB816FA}.Release|Any CPU.Build.0 = Release|Any CPU {24CCB459-B4F6-484F-8BA4-946A4AB816FA}.Release-Windows|Any CPU.ActiveCfg = Release|Any CPU {24CCB459-B4F6-484F-8BA4-946A4AB816FA}.Release-Windows|Any CPU.Build.0 = Release|Any CPU + {D9242899-AB3F-46BB-BAB4-386CB8EC535C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D9242899-AB3F-46BB-BAB4-386CB8EC535C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D9242899-AB3F-46BB-BAB4-386CB8EC535C}.Debug-Windows|Any CPU.ActiveCfg = Debug|Any CPU + {D9242899-AB3F-46BB-BAB4-386CB8EC535C}.Debug-Windows|Any CPU.Build.0 = Debug|Any CPU + {D9242899-AB3F-46BB-BAB4-386CB8EC535C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D9242899-AB3F-46BB-BAB4-386CB8EC535C}.Release|Any CPU.Build.0 = Release|Any CPU + {D9242899-AB3F-46BB-BAB4-386CB8EC535C}.Release-Windows|Any CPU.ActiveCfg = Release|Any CPU + {D9242899-AB3F-46BB-BAB4-386CB8EC535C}.Release-Windows|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -743,6 +753,7 @@ Global {C8E31CD2-89D4-4659-9557-43EC9C99D984} = {6230B915-B238-4E57-AAC4-06B4498F540F} {1D05EFE4-7F25-4D5A-BCEE-1109B9EF25A8} = {E8CD434A-306F-41D9-B67D-BFFF3287354D} {24CCB459-B4F6-484F-8BA4-946A4AB816FA} = {AD743B78-D61F-4FBF-B620-FA83CE599A50} + {D9242899-AB3F-46BB-BAB4-386CB8EC535C} = {AD743B78-D61F-4FBF-B620-FA83CE599A50} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {7173C9F3-A7F9-496E-9078-9156E35D6E16} diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/Ask.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/Ask.cs index 1a7635e06..aaf6a0d11 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/Ask.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/Ask.cs @@ -57,8 +57,8 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions dc.GetState().TryGetValue(TurnPath.DIALOGEVENT, out DialogEvent trigger); - var expected = ExpectedProperties.GetValue(dc.GetState()); - if (ExpectedProperties != null + var expected = ExpectedProperties?.GetValue(dc.GetState()); + if (expected != null && dc.GetState().TryGetValue(DialogPath.ExpectedProperties, out List lastExpectedProperties) && !expected.Any(prop => !lastExpectedProperties.Contains(prop)) && !lastExpectedProperties.Any(prop => !expected.Contains(prop)) diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Profiling/Microsoft.Bot.Builder.Dialogs.Adaptive.Profiling.csproj b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Profiling/Microsoft.Bot.Builder.Dialogs.Adaptive.Profiling.csproj new file mode 100644 index 000000000..e0f9af877 --- /dev/null +++ b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Profiling/Microsoft.Bot.Builder.Dialogs.Adaptive.Profiling.csproj @@ -0,0 +1,17 @@ + + + + Exe + netcoreapp3.0 + + + + portable + true + + + + + + + diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Profiling/Program.cs b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Profiling/Program.cs new file mode 100644 index 000000000..639c62517 --- /dev/null +++ b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Profiling/Program.cs @@ -0,0 +1,97 @@ +// Licensed under the MIT License. +// Copyright (c) Microsoft Corporation. All rights reserved. + +using System; +using System.IO; +using System.Threading.Tasks; +using Microsoft.Bot.Builder.AI.QnA; +using Microsoft.Bot.Builder.Dialogs.Adaptive.Testing; +using Microsoft.Bot.Builder.Dialogs.Declarative; +using Microsoft.Bot.Builder.Dialogs.Declarative.Resources; +using Microsoft.Bot.Builder.Dialogs.Declarative.Types; +using Microsoft.Bot.Builder.MockLuis; +using Microsoft.Extensions.Configuration; + +namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Profiling +{ + public class Program + { + public static void Help() + { + Console.Error.WriteLine("[-secret ] [-luis ] testscripts..."); + Console.Error.WriteLine("-secret This is your secret id for luis keys."); + Console.Error.WriteLine("-luis This is the directory where luis settings arg."); + System.Environment.Exit(-1); + } + + public static void Main(string[] args) + { + var secret = "profile"; + string luis = null; + if (args.Length == 0) + { + Help(); + } + + for (var i = 0; i < args.Length; ++i) + { + var arg = args[i]; + if (arg.StartsWith("-")) + { + if (arg == "-secret") + { + if (++i < args.Length) + { + secret = args[i]; + } + else + { + throw new System.ArgumentException("Missing --secret value"); + } + } + else if (arg == "-luis") + { + if (++i < args.Length) + { + luis = args[i]; + } + else + { + throw new System.ArgumentException("Missing --luis value"); + } + } + else + { + Console.Error.WriteLine($"Unknown arg {arg}"); + Help(); + } + } + else + { + var cd = Directory.GetCurrentDirectory(); + var dir = Path.GetDirectoryName(arg); + var name = Path.GetFileName(arg); + var config = new ConfigurationBuilder() + .AddInMemoryCollection() + .UseLuisSettings(luis ?? dir, secret) + .Build(); + var explorer = new ResourceExplorer().AddFolder(dir); + DeclarativeTypeLoader.Reset(); + TypeFactory.Configuration = config; + DeclarativeTypeLoader.AddComponent(new DialogComponentRegistration()); + DeclarativeTypeLoader.AddComponent(new AdaptiveComponentRegistration()); + DeclarativeTypeLoader.AddComponent(new LanguageGenerationComponentRegistration()); + DeclarativeTypeLoader.AddComponent(new QnAMakerComponentRegistration()); + DeclarativeTypeLoader.AddComponent(new MockLuisComponentRegistration()); + var script = explorer.LoadType(name); + var timer = new System.Diagnostics.Stopwatch(); + Console.Write($"Executing {arg}"); + timer.Start(); + script.ExecuteAsync(testName: name, configuration: config, resourceExplorer: explorer).Wait(); + timer.Stop(); + Console.WriteLine($" took {timer.ElapsedMilliseconds} ms"); + } + } + } + } +}