public virtual void InitializeSkill() { Services = new ServiceCollection(); Services.AddSingleton(new BotSettings()); Services.AddSingleton(new BotServices() { CognitiveModelSets = new Dictionary <string, CognitiveModelSet> { { "en-us", new CognitiveModelSet { LuisServices = new Dictionary <string, LuisRecognizer> { { "General", GeneralTestUtil.CreateRecognizer() }, { "$ext_safeprojectname$", SkillTestUtil.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)); }); 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); } TemplateEngine = new LocaleTemplateManager(localizedTemplates, "en-us"); Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-us"); Services.AddSingleton(TemplateEngine); Services.AddTransient <MainDialog>(); Services.AddTransient <SampleDialog>(); Services.AddTransient <SampleAction>(); Services.AddSingleton <TestAdapter, DefaultTestAdapter>(); Services.AddTransient <IBot, DefaultActivityHandler <MainDialog> >(); }
public override void Initialize() { var builder = new ContainerBuilder(); ConversationState = new ConversationState(new MemoryStorage()); UserState = new UserState(new MemoryStorage()); TelemetryClient = new NullBotTelemetryClient(); Services = new MockSkillConfiguration(); Services.LocaleConfigurations.Add("en", new LocaleConfiguration() { Locale = "en-us", LuisServices = new Dictionary <string, ITelemetryLuisRecognizer> { { "general", GeneralTestUtil.CreateRecognizer() },
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 <List <SkillDialog> >(); Services.AddSingleton <TestAdapter, DefaultTestAdapter>(); Services.AddTransient <IBot, DialogBot <MainDialog> >(); }
public virtual void InitializeSkill() { Services = new ServiceCollection(); Services.AddSingleton(new BotSettings()); Services.AddSingleton(new BotServices() { CognitiveModelSets = new Dictionary <string, CognitiveModelSet> { { "en", new CognitiveModelSet { LuisServices = new Dictionary <string, ITelemetryRecognizer> { { "General", GeneralTestUtil.CreateRecognizer() }, { "$ext_safeprojectname$", SkillTestUtil.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)); }); ResponseManager = new ResponseManager( new string[] { "en", "de", "es", "fr", "it", "zh" }, new MainResponses(), new SharedResponses(), new SampleResponses()); Services.AddSingleton(ResponseManager); Services.AddTransient <MainDialog>(); Services.AddTransient <SampleDialog>(); 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().AddLogging(config => config.AddConsole()); 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> >(); // Add MicrosoftAPPId to configuration var configuration = new Mock <IConfiguration>(); var configurationSection = new Mock <IConfigurationSection>(); configurationSection.Setup(a => a.Value).Returns("testvalue"); configuration.Setup(a => a.GetSection("MicrosoftAppId")).Returns(configurationSection.Object); // Register configuration Services.AddSingleton(configuration.Object); TestUserProfileState = new UserProfileState(); TestUserProfileState.Name = "Bot"; }
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"; }