diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/AssignEntityTests.cs b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/AssignEntityTests.cs new file mode 100644 index 0000000000..6cd6e25b22 --- /dev/null +++ b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/AssignEntityTests.cs @@ -0,0 +1,55 @@ +// Licensed under the MIT License. +// Copyright (c) Microsoft Corporation. All rights reserved. + +using System.Threading.Tasks; +using Microsoft.Bot.Builder.AI.Luis; +using Microsoft.Bot.Builder.AI.Luis.Testing; +using Microsoft.Extensions.Configuration; +using Xunit; + +namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Tests +{ + [CollectionDefinition("Dialogs.Adaptive")] + public class AssignEntityTests : IClassFixture + { + private readonly string assignEntityDirectory = PathUtils.NormalizePath(@"..\..\..\..\..\tests\Microsoft.Bot.Builder.Dialogs.Adaptive.Tests\Tests\AssignEntityTests\"); + private readonly IConfiguration _configuration; + private readonly ResourceExplorerFixture _resourceExplorerFixture; + + public AssignEntityTests(ResourceExplorerFixture resourceExplorerFixture) + { + _resourceExplorerFixture = resourceExplorerFixture.Initialize(nameof(AssignEntityTests)); + + _configuration = new ConfigurationBuilder() + .UseMockLuisSettings(assignEntityDirectory, "TestBot") + .Build(); + + _resourceExplorerFixture.ResourceExplorer + .RegisterType(LuisAdaptiveRecognizer.Kind, typeof(MockLuisRecognizer), new MockLuisLoader(_configuration)); + } + + [Fact] + public async Task AddEntity() + { + await TestUtils.RunTestScript(_resourceExplorerFixture.ResourceExplorer, configuration: _configuration); + } + + [Fact] + public async Task ClearEntity() + { + await TestUtils.RunTestScript(_resourceExplorerFixture.ResourceExplorer, configuration: _configuration); + } + + [Fact] + public async Task ShowEntity() + { + await TestUtils.RunTestScript(_resourceExplorerFixture.ResourceExplorer, configuration: _configuration); + } + + [Fact] + public async Task HelpEntity() + { + await TestUtils.RunTestScript(_resourceExplorerFixture.ResourceExplorer, configuration: _configuration); + } + } +} diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/ChooseEntityTests.cs b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/ChooseEntityTests.cs new file mode 100644 index 0000000000..3ae4fba34c --- /dev/null +++ b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/ChooseEntityTests.cs @@ -0,0 +1,37 @@ +// Licensed under the MIT License. +// Copyright (c) Microsoft Corporation. All rights reserved. + +using System.Threading.Tasks; +using Microsoft.Bot.Builder.AI.Luis; +using Microsoft.Bot.Builder.AI.Luis.Testing; +using Microsoft.Extensions.Configuration; +using Xunit; + +namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Tests +{ + [CollectionDefinition("Dialogs.Adaptive")] + public class ChooseEntityTests : IClassFixture + { + private readonly string chooseEntityDirectory = PathUtils.NormalizePath(@"..\..\..\..\..\tests\Microsoft.Bot.Builder.Dialogs.Adaptive.Tests\Tests\chooseEntityTests\"); + private readonly IConfiguration _configuration; + private readonly ResourceExplorerFixture _resourceExplorerFixture; + + public ChooseEntityTests(ResourceExplorerFixture resourceExplorerFixture) + { + _resourceExplorerFixture = resourceExplorerFixture.Initialize(nameof(ChooseEntityTests)); + + _configuration = new ConfigurationBuilder() + .UseMockLuisSettings(chooseEntityDirectory, "TestBot") + .Build(); + + _resourceExplorerFixture.ResourceExplorer + .RegisterType(LuisAdaptiveRecognizer.Kind, typeof(MockLuisRecognizer), new MockLuisLoader(_configuration)); + } + + [Fact] + public async Task ChooseEntity() + { + await TestUtils.RunTestScript(_resourceExplorerFixture.ResourceExplorer, configuration: _configuration); + } + } +} diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/ChoosePropertyTests.cs b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/ChoosePropertyTests.cs new file mode 100644 index 0000000000..8437fca30f --- /dev/null +++ b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/ChoosePropertyTests.cs @@ -0,0 +1,37 @@ +// Licensed under the MIT License. +// Copyright (c) Microsoft Corporation. All rights reserved. + +using System.Threading.Tasks; +using Microsoft.Bot.Builder.AI.Luis; +using Microsoft.Bot.Builder.AI.Luis.Testing; +using Microsoft.Extensions.Configuration; +using Xunit; + +namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Tests +{ + [CollectionDefinition("Dialogs.Adaptive")] + public class ChoosePropertyTests : IClassFixture + { + private readonly string choosePropertyDirectory = PathUtils.NormalizePath(@"..\..\..\..\..\tests\Microsoft.Bot.Builder.Dialogs.Adaptive.Tests\Tests\choosePropertyTests\"); + private readonly IConfiguration _configuration; + private readonly ResourceExplorerFixture _resourceExplorerFixture; + + public ChoosePropertyTests(ResourceExplorerFixture resourceExplorerFixture) + { + _resourceExplorerFixture = resourceExplorerFixture.Initialize(nameof(ChoosePropertyTests)); + + _configuration = new ConfigurationBuilder() + .UseMockLuisSettings(choosePropertyDirectory, "TestBot") + .Build(); + + _resourceExplorerFixture.ResourceExplorer + .RegisterType(LuisAdaptiveRecognizer.Kind, typeof(MockLuisRecognizer), new MockLuisLoader(_configuration)); + } + + [Fact] + public async Task ChooseProperty() + { + await TestUtils.RunTestScript(_resourceExplorerFixture.ResourceExplorer, configuration: _configuration); + } + } +} diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/AddEntity.test.dialog b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/AddEntity.test.dialog new file mode 100644 index 0000000000..057cd2ee13 --- /dev/null +++ b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/AddEntity.test.dialog @@ -0,0 +1,95 @@ +{ + "$schema": "../../../tests.schema", + "$kind": "Microsoft.Test.Script", + "description": "Tests for Adding Entity", + "httpRequestMocks": [ + "LuisAddEntity.mock" + ], + "dialog": { + "$kind": "Microsoft.AdaptiveDialog", + "recognizer": { + "$kind": "Microsoft.LuisRecognizer", + "applicationId": "00000000-0000-0000-0000-000000000000", + "endpointKey": "00000000000000000000000000000000", + "endpoint": "https://westus.api.cognitive.microsoft.com", + "predictionOptions": { + "IncludeAPIResults": true + } + }, + "schema": "twoProperties.json", + "triggers": [ + { + "$kind": "Microsoft.OnBeginDialog", + "actions": [ + { + "$kind": "Microsoft.SendActivity", + "activity": "welcome" + } + ] + }, + { + "$kind": "Microsoft.OnEndOfActions", + "condition": "=!$Bread", + "priority": 0, + "actions": [ + { + "$kind": "Microsoft.Ask", + "activity": "Bread?", + "expectedProperties": [ + "Bread" + ] + } + ] + }, + { + "$kind": "Microsoft.OnAssignEntity", + "operation": "Add()", + "property": "Bread", + "entity": "BreadEntity", + "actions": [ + { + "$kind": "Microsoft.SendActivity", + "activity": "Set bread to rye" + }, + { + "$kind": "Microsoft.SetProperty", + "property": "$Bread", + "value": "=@BreadEntity" + } + ] + } + ] + }, + "script": [ + { + "$kind": "Microsoft.Test.UserConversationUpdate", + "membersAdded": [ + "Bot", + "User" + ], + "membersRemoved": [] + }, + { + "$kind": "Microsoft.Test.AssertReply", + "text": "welcome" + }, + { + "$kind": "Microsoft.Test.AssertReply", + "text": "Bread?" + }, + { + "$kind": "Microsoft.Test.UserSays", + "text": "rye" + }, + { + "$kind": "Microsoft.Test.AssertReply", + "text": "Set bread to rye" + }, + { + "$kind": "Microsoft.Test.MemoryAssertions", + "assertions": [ + "$Bread == 'rye'" + ] + } + ] +} \ No newline at end of file diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/ClearEntity.test.dialog b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/ClearEntity.test.dialog new file mode 100644 index 0000000000..0afe7824ba --- /dev/null +++ b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/ClearEntity.test.dialog @@ -0,0 +1,107 @@ +{ + "$schema": "../../../tests.schema", + "$kind": "Microsoft.Test.Script", + "description": "Tests for Clearing Entity", + "httpRequestMocks": [ + "LuisAddEntity.mock", + "LuisClearEntity.mock" + ], + "dialog": { + "$kind": "Microsoft.AdaptiveDialog", + "recognizer": { + "$kind": "Microsoft.LuisRecognizer", + "applicationId": "00000000-0000-0000-0000-000000000000", + "endpointKey": "00000000000000000000000000000000", + "endpoint": "https://westus.api.cognitive.microsoft.com", + "predictionOptions": { + "IncludeAPIResults": true + } + }, + "schema": "twoProperties.json", + "triggers": [ + { + "$kind": "Microsoft.OnEndOfActions", + "condition": "=!$Bread", + "priority": 0, + "actions": [ + { + "$kind": "Microsoft.Ask", + "activity": "Bread?", + "expectedProperties": [ + "Bread" + ] + } + ] + }, + { + "$kind": "Microsoft.OnAssignEntity", + "operation": "Add()", + "property": "Bread", + "entity": "BreadEntity", + "actions": [ + { + "$kind": "Microsoft.SendActivity", + "activity": "Set bread to rye" + }, + { + "$kind": "Microsoft.SetProperty", + "property": "$Bread", + "value": "=@BreadEntity" + } + ] + }, + { + "$kind": "Microsoft.OnAssignEntity", + "operation": "Clear()", + "property": "Bread", + "actions": [ + { + "$kind": "Microsoft.SendActivity", + "activity": "bread has been cleared." + }, + { + "$kind": "Microsoft.DeleteProperty", + "property": "$Bread" + } + ] + } + ] + }, + "script": [ + { + "$kind": "Microsoft.Test.UserConversationUpdate", + "membersAdded": [ + "Bot", + "User" + ], + "membersRemoved": [] + }, + { + "$kind": "Microsoft.Test.AssertReply", + "text": "Bread?" + }, + { + "$kind": "Microsoft.Test.UserSays", + "text": "rye" + }, + { + "$kind": "Microsoft.Test.AssertReply", + "text": "Set bread to rye" + }, + { + "$kind": "Microsoft.Test.UserSays", + "text": "clear bread" + }, + { + "$kind": "Microsoft.Test.AssertReply", + "text": "bread has been cleared." + }, + { + "$kind": "Microsoft.Test.MemoryAssertions", + "assertions": [ + "!$Bread" + ] + } + + ] +} \ No newline at end of file diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/HelpEntity.test.dialog b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/HelpEntity.test.dialog new file mode 100644 index 0000000000..6d8634da80 --- /dev/null +++ b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/HelpEntity.test.dialog @@ -0,0 +1,52 @@ +{ + "$schema": "../../../tests.schema", + "$kind": "Microsoft.Test.Script", + "description": "Tests for Helping Entity", + "httpRequestMocks": [ + "LuisHelpEntity.mock" + ], + "dialog": { + "$kind": "Microsoft.AdaptiveDialog", + "recognizer": { + "$kind": "Microsoft.LuisRecognizer", + "applicationId": "00000000-0000-0000-0000-000000000000", + "endpointKey": "00000000000000000000000000000000", + "endpoint": "https://westus.api.cognitive.microsoft.com", + "predictionOptions": { + "IncludeAPIResults": true + } + }, + "schema": "twoProperties.json", + "triggers": [ + { + "$kind": "Microsoft.OnAssignEntity", + "operation": "Help()", + "property": "Bread", + "actions": [ + { + "$kind": "Microsoft.SendActivity", + "activity": "possible values" + } + ] + } + ] + }, + "script": [ + { + "$kind": "Microsoft.Test.UserConversationUpdate", + "membersAdded": [ + "Bot", + "User" + ], + "membersRemoved": [] + }, + { + "$kind": "Microsoft.Test.UserSays", + "text": "help bread" + }, + { + "$kind": "Microsoft.Test.AssertReply", + "text": "possible values" + } + ] +} \ No newline at end of file diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/LuisAddEntity.mock.dialog b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/LuisAddEntity.mock.dialog new file mode 100644 index 0000000000..cc5909316a --- /dev/null +++ b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/LuisAddEntity.mock.dialog @@ -0,0 +1,63 @@ +{ + "$schema": "../../../tests.schema", + "$kind": "Microsoft.Test.HttpRequestSequenceMock", + "method": "POST", + "url": "https://westus.api.cognitive.microsoft.com/luis/prediction/v3.0/apps/00000000-0000-0000-0000-000000000000/*", + "body": "\"query\": \"rye\"", + "responses": [ + { + "content": { + "query": "rye", + "prediction": { + "topIntent": "none", + "intents": { + "sandwich": { + "score": 0.9 + } + }, + "entities": { + "Bread": [ + { + "BreadEntity": [ + [ + "rye" + ] + ], + "$instance": { + "BreadEntity": [ + { + "type": "BreadEntity", + "text": "rye", + "startIndex": 0, + "length": 3, + "modelTypeId": 1, + "modelType": "Entity Extractor", + "recognitionSources": [ + "model" + ] + } + ] + } + } + ], + "$instance": { + "Bread": [ + { + "type": "Bread", + "text": "rye", + "startIndex": 0, + "length": 3, + "modelTypeId": 1, + "modelType": "Entity Extractor", + "recognitionSources": [ + "model" + ] + } + ] + } + } + } + } + } + ] +} \ No newline at end of file diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/LuisAddToppingsEntity.mock.dialog b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/LuisAddToppingsEntity.mock.dialog new file mode 100644 index 0000000000..f42f45363a --- /dev/null +++ b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/LuisAddToppingsEntity.mock.dialog @@ -0,0 +1,96 @@ +{ + "$schema": "../../../tests.schema", + "$kind": "Microsoft.Test.HttpRequestSequenceMock", + "method": "POST", + "url": "https://westus.api.cognitive.microsoft.com/luis/prediction/v3.0/apps/00000000-0000-0000-0000-000000000000/*", + "body": "\"query\": \"add tomato and lettuce\"", + "responses": [ + { + "content": { + "query": "add tomato and lettuce", + "prediction": { + "entities": { + "$instance": { + "Add()": [ + { + "length": 22, + "modelType": "Entity Extractor", + "modelTypeId": 1, + "recognitionSources": [ + "model" + ], + "startIndex": 0, + "text": "add tomato and lettuce", + "type": "Add()" + } + ] + }, + "Add()": [ + { + "$instance": { + "Toppings": [ + { + "length": 18, + "modelType": "Entity Extractor", + "modelTypeId": 1, + "recognitionSources": [ + "model" + ], + "startIndex": 4, + "text": "tomato and lettuce", + "type": "Toppings" + } + ] + }, + "Toppings": [ + { + "$instance": { + "ToppingsEntity": [ + { + "length": 6, + "modelType": "Entity Extractor", + "modelTypeId": 1, + "recognitionSources": [ + "model" + ], + "startIndex": 4, + "text": "tomato", + "type": "ToppingsEntity" + }, + { + "length": 7, + "modelType": "Entity Extractor", + "modelTypeId": 1, + "recognitionSources": [ + "model" + ], + "startIndex": 15, + "text": "lettuce", + "type": "ToppingsEntity" + } + ] + }, + "ToppingsEntity": [ + [ + "tomato" + ], + [ + "lettuce" + ] + ] + } + ] + } + ] + }, + "intents": { + "sandwich": { + "score": 0.9971155 + } + }, + "topIntent": "sandwich" + } + } + } + ] +} \ No newline at end of file diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/LuisClearEntity.mock.dialog b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/LuisClearEntity.mock.dialog new file mode 100644 index 0000000000..4bf41a0d5b --- /dev/null +++ b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/LuisClearEntity.mock.dialog @@ -0,0 +1,61 @@ +{ + "$schema": "../../../tests.schema", + "$kind": "Microsoft.Test.HttpRequestSequenceMock", + "method": "POST", + "url": "https://westus.api.cognitive.microsoft.com/luis/prediction/v3.0/apps/00000000-0000-0000-0000-000000000000/*", + "body": "\"query\": \"clear bread\"", + "responses": [ + { + "content": { + "query": "clear bread", + "prediction": { + "entities": { + "$instance": { + "Clear()": [ + { + "length": 11, + "modelType": "Entity Extractor", + "modelTypeId": 1, + "recognitionSources": [ + "model" + ], + "startIndex": 0, + "text": "clear bread", + "type": "Clear()" + } + ] + }, + "Clear()": [ + { + "$instance": { + "Bread": [ + { + "length": 5, + "modelType": "Entity Extractor", + "modelTypeId": 1, + "recognitionSources": [ + "model" + ], + "startIndex": 6, + "text": "bread", + "type": "Bread" + } + ] + }, + "Bread": [ + {} + ] + } + ] + }, + "intents": { + "sandwich": { + "score": 0.99816823 + } + }, + "topIntent": "sandwich" + } + } + } + ] +} \ No newline at end of file diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/LuisHelpEntity.mock.dialog b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/LuisHelpEntity.mock.dialog new file mode 100644 index 0000000000..7dad1953d4 --- /dev/null +++ b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/LuisHelpEntity.mock.dialog @@ -0,0 +1,61 @@ +{ + "$schema": "../../../tests.schema", + "$kind": "Microsoft.Test.HttpRequestSequenceMock", + "method": "POST", + "url": "https://westus.api.cognitive.microsoft.com/luis/prediction/v3.0/apps/00000000-0000-0000-0000-000000000000/*", + "body": "\"query\": \"help bread\"", + "responses": [ + { + "content": { + "query": "help bread", + "prediction": { + "entities": { + "$instance": { + "Help()": [ + { + "length": 10, + "modelType": "Entity Extractor", + "modelTypeId": 1, + "recognitionSources": [ + "model" + ], + "startIndex": 0, + "text": "help bread", + "type": "Help()" + } + ] + }, + "Help()": [ + { + "$instance": { + "Bread": [ + { + "length": 5, + "modelType": "Entity Extractor", + "modelTypeId": 1, + "recognitionSources": [ + "model" + ], + "startIndex": 5, + "text": "bread", + "type": "Bread" + } + ] + }, + "Bread": [ + {} + ] + } + ] + }, + "intents": { + "sandwich": { + "score": 0.9987374 + } + }, + "topIntent": "sandwich" + } + } + } + ] +} \ No newline at end of file diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/LuisRemoveEntity.mock.dialog b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/LuisRemoveEntity.mock.dialog new file mode 100644 index 0000000000..ad29d52dfe --- /dev/null +++ b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/LuisRemoveEntity.mock.dialog @@ -0,0 +1,82 @@ +{ + "$schema": "../../../tests.schema", + "$kind": "Microsoft.Test.HttpRequestSequenceMock", + "method": "POST", + "url": "https://westus.api.cognitive.microsoft.com/luis/prediction/v3.0/apps/00000000-0000-0000-0000-000000000000/*", + "body": "\"query\": \"remove tomato\"", + "responses": [ + { + "content": { + "query": "remove tomato", + "prediction": { + "entities": { + "$instance": { + "Remove()": [ + { + "length": 13, + "modelType": "Entity Extractor", + "modelTypeId": 1, + "recognitionSources": [ + "model" + ], + "startIndex": 0, + "text": "remove tomato", + "type": "Remove()" + } + ] + }, + "Remove()": [ + { + "$instance": { + "Toppings": [ + { + "length": 6, + "modelType": "Entity Extractor", + "modelTypeId": 1, + "recognitionSources": [ + "model" + ], + "startIndex": 7, + "text": "tomato", + "type": "Toppings" + } + ] + }, + "Toppings": [ + { + "$instance": { + "ToppingsEntity": [ + { + "length": 6, + "modelType": "Entity Extractor", + "modelTypeId": 1, + "recognitionSources": [ + "model" + ], + "startIndex": 7, + "text": "tomato", + "type": "ToppingsEntity" + } + ] + }, + "ToppingsEntity": [ + [ + "tomato" + ] + ] + } + ] + } + ] + }, + "intents": { + "sandwich": { + "score": 0.997536838 + } + }, + "topIntent": "sandwich" + } + } + } + ] +} \ No newline at end of file diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/LuisShowEntity.mock.dialog b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/LuisShowEntity.mock.dialog new file mode 100644 index 0000000000..f077fb46e9 --- /dev/null +++ b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/LuisShowEntity.mock.dialog @@ -0,0 +1,61 @@ +{ + "$schema": "../../../tests.schema", + "$kind": "Microsoft.Test.HttpRequestSequenceMock", + "method": "POST", + "url": "https://westus.api.cognitive.microsoft.com/luis/prediction/v3.0/apps/00000000-0000-0000-0000-000000000000/*", + "body": "\"query\": \"show bread\"", + "responses": [ + { + "content": { + "query": "show bread", + "prediction": { + "entities": { + "$instance": { + "Show()": [ + { + "length": 10, + "modelType": "Entity Extractor", + "modelTypeId": 1, + "recognitionSources": [ + "model" + ], + "startIndex": 0, + "text": "show bread", + "type": "Show()" + } + ] + }, + "Show()": [ + { + "$instance": { + "Bread": [ + { + "length": 5, + "modelType": "Entity Extractor", + "modelTypeId": 1, + "recognitionSources": [ + "model" + ], + "startIndex": 5, + "text": "bread", + "type": "Bread" + } + ] + }, + "Bread": [ + {} + ] + } + ] + }, + "intents": { + "sandwich": { + "score": 0.9984165 + } + }, + "topIntent": "sandwich" + } + } + } + ] +} \ No newline at end of file diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/RemoveEntity.test.dialog b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/RemoveEntity.test.dialog new file mode 100644 index 0000000000..82ce14e013 --- /dev/null +++ b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/RemoveEntity.test.dialog @@ -0,0 +1,111 @@ +{ + "$schema": "../../../tests.schema", + "$kind": "Microsoft.Test.Script", + "description": "Tests for Removing Entity", + "httpRequestMocks": [ + "LuisAddToppingsEntity.mock", + "LuisRemoveEntity.mock" + ], + "dialog": { + "$kind": "Microsoft.AdaptiveDialog", + "recognizer": { + "$kind": "Microsoft.LuisRecognizer", + "applicationId": "00000000-0000-0000-0000-000000000000", + "endpointKey": "00000000000000000000000000000000", + "endpoint": "https://westus.api.cognitive.microsoft.com", + "predictionOptions": { + "IncludeAPIResults": true + } + }, + "schema": "twoProperties.json", + "triggers": [ + { + "$kind": "Microsoft.OnEndOfActions", + "condition": "=!$Toppings", + "priority": 0, + "actions": [ + { + "$kind": "Microsoft.Ask", + "activity": "Toppings?", + "expectedProperties": [ + "Toppings" + ] + } + ] + }, + { + "$kind": "Microsoft.OnAssignEntity", + "operation": "Add()", + "property": "Toppings", + "entity": "ToppingsEntity", + "actions": [ + { + "$kind": "Microsoft.SendActivity", + "activity": "Set toppings to tomato and lettuce" + }, + { + "$kind": "Microsoft.EditArray", + "changeType": "push", + "itemsProperty": "$Toppings", + "value": "=@ToppingsEntity" + } + ] + }, + { + "$kind": "Microsoft.OnAssignEntity", + "operation": "Remove()", + "property": "Toppings", + "entity": "ToppingsEntity", + "actions": [ + { + "$kind": "Microsoft.SendActivity", + "activity": "tomato has been removed" + }, + { + "$kind": "Microsoft.EditArray", + "changeType": "remove", + "itemsProperty": "$Toppings", + "value": "=@ToppingsEntity" + } + ] + } + ] + }, + "script": [ + { + "$kind": "Microsoft.Test.UserConversationUpdate", + "membersAdded": [ + "Bot", + "User" + ], + "membersRemoved": [] + }, + { + "$kind": "Microsoft.Test.AssertReply", + "text": "Toppings?" + }, + { + "$kind": "Microsoft.Test.UserSays", + "text": "add tomato and lettuce" + }, + { + "$kind": "Microsoft.Test.AssertReply", + "text": "Set toppings to tomato and lettuce" + }, + { + "$kind": "Microsoft.Test.UserSays", + "text": "remove tomato" + }, + { + "$kind": "Microsoft.Test.AssertReply", + "text": "tomato has been removed" + }, + { + "$kind": "Microsoft.Test.MemoryAssertions", + "assertions": [ + "$Toppings" + ] + } + + ] +} \ No newline at end of file diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/ShowEntity.test.dialog b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/ShowEntity.test.dialog new file mode 100644 index 0000000000..bb9041852b --- /dev/null +++ b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/ShowEntity.test.dialog @@ -0,0 +1,52 @@ +{ + "$schema": "../../../tests.schema", + "$kind": "Microsoft.Test.Script", + "description": "Tests for Showing Entity", + "httpRequestMocks": [ + "LuisShowEntity.mock" + ], + "dialog": { + "$kind": "Microsoft.AdaptiveDialog", + "recognizer": { + "$kind": "Microsoft.LuisRecognizer", + "applicationId": "00000000-0000-0000-0000-000000000000", + "endpointKey": "00000000000000000000000000000000", + "endpoint": "https://westus.api.cognitive.microsoft.com", + "predictionOptions": { + "IncludeAPIResults": true + } + }, + "schema": "twoProperties.json", + "triggers": [ + { + "$kind": "Microsoft.OnAssignEntity", + "operation": "Show()", + "property": "Bread", + "actions": [ + { + "$kind": "Microsoft.SendActivity", + "activity": "bread : rye" + } + ] + } + ] + }, + "script": [ + { + "$kind": "Microsoft.Test.UserConversationUpdate", + "membersAdded": [ + "Bot", + "User" + ], + "membersRemoved": [] + }, + { + "$kind": "Microsoft.Test.UserSays", + "text": "show bread" + }, + { + "$kind": "Microsoft.Test.AssertReply", + "text": "bread : rye" + } + ] +} \ No newline at end of file diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/luis.settings.westus.json b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/luis.settings.westus.json new file mode 100644 index 0000000000..91dd9c8a25 --- /dev/null +++ b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/luis.settings.westus.json @@ -0,0 +1,6 @@ +{ + "app_en_us_lu": { + "appId": "0000000", + "version": "0.1" + } +} diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/twoProperties.json b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/twoProperties.json new file mode 100644 index 0000000000..d09e7f0e15 --- /dev/null +++ b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/AssignEntityTests/twoProperties.json @@ -0,0 +1,53 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema", + "type": "object", + "properties": { + "Bread": { + "type": "string", + "enum": [ + "multiGrainWheat", + "rye", + "white", + "wholeWheat" + ], + "$entities": [ + "BreadEntity" + ] + }, + "Toppings": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "tomato", + "lettuce", + "pickles", + "greenPeppers", + "redPepppers", + "whiteOnions", + "redOnions" + ], + "maxItems": 3 + }, + "$entities": [ + "ToppingsEntity" + ] + } + }, + "required": [ + "Bread", + "Toppings" + ], + "$operations": [ + "Add()", + "Remove()", + "Clear()", + "Show()", + "Help()" + ], + "$defaultOperation": { + "": { + "": "Add()" + } + } +} \ No newline at end of file diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/ChooseEntityTests/ChooseEntity.test.dialog b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/ChooseEntityTests/ChooseEntity.test.dialog new file mode 100644 index 0000000000..bc5fdc1209 --- /dev/null +++ b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/ChooseEntityTests/ChooseEntity.test.dialog @@ -0,0 +1,108 @@ +{ + "$schema": "../../../tests.schema", + "$kind": "Microsoft.Test.Script", + "description": "Tests for Choosing Entity", + "httpRequestMocks": [ + "LuisChooseEntity.mock" + ], + "dialog": { + "$kind": "Microsoft.AdaptiveDialog", + "recognizer": { + "$kind": "Microsoft.LuisRecognizer", + "applicationId": "00000000-0000-0000-0000-000000000000", + "endpointKey": "00000000000000000000000000000000", + "endpoint": "https://westus.api.cognitive.microsoft.com", + "predictionOptions": { + "IncludeAPIResults": true + } + }, + "schema": "oneProperty.json", + "triggers": [ + { + "$kind": "Microsoft.OnBeginDialog", + "actions": [ + { + "$kind": "Microsoft.SendActivity", + "activity": "welcome" + } + ] + }, + { + "$kind": "Microsoft.OnEndOfActions", + "condition": "=!$Bread", + "priority": 0, + "actions": [ + { + "$kind": "Microsoft.Ask", + "activity": "which value do you what for bread ?", + "expectedProperties": [ + "Bread" + ] + } + ] + }, + { + "$kind": "Microsoft.OnAssignEntity", + "operation": "Add()", + "property": "Bread", + "entity": "BreadEntity", + "actions": [ + { + "$kind": "Microsoft.SetProperty", + "property": "$Bread", + "value": "=@BreadEntity" + } + ] + }, + { + "$kind": "Microsoft.OnChooseEntity", + "entity": "BreadEntity", + "actions": [ + { + "$kind": "Microsoft.Ask", + "activity": "Please choose a value for bread from [multi grain wheat, whole wheat]", + "expectedProperties": [ + "Bread" + ] + } + ] + } + ] + }, + "script": [ + { + "$kind": "Microsoft.Test.UserConversationUpdate", + "membersAdded": [ + "Bot", + "User" + ], + "membersRemoved": [] + }, + { + "$kind": "Microsoft.Test.AssertReply", + "text": "welcome" + }, + { + "$kind": "Microsoft.Test.AssertReply", + "text": "which value do you what for bread ?" + }, + { + "$kind": "Microsoft.Test.UserSays", + "text": "wheat" + }, + { + "$kind": "Microsoft.Test.AssertReply", + "text": "Please choose a value for bread from [multi grain wheat, whole wheat]" + }, + { + "$kind": "Microsoft.Test.UserSays", + "text": "whole wheat" + }, + { + "$kind": "Microsoft.Test.MemoryAssertions", + "assertions": [ + "$Bread == 'whole wheat'" + ] + } + ] +} diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/ChooseEntityTests/LuisChooseEntity.mock.dialog b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/ChooseEntityTests/LuisChooseEntity.mock.dialog new file mode 100644 index 0000000000..1bdc28e08b --- /dev/null +++ b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/ChooseEntityTests/LuisChooseEntity.mock.dialog @@ -0,0 +1,51 @@ +{ + "$schema": "../../../tests.schema", + "$kind": "Microsoft.Test.HttpRequestSequenceMock", + "method": "POST", + "url": "https://westus.api.cognitive.microsoft.com/luis/prediction/v3.0/apps/00000000-0000-0000-0000-000000000000/*", + "body": "\"query\": \"wheat\"", + "responses": [ + { + "content": { + "query": "wheat", + "prediction": { + "topIntent": "sandwich", + "intents": { "sandwich": { "score": 0.9939042 } }, + "entities": { + "Bread": [ + { + "BreadEntity": [ [ "multiGrainWheat", "wholeWheat" ] ], + "$instance": { + "BreadEntity": [ + { + "type": "BreadEntity", + "text": "wheat", + "startIndex": 0, + "length": 5, + "modelTypeId": 1, + "modelType": "Entity Extractor", + "recognitionSources": [ "model" ] + } + ] + } + } + ], + "$instance": { + "Bread": [ + { + "type": "Bread", + "text": "wheat", + "startIndex": 0, + "length": 5, + "modelTypeId": 1, + "modelType": "Entity Extractor", + "recognitionSources": [ "model" ] + } + ] + } + } + } + } + } + ] +} diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/ChooseEntityTests/luis.settings.westus.json b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/ChooseEntityTests/luis.settings.westus.json new file mode 100644 index 0000000000..91dd9c8a25 --- /dev/null +++ b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/ChooseEntityTests/luis.settings.westus.json @@ -0,0 +1,6 @@ +{ + "app_en_us_lu": { + "appId": "0000000", + "version": "0.1" + } +} diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/ChooseEntityTests/oneProperty.json b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/ChooseEntityTests/oneProperty.json new file mode 100644 index 0000000000..62069929a4 --- /dev/null +++ b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/ChooseEntityTests/oneProperty.json @@ -0,0 +1,29 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema", + "type": "object", + "properties": { + "Bread": { + "type": "string", + "enum": [ + "multiGrainWheat", + "rye", + "white", + "wholeWheat" + ], + "$entities": [ + "BreadEntity" + ] + } + }, + "required": [ + "Bread" + ], + "$operations": [ + "Add()" + ], + "$defaultOperation": { + "": { + "": "Add()" + } + } +} \ No newline at end of file diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/ChoosePropertyTests/ChooseProperty.test.dialog b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/ChoosePropertyTests/ChooseProperty.test.dialog new file mode 100644 index 0000000000..6afaed39e9 --- /dev/null +++ b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/ChoosePropertyTests/ChooseProperty.test.dialog @@ -0,0 +1,121 @@ +{ + "$schema": "../../../tests.schema", + "$kind": "Microsoft.Test.Script", + "description": "Tests for Choosing Property", + "httpRequestMocks": [ + "LuisChooseProperty.mock", + "LuisProperty.mock" + ], + "dialog": { + "$kind": "Microsoft.AdaptiveDialog", + "recognizer": { + "$kind": "Microsoft.LuisRecognizer", + "applicationId": "00000000-0000-0000-0000-000000000000", + "endpointKey": "00000000000000000000000000000000", + "endpoint": "https://westus.api.cognitive.microsoft.com", + "predictionOptions": { + "IncludeAPIResults": true + } + }, + "schema": "threeProperties.json", + "triggers": [ + { + "$kind": "Microsoft.OnBeginDialog", + "actions": [ + { + "$kind": "Microsoft.SendActivity", + "activity": "welcome" + } + ] + }, + { + "$kind": "Microsoft.OnEndOfActions", + "condition": "=!$Name", + "priority": 0, + "actions": [ + { + "$kind": "Microsoft.Ask", + "activity": "Name?", + "expectedProperties": [ + "Name" + ] + } + ] + }, + { + "$kind": "Microsoft.OnChooseProperty", + "actions": [ + { + "$kind": "Microsoft.Ask", + "activity": "meat or cheese ?", + "expectedProperties": [ + "PropertyToChange" + ] + } + ] + }, + { + "$kind": "Microsoft.OnAssignEntity", + "operation": "Add()", + "property": "Meat", + "entity": "MeatEntity", + "actions": [ + { + "$kind": "Microsoft.SendActivity", + "activity": "set meat to none" + }, + { + "$kind": "Microsoft.SetProperty", + "property": "$Meat", + "value": "=@MeatEntity" + }, + { + "$kind": "Microsoft.IfCondition", + "condition": "$PropertyToChange == 'Meat'", + "actions": [ + { + "$kind": "Microsoft.DeleteProperty", + "property": "$PropertyToChange" + } + ] + } + ] + } + ] + }, + "script": [ + { + "$kind": "Microsoft.Test.UserConversationUpdate", + "membersAdded": [ + "Bot", + "User" + ], + "membersRemoved": [] + }, + { + "$kind": "Microsoft.Test.AssertReply", + "text": "welcome" + }, + { + "$kind": "Microsoft.Test.AssertReply", + "text": "Name?" + }, + { + "$kind": "Microsoft.Test.UserSays", + "text": "none" + }, + { + "$kind": "Microsoft.Test.AssertReply", + "text": "meat or cheese ?" + }, + { + "$kind": "Microsoft.Test.UserSays", + "text": "meat" + }, + { + "$kind": "Microsoft.Test.AssertReply", + "text": "set meat to none" + } + + ] +} diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/ChoosePropertyTests/LuisChooseProperty.mock.dialog b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/ChoosePropertyTests/LuisChooseProperty.mock.dialog new file mode 100644 index 0000000000..ebe0635eb8 --- /dev/null +++ b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/ChoosePropertyTests/LuisChooseProperty.mock.dialog @@ -0,0 +1,81 @@ +{ + "$schema": "../../../tests.schema", + "$kind": "Microsoft.Test.HttpRequestSequenceMock", + "method": "POST", + "url": "https://westus.api.cognitive.microsoft.com/luis/prediction/v3.0/apps/00000000-0000-0000-0000-000000000000/*", + "body": "\"query\": \"none\"", + "responses": [ + { + "content": { + "query": "none", + "prediction": { + "entities": { + "$instance": { + "CheeseEntity": [ + { + "length": 4, + "modelType": "List Entity Extractor", + "modelTypeId": 5, + "recognitionSources": [ + "model" + ], + "startIndex": 0, + "text": "none", + "type": "CheeseEntity" + } + ], + "Meat": [ + { + "length": 4, + "modelType": "Entity Extractor", + "modelTypeId": 1, + "recognitionSources": [ + "model" + ], + "startIndex": 0, + "text": "none", + "type": "Meat" + } + ] + }, + "CheeseEntity": [ + [ + "none" + ] + ], + "Meat": [ + { + "$instance": { + "MeatEntity": [ + { + "length": 4, + "modelType": "Entity Extractor", + "modelTypeId": 1, + "recognitionSources": [ + "model" + ], + "startIndex": 0, + "text": "none", + "type": "MeatEntity" + } + ] + }, + "MeatEntity": [ + [ + "none" + ] + ] + } + ] + }, + "intents": { + "sandwich": { + "score": 0.9335949 + } + }, + "topIntent": "sandwich" + } + } + } + ] +} diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/ChoosePropertyTests/LuisProperty.mock.dialog b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/ChoosePropertyTests/LuisProperty.mock.dialog new file mode 100644 index 0000000000..4c75ff3273 --- /dev/null +++ b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/ChoosePropertyTests/LuisProperty.mock.dialog @@ -0,0 +1,42 @@ +{ + "$schema": "../../../tests.schema", + "$kind": "Microsoft.Test.HttpRequestSequenceMock", + "method": "POST", + "url": "https://westus.api.cognitive.microsoft.com/luis/prediction/v3.0/apps/00000000-0000-0000-0000-000000000000/*", + "body": "\"query\": \"meat\"", + "responses": [ + { + "content": { + "query": "meat", + "prediction": { + "entities": { + "$instance": { + "Meat": [ + { + "length": 4, + "modelType": "Entity Extractor", + "modelTypeId": 1, + "recognitionSources": [ + "model" + ], + "startIndex": 0, + "text": "meat", + "type": "Meat" + } + ] + }, + "Meat": [ + {} + ] + }, + "intents": { + "sandwich": { + "score": 0.9991361 + } + }, + "topIntent": "sandiwch" + } + } + } + ] +} diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/ChoosePropertyTests/luis.settings.westus.json b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/ChoosePropertyTests/luis.settings.westus.json new file mode 100644 index 0000000000..91dd9c8a25 --- /dev/null +++ b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/ChoosePropertyTests/luis.settings.westus.json @@ -0,0 +1,6 @@ +{ + "app_en_us_lu": { + "appId": "0000000", + "version": "0.1" + } +} diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/ChoosePropertyTests/threeProperties.json b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/ChoosePropertyTests/threeProperties.json new file mode 100644 index 0000000000..775cd5ff46 --- /dev/null +++ b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/Tests/ChoosePropertyTests/threeProperties.json @@ -0,0 +1,73 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema", + "type": "object", + "properties": { + "Name": { + "type": "string", + "$entities": [ + "personName" + ] + }, + "Meat": { + "type": "string", + "enum": [ + "bacon", + "chicken", + "ham", + "pulled pork", + "roast beef", + "salami", + "turkey", + "none" + ], + "$entities": [ + "MeatEntity" + ] + }, + "Cheese": { + "type": "string", + "enum": [ + "american", + "cheddar", + "feta", + "gouda", + "pepper jack", + "provolone", + "swiss", + "none" + ], + "$entities": [ + "CheeseEntity" + ] + }, + "PropertyToChange": { + "type": "string", + "$entities": [ + "Name", + "Meat", + "Cheese" + ] + } + }, + "required": [ + "Name", + "Meat", + "Cheese" + ], + "$operations": [ + "Add()", + "Remove()", + "Clear()", + "Show()", + "Help()", + "Change()" + ], + "$expectedOnly": [ + "personName" + ], + "$defaultOperation": { + "": { + "": "Add()" + } + } +} \ No newline at end of file