diff --git a/Microsoft.Bot.Builder.sln b/Microsoft.Bot.Builder.sln index 59b6e94a50..a1951dc16a 100644 --- a/Microsoft.Bot.Builder.sln +++ b/Microsoft.Bot.Builder.sln @@ -54,13 +54,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Bot.Builder.Tests EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Bot.Builder.Transcripts.Tests", "tests\Microsoft.Bot.Builder.Transcripts.Tests\Microsoft.Bot.Builder.Transcripts.Tests.csproj", "{71698D71-4C6F-40D5-8BDE-2587514CA21C}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Bot.Builder.TestBot", "tests\Microsoft.Bot.Builder.TestBot\Microsoft.Bot.Builder.TestBot.csproj", "{F87B093D-A3AC-4125-A8A8-FE167F918FFF}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Bot.Configuration", "libraries\Microsoft.Bot.Configuration\Microsoft.Bot.Configuration.csproj", "{0B8ABFDB-F9CF-4EC6-988E-9C32D9E01C26}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Bot.Configuration.Tests", "tests\Microsoft.Bot.Configuration.Tests\Microsoft.Bot.Configuration.Tests.csproj", "{1B7920E6-5262-4054-B72D-3A8DBBA057D2}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Bot.Builder.TestBot.WebApi", "tests\Microsoft.Bot.Builder.TestBot.WebApi\Microsoft.Bot.Builder.TestBot.WebApi.csproj", "{298009D3-971D-4375-A2F2-04CFB168CED9}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Bot.Configuration.Tests", "tests\Microsoft.Bot.Configuration.Tests\Microsoft.Bot.Configuration.Tests.csproj", "{1B7920E6-5262-4054-B72D-3A8DBBA057D2}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Bot.Builder.Integration.ApplicationInsights.Core", "libraries\integration\Microsoft.Bot.Builder.Integration.ApplicationInsights.Core\Microsoft.Bot.Builder.Integration.ApplicationInsights.Core.csproj", "{8FC920C6-E895-4A17-AB2F-452FAAA36CC8}" EndProject @@ -74,6 +70,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Bot.ApplicationIn EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Bot.Builder.ApplicationInsights.Tests", "tests\Microsoft.Bot.Builder.ApplicationInsights.Tests\Microsoft.Bot.Builder.ApplicationInsights.Tests.csproj", "{D790A4BB-D8AC-4AAE-B3FE-0CF432CA8031}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Bot.Builder.TestBot", "tests\Microsoft.Bot.Builder.TestBot\Microsoft.Bot.Builder.TestBot.csproj", "{C113E0AE-5564-4389-BA39-183A8D574210}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug - NuGet Packages|Any CPU = Debug - NuGet Packages|Any CPU @@ -249,14 +247,6 @@ Global {71698D71-4C6F-40D5-8BDE-2587514CA21C}.Documentation|Any CPU.Build.0 = Debug|Any CPU {71698D71-4C6F-40D5-8BDE-2587514CA21C}.Release|Any CPU.ActiveCfg = Release|Any CPU {71698D71-4C6F-40D5-8BDE-2587514CA21C}.Release|Any CPU.Build.0 = Release|Any CPU - {F87B093D-A3AC-4125-A8A8-FE167F918FFF}.Debug - NuGet Packages|Any CPU.ActiveCfg = Debug|Any CPU - {F87B093D-A3AC-4125-A8A8-FE167F918FFF}.Debug - NuGet Packages|Any CPU.Build.0 = Debug|Any CPU - {F87B093D-A3AC-4125-A8A8-FE167F918FFF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F87B093D-A3AC-4125-A8A8-FE167F918FFF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F87B093D-A3AC-4125-A8A8-FE167F918FFF}.Documentation|Any CPU.ActiveCfg = Debug|Any CPU - {F87B093D-A3AC-4125-A8A8-FE167F918FFF}.Documentation|Any CPU.Build.0 = Debug|Any CPU - {F87B093D-A3AC-4125-A8A8-FE167F918FFF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F87B093D-A3AC-4125-A8A8-FE167F918FFF}.Release|Any CPU.Build.0 = Release|Any CPU {0B8ABFDB-F9CF-4EC6-988E-9C32D9E01C26}.Debug - NuGet Packages|Any CPU.ActiveCfg = Debug|Any CPU {0B8ABFDB-F9CF-4EC6-988E-9C32D9E01C26}.Debug - NuGet Packages|Any CPU.Build.0 = Debug|Any CPU {0B8ABFDB-F9CF-4EC6-988E-9C32D9E01C26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU @@ -273,14 +263,6 @@ Global {1B7920E6-5262-4054-B72D-3A8DBBA057D2}.Documentation|Any CPU.Build.0 = Debug|Any CPU {1B7920E6-5262-4054-B72D-3A8DBBA057D2}.Release|Any CPU.ActiveCfg = Release|Any CPU {1B7920E6-5262-4054-B72D-3A8DBBA057D2}.Release|Any CPU.Build.0 = Release|Any CPU - {298009D3-971D-4375-A2F2-04CFB168CED9}.Debug - NuGet Packages|Any CPU.ActiveCfg = Debug|Any CPU - {298009D3-971D-4375-A2F2-04CFB168CED9}.Debug - NuGet Packages|Any CPU.Build.0 = Debug|Any CPU - {298009D3-971D-4375-A2F2-04CFB168CED9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {298009D3-971D-4375-A2F2-04CFB168CED9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {298009D3-971D-4375-A2F2-04CFB168CED9}.Documentation|Any CPU.ActiveCfg = Debug|Any CPU - {298009D3-971D-4375-A2F2-04CFB168CED9}.Documentation|Any CPU.Build.0 = Debug|Any CPU - {298009D3-971D-4375-A2F2-04CFB168CED9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {298009D3-971D-4375-A2F2-04CFB168CED9}.Release|Any CPU.Build.0 = Release|Any CPU {8FC920C6-E895-4A17-AB2F-452FAAA36CC8}.Debug - NuGet Packages|Any CPU.ActiveCfg = Debug|Any CPU {8FC920C6-E895-4A17-AB2F-452FAAA36CC8}.Debug - NuGet Packages|Any CPU.Build.0 = Debug|Any CPU {8FC920C6-E895-4A17-AB2F-452FAAA36CC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU @@ -329,6 +311,14 @@ Global {D790A4BB-D8AC-4AAE-B3FE-0CF432CA8031}.Documentation|Any CPU.Build.0 = Debug|Any CPU {D790A4BB-D8AC-4AAE-B3FE-0CF432CA8031}.Release|Any CPU.ActiveCfg = Release|Any CPU {D790A4BB-D8AC-4AAE-B3FE-0CF432CA8031}.Release|Any CPU.Build.0 = Release|Any CPU + {C113E0AE-5564-4389-BA39-183A8D574210}.Debug - NuGet Packages|Any CPU.ActiveCfg = Debug|Any CPU + {C113E0AE-5564-4389-BA39-183A8D574210}.Debug - NuGet Packages|Any CPU.Build.0 = Debug|Any CPU + {C113E0AE-5564-4389-BA39-183A8D574210}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C113E0AE-5564-4389-BA39-183A8D574210}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C113E0AE-5564-4389-BA39-183A8D574210}.Documentation|Any CPU.ActiveCfg = Debug|Any CPU + {C113E0AE-5564-4389-BA39-183A8D574210}.Documentation|Any CPU.Build.0 = Debug|Any CPU + {C113E0AE-5564-4389-BA39-183A8D574210}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C113E0AE-5564-4389-BA39-183A8D574210}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -358,16 +348,15 @@ Global {2614D290-1345-4A41-BE90-F85F817CEADE} = {0A0E26B0-7A46-4F1A-8BFE-9A763FDF6CF8} {35F9B8A8-1974-4795-930B-5E4980EE85E5} = {AD743B78-D61F-4FBF-B620-FA83CE599A50} {71698D71-4C6F-40D5-8BDE-2587514CA21C} = {AD743B78-D61F-4FBF-B620-FA83CE599A50} - {F87B093D-A3AC-4125-A8A8-FE167F918FFF} = {AD743B78-D61F-4FBF-B620-FA83CE599A50} {0B8ABFDB-F9CF-4EC6-988E-9C32D9E01C26} = {4269F3C3-6B42-419B-B64A-3E6DC0F1574A} {1B7920E6-5262-4054-B72D-3A8DBBA057D2} = {AD743B78-D61F-4FBF-B620-FA83CE599A50} - {298009D3-971D-4375-A2F2-04CFB168CED9} = {AD743B78-D61F-4FBF-B620-FA83CE599A50} {8FC920C6-E895-4A17-AB2F-452FAAA36CC8} = {276EBE79-A13A-46BD-A566-B01DC0477A9B} {B609DB2C-5C1F-46D1-A0FA-A0FF9216899A} = {4269F3C3-6B42-419B-B64A-3E6DC0F1574A} {3F4A0DD8-4D47-4B9C-939A-3146E68C84F7} = {0A0E26B0-7A46-4F1A-8BFE-9A763FDF6CF8} {400BB78F-AFDC-4B1C-AD85-BE159B576FCE} = {276EBE79-A13A-46BD-A566-B01DC0477A9B} {873BCC1F-ED12-424E-93FA-D76F4BA022C2} = {0A0E26B0-7A46-4F1A-8BFE-9A763FDF6CF8} {D790A4BB-D8AC-4AAE-B3FE-0CF432CA8031} = {AD743B78-D61F-4FBF-B620-FA83CE599A50} + {C113E0AE-5564-4389-BA39-183A8D574210} = {AD743B78-D61F-4FBF-B620-FA83CE599A50} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {7173C9F3-A7F9-496E-9078-9156E35D6E16} diff --git a/tests/Microsoft.Bot.Builder.TestBot.WebApi/App_Start/BotConfig.cs b/tests/Microsoft.Bot.Builder.TestBot.WebApi/App_Start/BotConfig.cs deleted file mode 100644 index 1769cd3a47..0000000000 --- a/tests/Microsoft.Bot.Builder.TestBot.WebApi/App_Start/BotConfig.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System.Web.Http; -using Microsoft.Bot.Builder.Integration.AspNet.WebApi; - -namespace Microsoft.Bot.Builder.TestBot.WebApi -{ - public static class BotConfig - { - public static void Register(HttpConfiguration config) - { - config.MapBotFramework(botConfig => - { - botConfig.UseMicrosoftApplicationIdentity(null, null); - - // Uncomment these lines to debug with state - - //// The Memory Storage used here is for local bot debugging only. When the bot - //// is restarted, everything stored in memory will be gone. - //IStorage dataStore = new MemoryStorage(); - - //// Create Conversation State object. - //// The Conversation State object is where we persist anything at the conversation-scope. - //var conversationState = new ConversationState(dataStore); - //botConfig.BotFrameworkOptions.State.Add(conversationState); - - //// Create the custom state accessor. - //// State accessors enable other components to read and write individual properties of state. - //var accessors = new EchoBotAccessors(conversationState) - //{ - // CounterState = conversationState.CreateProperty(EchoBotAccessors.CounterStateName), - //}; - - //UnityConfig.Container.RegisterInstance(accessors, new ContainerControlledLifetimeManager()); - }); - } - } -} diff --git a/tests/Microsoft.Bot.Builder.TestBot.WebApi/App_Start/UnityConfig.cs b/tests/Microsoft.Bot.Builder.TestBot.WebApi/App_Start/UnityConfig.cs deleted file mode 100644 index 6f83547eb7..0000000000 --- a/tests/Microsoft.Bot.Builder.TestBot.WebApi/App_Start/UnityConfig.cs +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using Microsoft.Bot.Builder.Integration; -using Unity; - -namespace Microsoft.Bot.Builder.TestBot.WebApi -{ - /// - /// Specifies the Unity configuration for the main container. - /// - public static class UnityConfig - { - #region Unity Container - private static Lazy container = - new Lazy(() => - { - var container = new UnityContainer(); - RegisterTypes(container); - return container; - }); - - /// - /// Configured Unity Container. - /// - public static IUnityContainer Container => container.Value; - #endregion - - /// - /// Registers the type mappings with the Unity container. - /// - /// The unity container to configure. - /// - /// There is no need to register concrete types such as controllers or - /// API controllers (unless you want to change the defaults), as Unity - /// allows resolving a concrete type even if it was not previously - /// registered. - /// - public static void RegisterTypes(IUnityContainer container) - { - // NOTE: To load from web.config uncomment the line below. - // Make sure to add a Unity.Configuration to the using statements. - // container.LoadConfiguration(); - - // TODO: Register your type's mappings here. - // container.RegisterType(); - - var options = new BotFrameworkOptions(); - - options.Middleware.Add(new ShowTypingMiddleware()); - - var botFrameworkAdapter = new BotFrameworkAdapter(options.CredentialProvider) - { - OnTurnError = options.OnTurnError, - }; - - foreach (var middleware in options.Middleware) - { - botFrameworkAdapter.Use(middleware); - } - - //return botFrameworkAdapter; - - var adapter = new InteceptorAdapter(botFrameworkAdapter); - - container.RegisterInstance(adapter); - - container.RegisterType(); - } - } -} diff --git a/tests/Microsoft.Bot.Builder.TestBot.WebApi/App_Start/UnityWebApiActivator.cs b/tests/Microsoft.Bot.Builder.TestBot.WebApi/App_Start/UnityWebApiActivator.cs deleted file mode 100644 index 9c3565f919..0000000000 --- a/tests/Microsoft.Bot.Builder.TestBot.WebApi/App_Start/UnityWebApiActivator.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Web.Http; - -using Unity.AspNet.WebApi; - -[assembly: WebActivatorEx.PreApplicationStartMethod(typeof(Microsoft.Bot.Builder.TestBot.WebApi.UnityWebApiActivator), nameof(Microsoft.Bot.Builder.TestBot.WebApi.UnityWebApiActivator.Start))] -[assembly: WebActivatorEx.ApplicationShutdownMethod(typeof(Microsoft.Bot.Builder.TestBot.WebApi.UnityWebApiActivator), nameof(Microsoft.Bot.Builder.TestBot.WebApi.UnityWebApiActivator.Shutdown))] - -namespace Microsoft.Bot.Builder.TestBot.WebApi -{ - /// - /// Provides the bootstrapping for integrating Unity with WebApi when it is hosted in ASP.NET. - /// - public static class UnityWebApiActivator - { - /// - /// Integrates Unity when the application starts. - /// - public static void Start() - { - // Use UnityHierarchicalDependencyResolver if you want to use - // a new child container for each IHttpController resolution. - // var resolver = new UnityHierarchicalDependencyResolver(UnityConfig.Container); - var resolver = new UnityDependencyResolver(UnityConfig.Container); - - GlobalConfiguration.Configuration.DependencyResolver = resolver; - } - - /// - /// Disposes the Unity container when the application is shut down. - /// - public static void Shutdown() - { - UnityConfig.Container.Dispose(); - } - } -} \ No newline at end of file diff --git a/tests/Microsoft.Bot.Builder.TestBot.WebApi/Global.asax b/tests/Microsoft.Bot.Builder.TestBot.WebApi/Global.asax deleted file mode 100644 index d5ba769d59..0000000000 --- a/tests/Microsoft.Bot.Builder.TestBot.WebApi/Global.asax +++ /dev/null @@ -1 +0,0 @@ -<%@ Application Codebehind="Global.asax.cs" Inherits="Microsoft.Bot.Builder.TestBot.WebApi.WebApiApplication" Language="C#" %> diff --git a/tests/Microsoft.Bot.Builder.TestBot.WebApi/Global.asax.cs b/tests/Microsoft.Bot.Builder.TestBot.WebApi/Global.asax.cs deleted file mode 100644 index bdad9e2a4f..0000000000 --- a/tests/Microsoft.Bot.Builder.TestBot.WebApi/Global.asax.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System.Web.Http; - -namespace Microsoft.Bot.Builder.TestBot.WebApi -{ - public class WebApiApplication : System.Web.HttpApplication - { - protected void Application_Start() - { - GlobalConfiguration.Configure(config => - { - BotConfig.Register(config); - }); - } - } -} diff --git a/tests/Microsoft.Bot.Builder.TestBot.WebApi/InteceptorAdapter.cs b/tests/Microsoft.Bot.Builder.TestBot.WebApi/InteceptorAdapter.cs deleted file mode 100644 index 20f48588e3..0000000000 --- a/tests/Microsoft.Bot.Builder.TestBot.WebApi/InteceptorAdapter.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Bot.Builder.Integration; -using Microsoft.Bot.Schema; - -namespace Microsoft.Bot.Builder.TestBot.WebApi -{ - public class InteceptorAdapter : IAdapterIntegration - { - private IAdapterIntegration _innerAdapter; - - public InteceptorAdapter(IAdapterIntegration innerAdapter) - { - _innerAdapter = innerAdapter; - } - - public Task ContinueConversationAsync(string botId, ConversationReference reference, BotCallbackHandler callback, CancellationToken cancellationToken = default(CancellationToken)) - { - return _innerAdapter.ContinueConversationAsync(botId, reference, callback, cancellationToken); - } - - public Task ProcessActivityAsync(string authHeader, Activity activity, BotCallbackHandler callback, CancellationToken cancellationToken) - { - return _innerAdapter.ProcessActivityAsync(authHeader, activity, callback, cancellationToken); - } - } -} diff --git a/tests/Microsoft.Bot.Builder.TestBot.WebApi/Microsoft.Bot.Builder.TestBot.WebApi.csproj b/tests/Microsoft.Bot.Builder.TestBot.WebApi/Microsoft.Bot.Builder.TestBot.WebApi.csproj deleted file mode 100644 index 512a18f5c7..0000000000 --- a/tests/Microsoft.Bot.Builder.TestBot.WebApi/Microsoft.Bot.Builder.TestBot.WebApi.csproj +++ /dev/null @@ -1,195 +0,0 @@ - - - - - - Debug - AnyCPU - - - 2.0 - {298009D3-971D-4375-A2F2-04CFB168CED9} - {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} - Library - Properties - Microsoft.Bot.Builder.TestBot.WebApi - Microsoft.Bot.Builder.TestBot.WebApi - v4.6.1 - true - - - - - - - - - - - - true - full - false - bin\ - DEBUG;TRACE - prompt - 4 - - - true - pdbonly - true - bin\ - TRACE - prompt - 4 - - - - - ..\..\packages\Microsoft.Extensions.Logging.Abstractions.2.1.1\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll - - - ..\..\packages\Microsoft.Rest.ClientRuntime.2.3.13\lib\net452\Microsoft.Rest.ClientRuntime.dll - - - ..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll - - - ..\..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll - - - - - ..\..\packages\Microsoft.AspNet.WebApi.Client.5.2.6\lib\net45\System.Net.Http.Formatting.dll - - - - - - - - - - - - ..\..\packages\Microsoft.AspNet.WebApi.Core.5.2.6\lib\net45\System.Web.Http.dll - - - ..\..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.6\lib\net45\System.Web.Http.WebHost.dll - - - - - - - - - ..\..\packages\Unity.Abstractions.3.3.1\lib\net46\Unity.Abstractions.dll - - - ..\..\packages\Unity.AspNet.WebApi.5.0.15\lib\net46\Unity.AspNet.WebApi.dll - - - ..\..\packages\Unity.Container.5.8.10\lib\net46\Unity.Container.dll - - - ..\..\packages\WebActivatorEx.2.2.0\lib\net40\WebActivatorEx.dll - - - - - ..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll - - - - - - - - - - - - Global.asax - - - - - - - - - Web.config - - - Web.config - - - - - - - - - - {bd0b82ef-1601-4e87-b78a-b43de7eb36b0} - Microsoft.Bot.Builder.Integration.AspNet.WebApi - - - {0f639eb4-fb64-4909-8a10-fb93e7be3afb} - Microsoft.Bot.Builder.Dialogs - - - {ada8ab8b-2066-4193-b8f7-985669b23e00} - Microsoft.Bot.Builder - - - {6462da5d-27dc-4cd5-9467-5efb998fd838} - Microsoft.Bot.Connector - - - {c1f54cdc-ad1d-45bb-8f7d-f49e411afaf1} - Microsoft.Bot.Schema - - - - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - - - - - - True - True - 14972 - / - http://localhost:11034/ - False - False - - - False - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - \ No newline at end of file diff --git a/tests/Microsoft.Bot.Builder.TestBot.WebApi/Properties/AssemblyInfo.cs b/tests/Microsoft.Bot.Builder.TestBot.WebApi/Properties/AssemblyInfo.cs deleted file mode 100644 index 85da9e28c4..0000000000 --- a/tests/Microsoft.Bot.Builder.TestBot.WebApi/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Microsoft.Bot.Builder.TestBot.WebApi")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Microsoft.Bot.Builder.TestBot.WebApi")] -[assembly: AssemblyCopyright("Copyright © 2018")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("298009d3-971d-4375-a2f2-04cfb168ced9")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/tests/Microsoft.Bot.Builder.TestBot.WebApi/TestBot.cs b/tests/Microsoft.Bot.Builder.TestBot.WebApi/TestBot.cs deleted file mode 100644 index 1f13b02afe..0000000000 --- a/tests/Microsoft.Bot.Builder.TestBot.WebApi/TestBot.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Bot.Schema; - -namespace Microsoft.Bot.Builder.TestBot.WebApi -{ - public class TestBot : IBot - { - public async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default(CancellationToken)) - { - if (turnContext.Activity.Type == ActivityTypes.Message) - { - await turnContext.SendActivityAsync(MessageFactory.Text("hi")); - } - } - } -} diff --git a/tests/Microsoft.Bot.Builder.TestBot.WebApi/Web.Debug.config b/tests/Microsoft.Bot.Builder.TestBot.WebApi/Web.Debug.config deleted file mode 100644 index fae9cfefa9..0000000000 --- a/tests/Microsoft.Bot.Builder.TestBot.WebApi/Web.Debug.config +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/tests/Microsoft.Bot.Builder.TestBot.WebApi/Web.Release.config b/tests/Microsoft.Bot.Builder.TestBot.WebApi/Web.Release.config deleted file mode 100644 index da6e960b8d..0000000000 --- a/tests/Microsoft.Bot.Builder.TestBot.WebApi/Web.Release.config +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/tests/Microsoft.Bot.Builder.TestBot.WebApi/Web.config b/tests/Microsoft.Bot.Builder.TestBot.WebApi/Web.config deleted file mode 100644 index 95f53fedcd..0000000000 --- a/tests/Microsoft.Bot.Builder.TestBot.WebApi/Web.config +++ /dev/null @@ -1,274 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/tests/Microsoft.Bot.Builder.TestBot.WebApi/packages.config b/tests/Microsoft.Bot.Builder.TestBot.WebApi/packages.config deleted file mode 100644 index 9ea311eadc..0000000000 --- a/tests/Microsoft.Bot.Builder.TestBot.WebApi/packages.config +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/tests/Microsoft.Bot.Builder.TestBot/BotBuilderTestBot.bot b/tests/Microsoft.Bot.Builder.TestBot/BotBuilderTestBot.bot deleted file mode 100644 index cfa16be4c4..0000000000 --- a/tests/Microsoft.Bot.Builder.TestBot/BotBuilderTestBot.bot +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "BotBuilderTestBot", - "description": "", - "secretKey": "", - "services": [ - { - "appId": "", - "id": "98fd9150-a278-11e8-90fe-f92f88ed2f78", - "type": "endpoint", - "appPassword": "", - "endpoint": "http://localhost:51135/api/messages", - "name": "http://localhost:51135/api/messages" - } - ] -} diff --git a/tests/Microsoft.Bot.Builder.TestBot/Bots/MyBot.cs b/tests/Microsoft.Bot.Builder.TestBot/Bots/MyBot.cs new file mode 100644 index 0000000000..0ecfec74db --- /dev/null +++ b/tests/Microsoft.Bot.Builder.TestBot/Bots/MyBot.cs @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Bot.Schema; + +namespace Microsoft.Bot.Builder.TestBot.Bots +{ + public class MyBot : ActivityHandler + { + protected override async Task OnMessageActivityAsync(ITurnContext turnContext, CancellationToken cancellationToken) + { + await turnContext.SendActivityAsync(MessageFactory.Text($"Echo: {turnContext.Activity.Text}"), cancellationToken); + } + } +} diff --git a/tests/Microsoft.Bot.Builder.TestBot/Controllers/BotController.cs b/tests/Microsoft.Bot.Builder.TestBot/Controllers/BotController.cs new file mode 100644 index 0000000000..631fa3d5e3 --- /dev/null +++ b/tests/Microsoft.Bot.Builder.TestBot/Controllers/BotController.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Bot.Builder.Integration.AspNet.Core; + +namespace Microsoft.Bot.Builder.TestBot.Controllers +{ + [Route("bot")] + [ApiController] + public class BotController : ControllerBase + { + private IBotFrameworkHttpAdapter _adapter; + private IBot _bot; + + public BotController(IBotFrameworkHttpAdapter adapter, IBot bot) + { + _adapter = adapter; + _bot = bot; + } + + [HttpPost] + public async Task PostAsync() + { + await _adapter.ProcessAsync(Request, Response, _bot); + } + } +} diff --git a/tests/Microsoft.Bot.Builder.TestBot/InteceptorAdapter.cs b/tests/Microsoft.Bot.Builder.TestBot/InteceptorAdapter.cs deleted file mode 100644 index e40deacb3c..0000000000 --- a/tests/Microsoft.Bot.Builder.TestBot/InteceptorAdapter.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Bot.Builder.Integration; -using Microsoft.Bot.Schema; - -namespace Microsoft.Bot.Builder.TestBot -{ - public class InteceptorAdapter : IAdapterIntegration - { - private IAdapterIntegration _innerAdapter; - - public InteceptorAdapter(IAdapterIntegration innerAdapter) - { - _innerAdapter = innerAdapter; - } - - public Task ContinueConversationAsync(string botId, ConversationReference reference, BotCallbackHandler callback, CancellationToken cancellationToken = default(CancellationToken)) - { - return _innerAdapter.ContinueConversationAsync(botId, reference, callback, cancellationToken); - } - - public Task ProcessActivityAsync(string authHeader, Activity activity, BotCallbackHandler callback, CancellationToken cancellationToken) - { - return _innerAdapter.ProcessActivityAsync(authHeader, activity, callback, cancellationToken); - } - - - } -} diff --git a/tests/Microsoft.Bot.Builder.TestBot/Microsoft.Bot.Builder.TestBot.csproj b/tests/Microsoft.Bot.Builder.TestBot/Microsoft.Bot.Builder.TestBot.csproj index 3cae49b2f5..e87764305f 100644 --- a/tests/Microsoft.Bot.Builder.TestBot/Microsoft.Bot.Builder.TestBot.csproj +++ b/tests/Microsoft.Bot.Builder.TestBot/Microsoft.Bot.Builder.TestBot.csproj @@ -1,21 +1,18 @@ - + + netcoreapp2.1 - false - false + f277272c-9113-411f-addd-a4acfa9701a2 - - - - - + + + - - + diff --git a/tests/Microsoft.Bot.Builder.TestBot/Program.cs b/tests/Microsoft.Bot.Builder.TestBot/Program.cs index f6bec71ee3..4f28f48b74 100644 --- a/tests/Microsoft.Bot.Builder.TestBot/Program.cs +++ b/tests/Microsoft.Bot.Builder.TestBot/Program.cs @@ -1,8 +1,12 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; namespace Microsoft.Bot.Builder.TestBot { @@ -10,12 +14,11 @@ public class Program { public static void Main(string[] args) { - BuildWebHost(args).Run(); + CreateWebHostBuilder(args).Build().Run(); } - public static IWebHost BuildWebHost(string[] args) => + public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) - .UseStartup() - .Build(); + .UseStartup(); } } diff --git a/tests/Microsoft.Bot.Builder.TestBot/Startup.cs b/tests/Microsoft.Bot.Builder.TestBot/Startup.cs index 793a923801..36d51e79df 100644 --- a/tests/Microsoft.Bot.Builder.TestBot/Startup.cs +++ b/tests/Microsoft.Bot.Builder.TestBot/Startup.cs @@ -1,32 +1,22 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System; -using System.Linq; -using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; -using Microsoft.Bot.Builder.Dialogs; -using Microsoft.Bot.Builder.Integration; +using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder.Integration.AspNet.Core; +using Microsoft.Bot.Builder.TestBot.Bots; +using Microsoft.Bot.Connector.Authentication; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Options; namespace Microsoft.Bot.Builder.TestBot { public class Startup { - public Startup(IHostingEnvironment env) + public Startup(IConfiguration configuration) { - var builder = new ConfigurationBuilder() - .SetBasePath(env.ContentRootPath) - .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) - .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) - .AddEnvironmentVariables(); - - Configuration = builder.Build(); + Configuration = configuration; } public IConfiguration Configuration { get; } @@ -34,60 +24,16 @@ public Startup(IHostingEnvironment env) // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - //services.AddSingleton(sp => - //{ - // var options = sp.GetRequiredService>().Value; - // var accessors = sp.GetRequiredService(); - - // options.Middleware.Add(new AutoSaveStateMiddleware(accessors.ConversationState)); - // options.Middleware.Add(new ShowTypingMiddleware()); - - // var botFrameworkAdapter = new BotFrameworkAdapter(options.CredentialProvider, options.ChannelProvider, options.ConnectorClientRetryPolicy, options.HttpClient) - // { - // OnTurnError = options.OnTurnError, - // }; - - // foreach (var middleware in options.Middleware) - // { - // botFrameworkAdapter.Use(middleware); - // } - - // //return botFrameworkAdapter; - - // return new InteceptorAdapter(botFrameworkAdapter); - //}); + services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); - IStorage dataStore = new MemoryStorage(); - var conversationState = new ConversationState(dataStore); + // Load the credentials from configuration and create the credential provider. + var appId = Configuration["BotFramework:AppId"]; + var password = Configuration["BotFramework:Password"]; + var credentialProvider = new SimpleCredentialProvider(appId, password); - var accessors = new TestBotAccessors - { - ConversationDialogState = conversationState.CreateProperty("DialogState"), - ConversationState = conversationState - }; - - services.AddBot( - (IServiceProvider sp) => - { - return new TestBot(accessors); - }, - (BotFrameworkOptions options) => - { - options.OnTurnError = async (turnContext, exception) => - { - await conversationState.ClearStateAsync(turnContext); - await conversationState.SaveChangesAsync(turnContext); - }; - options.Middleware.Add(new AutoSaveStateMiddleware(conversationState)); - }); - - //services.AddBot(options => - //{ - // IStorage dataStore = new MemoryStorage(); - // options.State.Add(new ConversationState(dataStore)); - // options.Middleware.Add(new AutoSaveStateMiddleware(options.State.ToArray())); - // options.Middleware.Add(new ShowTypingMiddleware()); - //}); + // Add the Adapter as a singleton and in this example the Bot as transient. + services.AddSingleton(sp => new BotFrameworkHttpAdapter(credentialProvider)); + services.AddTransient(sp => new MyBot()); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. @@ -97,18 +43,16 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.UseDeveloperExceptionPage(); } + else + { + app.UseHsts(); + } - // NOTE: Uncomment this to force request buffering to test accessing the request body in buffered scenarios (default is always unbuffered) - //app.Use(async (httpContext, next) => - //{ - // httpContext.Request.EnableBuffering(); - - // await next(); - //}); + app.UseDefaultFiles(); + app.UseStaticFiles(); - app.UseDefaultFiles() - .UseStaticFiles() - .UseBotFramework(); + //app.UseHttpsRedirection(); + app.UseMvc(); } } } diff --git a/tests/Microsoft.Bot.Builder.TestBot/TestBot.cs b/tests/Microsoft.Bot.Builder.TestBot/TestBot.cs deleted file mode 100644 index 855a752008..0000000000 --- a/tests/Microsoft.Bot.Builder.TestBot/TestBot.cs +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Bot.Builder.Dialogs; -using Microsoft.Bot.Schema; -using Microsoft.Recognizers.Text; - -namespace Microsoft.Bot.Builder.TestBot -{ - public class TestBot : IBot - { - private DialogSet _dialogs; - private SemaphoreSlim _semaphore; - - public TestBot(TestBotAccessors accessors) - { - // create the DialogSet from accessor - _dialogs = new DialogSet(accessors.ConversationDialogState); - - // a semaphore to serialize access to the bot state - _semaphore = accessors.SemaphoreSlim; - - // add the various named dialogs that can be used - _dialogs.Add(CreateWaterfall()); - _dialogs.Add(new NumberPrompt("number", defaultLocale: Culture.English)); - } - - public async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default(CancellationToken)) - { - // We only want to pump one activity at a time through the state. - // Note the state is shared across all instances of this IBot class so we - // create the semaphore globally with the accessors. - try - { - await _semaphore.WaitAsync(); - - if (turnContext.Activity.Type == ActivityTypes.Message && turnContext.Activity.Text == "throw") - { - throw new Exception("oh dear"); - } - - // run the DialogSet - let the framework identify the current state of the dialog from - // the dialog stack and figure out what (if any) is the active dialog - var dialogContext = await _dialogs.CreateContextAsync(turnContext, cancellationToken); - var results = await dialogContext.ContinueDialogAsync(cancellationToken); - - // HasActive = true if there is an active dialog on the dialogstack - // HasResults = true if the dialog just completed and the final result can be retrived - // if both are false this indicates a new dialog needs to start - // an additional check for Responded stops a new waterfall from being automatically started over - if (results.Status == DialogTurnStatus.Empty) - { - await dialogContext.BeginDialogAsync("test-waterfall", null, cancellationToken); - } - } - finally - { - _semaphore.Release(); - } - } - - private static WaterfallDialog CreateWaterfall() - { - return new WaterfallDialog("test-waterfall", new WaterfallStep[] { - WaterfallStep1, - WaterfallStep2, - WaterfallStep3 - }); - } - - private static async Task WaterfallStep1(WaterfallStepContext stepContext, CancellationToken cancellationToken) - { - // we are only interested in Message activities - any other type of activity we will immediately complete teh waterfall - if (stepContext.Context.Activity.Type != ActivityTypes.Message) - { - return await stepContext.EndDialogAsync(cancellationToken); - } - - // this prompt will not continue until we receive a number - return await stepContext.PromptAsync("number", new PromptOptions { Prompt = MessageFactory.Text("Enter a number.") }, cancellationToken); - } - private static async Task WaterfallStep2(WaterfallStepContext stepContext, CancellationToken cancellationToken) - { - // step context represents values from previous (waterfall) step - in this case the first number - if (stepContext.Values != null) - { - var numberResult = (int)stepContext.Result; - - if (numberResult == 0) - { - throw new Exception("zero is not a number"); - } - - await stepContext.Context.SendActivityAsync(MessageFactory.Text($"Thanks for '{numberResult}'"), cancellationToken); - } - return await stepContext.PromptAsync("number", new PromptOptions { Prompt = MessageFactory.Text("Enter another number.") }, cancellationToken); - } - private static async Task WaterfallStep3(WaterfallStepContext stepContext, CancellationToken cancellationToken) - { - var value = (int)stepContext.Result; - await stepContext.Context.SendActivityAsync(MessageFactory.Text($"Bot received the number '{value}'."), cancellationToken); - return await stepContext.EndDialogAsync(cancellationToken); - } - } -} diff --git a/tests/Microsoft.Bot.Builder.TestBot/TestBotAccessors.cs b/tests/Microsoft.Bot.Builder.TestBot/TestBotAccessors.cs deleted file mode 100644 index 5e9d2d8852..0000000000 --- a/tests/Microsoft.Bot.Builder.TestBot/TestBotAccessors.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System.Threading; -using Microsoft.Bot.Builder.Dialogs; - -namespace Microsoft.Bot.Builder.TestBot -{ - public class TestBotAccessors - { - public IStatePropertyAccessor ConversationDialogState { get; set; } - - public ConversationState ConversationState { get; set; } - - public SemaphoreSlim SemaphoreSlim { get; } = new SemaphoreSlim(1, 1); - } -} diff --git a/tests/Microsoft.Bot.Builder.TestBot/appsettings.Development.json b/tests/Microsoft.Bot.Builder.TestBot/appsettings.Development.json index fa8ce71a97..e203e9407e 100644 --- a/tests/Microsoft.Bot.Builder.TestBot/appsettings.Development.json +++ b/tests/Microsoft.Bot.Builder.TestBot/appsettings.Development.json @@ -1,6 +1,5 @@ -{ +{ "Logging": { - "IncludeScopes": false, "LogLevel": { "Default": "Debug", "System": "Information", diff --git a/tests/Microsoft.Bot.Builder.TestBot/appsettings.json b/tests/Microsoft.Bot.Builder.TestBot/appsettings.json index 26bb0ac7ac..def9159a7d 100644 --- a/tests/Microsoft.Bot.Builder.TestBot/appsettings.json +++ b/tests/Microsoft.Bot.Builder.TestBot/appsettings.json @@ -1,15 +1,8 @@ -{ +{ "Logging": { - "IncludeScopes": false, - "Debug": { - "LogLevel": { - "Default": "Warning" - } - }, - "Console": { - "LogLevel": { - "Default": "Warning" - } + "LogLevel": { + "Default": "Warning" } - } + }, + "AllowedHosts": "*" } diff --git a/tests/Microsoft.Bot.Builder.TestBot/wwwroot/default.htm b/tests/Microsoft.Bot.Builder.TestBot/wwwroot/default.htm deleted file mode 100644 index 49d980b21a..0000000000 --- a/tests/Microsoft.Bot.Builder.TestBot/wwwroot/default.htm +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - -

TestBot using ASP.Net Core 2

-

Describe your bot here and your terms of use etc.

-

To debug you bot using the Bot Framework Emulator, paste this URL into the Emulator window:

-
- - - \ No newline at end of file diff --git a/tests/Microsoft.Bot.Builder.TestBot/wwwroot/default.html b/tests/Microsoft.Bot.Builder.TestBot/wwwroot/default.html new file mode 100644 index 0000000000..252bce17ae --- /dev/null +++ b/tests/Microsoft.Bot.Builder.TestBot/wwwroot/default.html @@ -0,0 +1,10 @@ + + + + + TestBot Home Page + + + Hello and welcome to TestBot. + + \ No newline at end of file