public virtual void Initialize() { Services = new ServiceCollection(); Services.AddSingleton(new BotSettings()); Services.AddSingleton(new BotServices() { CognitiveModelSets = new Dictionary <string, CognitiveModelSet> { { "en", new CognitiveModelSet { DispatchService = DispatchTestUtil.CreateRecognizer(), LuisServices = new Dictionary <string, ITelemetryRecognizer> { { "General", GeneralTestUtil.CreateRecognizer() } }, QnAServices = new Dictionary <string, ITelemetryQnAMaker> { { "Faq", FaqTestUtil.CreateRecognizer() }, { "Chitchat", ChitchatTestUtil.CreateRecognizer() } } } } } }); Services.AddSingleton <IBotTelemetryClient, NullBotTelemetryClient>(); Services.AddSingleton(new MicrosoftAppCredentials("appId", "password")); Services.AddSingleton(new UserState(new MemoryStorage())); Services.AddSingleton(new ConversationState(new MemoryStorage())); Services.AddSingleton(sp => { var userState = sp.GetService <UserState>(); var conversationState = sp.GetService <ConversationState>(); return(new BotStateSet(userState, conversationState)); }); Services.AddTransient <CancelDialog>(); Services.AddTransient <EscalateDialog>(); Services.AddTransient <MainDialog>(); Services.AddTransient <OnboardingDialog>(); Services.AddTransient <CheckoutDialog>(); Services.AddTransient <List <SkillDialog> >(); Services.AddSingleton <TestAdapter, DefaultTestAdapter>(); Services.AddTransient <IBot, DialogBot <MainDialog> >(); }
public virtual void Initialize() { var builder = new ContainerBuilder(); ConversationState = new ConversationState(new MemoryStorage()); UserState = new UserState(new MemoryStorage()); TelemetryClient = new NullBotTelemetryClient(); BotServices = new BotServices() { DispatchRecognizer = DispatchTestUtil.CreateRecognizer(), LuisServices = new Dictionary <string, ITelemetryLuisRecognizer> { { "general", GeneralTestUtil.CreateRecognizer() } }, QnAServices = new Dictionary <string, ITelemetryQnAMaker> { { "faq", FaqTestUtil.CreateRecognizer() }, { "chitchat", ChitchatTestUtil.CreateRecognizer() } } }; builder.RegisterInstance(new BotStateSet(UserState, ConversationState)); Container = builder.Build(); }
public virtual void Initialize() { Services = new ServiceCollection(); Services.AddSingleton(new BotSettings()); Services.AddSingleton(new BotServices() { // Non US languages are empty as Dispatch/LUIS not required for localization tests. CognitiveModelSets = new Dictionary <string, CognitiveModelSet> { { "en-us", new CognitiveModelSet { DispatchService = DispatchTestUtil.CreateRecognizer(), LuisServices = new Dictionary <string, LuisRecognizer> { { "General", GeneralTestUtil.CreateRecognizer() } }, QnAConfiguration = new Dictionary <string, Microsoft.Bot.Builder.AI.QnA.QnAMakerEndpoint> { { "Chitchat", new QnAMakerEndpoint { KnowledgeBaseId = _knowledgeBaseId, EndpointKey = _endpointKey, Host = _hostname } } } } }, { "zh-cn", new CognitiveModelSet { } }, { "fr-fr", new CognitiveModelSet { } }, { "es-es", new CognitiveModelSet { } }, { "de-de", new CognitiveModelSet { } }, { "it-it", new CognitiveModelSet { } } } }); Services.AddSingleton <IBotTelemetryClient, NullBotTelemetryClient>(); Services.AddSingleton(new MicrosoftAppCredentials("appId", "password")); Services.AddSingleton(new UserState(new MemoryStorage())); Services.AddSingleton(new ConversationState(new MemoryStorage())); // For localization testing CultureInfo.CurrentUICulture = new CultureInfo("en-us"); var localizedTemplates = new Dictionary <string, string>(); var templateFile = "AllResponses"; var supportedLocales = new List <string>() { "en-us", "de-de", "es-es", "fr-fr", "it-it", "zh-cn" }; foreach (var locale in supportedLocales) { // LG template for en-us does not include locale in file extension. var localeTemplateFile = locale.Equals("en-us") ? Path.Combine(".", "Responses", $"{templateFile}.lg") : Path.Combine(".", "Responses", $"{templateFile}.{locale}.lg"); localizedTemplates.Add(locale, localeTemplateFile); } TestLocaleTemplateManager = new LocaleTemplateManager(localizedTemplates, "en-us"); Services.AddSingleton(TestLocaleTemplateManager); Services.AddTransient <MockMainDialog>(); Services.AddTransient <OnboardingDialog>(); Services.AddTransient <SwitchSkillDialog>(); Services.AddTransient <List <SkillDialog> >(); Services.AddSingleton <TestAdapter, DefaultTestAdapter>(); Services.AddTransient <IBot, DefaultActivityHandler <MockMainDialog> >(); TestUserProfileState = new UserProfileState(); TestUserProfileState.Name = "Bot"; }
public new void Initialize() { var builder = new ContainerBuilder(); this.ConversationState = new ConversationState(new MemoryStorage()); this.DialogState = this.ConversationState.CreateProperty <DialogState>(nameof(this.DialogState)); this.UserState = new UserState(new MemoryStorage()); this.ProactiveState = new ProactiveState(new MemoryStorage()); this.TelemetryClient = new NullBotTelemetryClient(); this.BackgroundTaskQueue = new BackgroundTaskQueue(); this.EndPointService = new EndpointService(); builder.RegisterInstance(new BotStateSet(this.UserState, this.ConversationState)); this.Container = builder.Build(); ResponseManager = new ResponseManager( responseTemplates: new IResponseIdCollection[] { // todo: register response files new CommonResponses() }, locales: new string[] { "en", "de", "es", "fr", "it", "zh" }); // Initialize the Dispatch and Luis mocks this.BotServices = new BotServices(); this.BotServices.LocaleConfigurations.Add("en", new LocaleConfiguration() { Locale = "en-us", LuisServices = new Dictionary <string, ITelemetryLuisRecognizer> { { "general", LuisTestUtils.GeneralTestUtil.CreateRecognizer() }, { "calendar", LuisTestUtils.CalendarTestUtil.CreateRecognizer() }, { "email", LuisTestUtils.EmailTestUtil.CreateRecognizer() }, { "todo", LuisTestUtils.ToDoTestUtil.CreateRecognizer() }, { "pointofinterest", LuisTestUtils.PointOfInterestTestUtil.CreateRecognizer() } }, DispatchRecognizer = DispatchTestUtil.CreateRecognizer() }); // Dummy Authentication connection for Auth testing this.BotServices.AuthenticationConnections = new Dictionary <string, string> { { "DummyAuth", "DummyAuthConnection" } }; // Skill Registration // CalendarSkill InitialiseSkill( "calendarSkill", typeof(CalendarSkill.CalendarSkill), nameof(Luis.Dispatch.Intent.l_Calendar), new string[] { "general", "calendar" }, new string[] { "DummyAuth" }, this.BotServices.LocaleConfigurations, new string[] { "DummyAuth" }); // EmailSkill InitialiseSkill( "emailSkill", typeof(EmailSkill.EmailSkill), nameof(Luis.Dispatch.Intent.l_Email), new string[] { "general", "email" }, new string[] { "DummyAuth" }, this.BotServices.LocaleConfigurations, new string[] { "DummyAuth" }); // ToDo InitialiseSkill( "todoSkill", typeof(ToDoSkill.ToDoSkill), nameof(Luis.Dispatch.Intent.l_ToDo), new string[] { "general", "todo" }, new string[] { "DummyAuth" }, this.BotServices.LocaleConfigurations, new string[] { "DummyAuth" }); // ToDo InitialiseSkill( "pointOfInterestSkill", typeof(PointOfInterestSkill.PointOfInterestSkill), nameof(Luis.Dispatch.Intent.l_PointOfInterest), new string[] { "general", "pointofinterest" }, new string[] { "DummyAuth" }, this.BotServices.LocaleConfigurations); }
public virtual void Initialize() { Services = new ServiceCollection(); Services.AddSingleton(new BotSettings()); Services.AddSingleton(new BotServices() { // Non US languages are empty as Dispatch/LUIS not required for localization tests. CognitiveModelSets = new Dictionary <string, CognitiveModelSet> { { "en-us", new CognitiveModelSet { DispatchService = DispatchTestUtil.CreateRecognizer(), LuisServices = new Dictionary <string, LuisRecognizer> { { "General", GeneralTestUtil.CreateRecognizer() } }, } }, { "zh-cn", new CognitiveModelSet { } }, { "fr-fr", new CognitiveModelSet { } }, { "es-es", new CognitiveModelSet { } }, { "de-de", new CognitiveModelSet { } }, { "it-it", new CognitiveModelSet { } } } }); Services.AddSingleton <IBotTelemetryClient, NullBotTelemetryClient>(); Services.AddSingleton(new MicrosoftAppCredentials("appId", "password")); Services.AddSingleton(new UserState(new MemoryStorage())); Services.AddSingleton(new ConversationState(new MemoryStorage())); Services.AddSingleton(sp => { var userState = sp.GetService <UserState>(); var conversationState = sp.GetService <ConversationState>(); return(new BotStateSet(userState, conversationState)); }); // For localization testing CultureInfo.CurrentUICulture = new CultureInfo("en-us"); var localizedTemplates = new Dictionary <string, List <string> >(); var templateFiles = new List <string>() { "MainResponses", "OnboardingResponses" }; var supportedLocales = new List <string>() { "en-us", "de-de", "es-es", "fr-fr", "it-it", "zh-cn" }; foreach (var locale in supportedLocales) { var localeTemplateFiles = new List <string>(); foreach (var template in templateFiles) { // LG template for en-us does not include locale in file extension. if (locale.Equals("en-us")) { localeTemplateFiles.Add(Path.Combine(".", "Responses", $"{template}.lg")); } else { localeTemplateFiles.Add(Path.Combine(".", "Responses", $"{template}.{locale}.lg")); } } localizedTemplates.Add(locale, localeTemplateFiles); } LocaleTemplateEngine = new LocaleTemplateEngineManager(localizedTemplates, "en-us"); Services.AddSingleton(LocaleTemplateEngine); Services.AddTransient <MainDialog>(); Services.AddTransient <OnboardingDialog>(); Services.AddTransient <SwitchSkillDialog>(); Services.AddTransient <List <SkillDialog> >(); Services.AddSingleton <TestAdapter, DefaultTestAdapter>(); Services.AddTransient <IBot, DefaultActivityHandler <MainDialog> >(); TestUserProfileState = new UserProfileState(); TestUserProfileState.Name = "Bot"; }
public new void Initialize() { var builder = new ContainerBuilder(); this.ConversationState = new ConversationState(new MemoryStorage()); this.DialogState = this.ConversationState.CreateProperty <DialogState>(nameof(this.DialogState)); this.UserState = new UserState(new MemoryStorage()); this.ProactiveState = new ProactiveState(new MemoryStorage()); this.TelemetryClient = new NullBotTelemetryClient(); this.BackgroundTaskQueue = new BackgroundTaskQueue(); this.ImageAssetLocation = "https://localhost"; // Mock HttpContext for image path resolution MockHttpContext = new DefaultHttpContext(); MockHttpContext.Request.Scheme = "http"; MockHttpContext.Request.Host = new HostString("localhost", 3980); MockHttpContextAcessor = new HttpContextAccessor { HttpContext = MockHttpContext }; this.EndPointService = new EndpointService(); builder.RegisterInstance(new BotStateSet(this.UserState, this.ConversationState)); this.Container = builder.Build(); var locales = new string[] { "en", "de", "es", "fr", "it", "zh" }; ResponseManager = new ResponseManager(locales, new POISharedResponses(), new SkillResponses(), new AuthenticationResponses(), new MainDialogResponses()); // Initialize the Dispatch and Luis mocks this.BotServices = new BotServices(); this.BotServices.LocaleConfigurations.Add("en", new LocaleConfiguration() { Locale = "en-us", LuisServices = new Dictionary <string, ITelemetryLuisRecognizer> { { "general", LuisTestUtils.GeneralTestUtil.CreateRecognizer() }, { "calendar", LuisTestUtils.CalendarTestUtil.CreateRecognizer() }, { "email", LuisTestUtils.EmailTestUtil.CreateRecognizer() }, { "todo", LuisTestUtils.ToDoTestUtil.CreateRecognizer() }, { "pointofinterest", LuisTestUtils.PointOfInterestTestUtil.CreateRecognizer() } }, DispatchRecognizer = DispatchTestUtil.CreateRecognizer() }); // Dummy Authentication connection for Auth testing this.BotServices.AuthenticationConnections = new Dictionary <string, string> { { "DummyAuth", "DummyAuthConnection" } }; // Skill Registration // CalendarSkill InitialiseSkill( "calendarSkill", typeof(CalendarSkill.CalendarSkill), nameof(Luis.Dispatch.Intent.l_Calendar), new string[] { "general", "calendar" }, new string[] { "DummyAuth" }, this.BotServices.LocaleConfigurations, new string[] { "DummyAuth" }); // EmailSkill InitialiseSkill( "emailSkill", typeof(EmailSkill.EmailSkill), nameof(Luis.Dispatch.Intent.l_Email), new string[] { "general", "email" }, new string[] { "DummyAuth" }, this.BotServices.LocaleConfigurations, new string[] { "DummyAuth" }); // ToDo InitialiseSkill( "todoSkill", typeof(ToDoSkill.ToDoSkill), nameof(Luis.Dispatch.Intent.l_ToDo), new string[] { "general", "todo" }, new string[] { "DummyAuth" }, this.BotServices.LocaleConfigurations, new string[] { "DummyAuth" }); // ToDo InitialiseSkill( "pointOfInterestSkill", typeof(PointOfInterestSkill.PointOfInterestSkill), nameof(Luis.Dispatch.Intent.l_PointOfInterest), new string[] { "general", "pointofinterest" }, new string[] { "DummyAuth" }, this.BotServices.LocaleConfigurations); }