public StepHelperTests() : base(DialogId) { Services = new MockSkillConfiguration(); this.mockEmailStateAccessor = new MockEmailStateAccessor(); EmailStateAccessor = mockEmailStateAccessor.GetMock().Object; this.mockDialogStateAccessor = new MockDialogStateAccessor(); DialogStateAccessor = mockDialogStateAccessor.GetMock().Object; ServiceManager = new MockServiceManager(); }
public async Task Test_CalendarMultipleMeetings() { int eventCount = 3; this.ServiceManager = MockServiceManager.SetMeetingsToMultiple(eventCount); await this.GetTestFlow() .Send(string.Empty) .AssertReplyOneOf(GetTemplates(CalendarMainResponses.CalendarWelcomeMessage)) .Send(FindMeetingTestUtterances.BaseNextMeeting) .AssertReplyOneOf(this.NextMeetingPrompt()) .AssertReply(this.ShowCalendarList()) .StartTestAsync(); }
public async Task Test_CalendarCreateWithMultipleContacts() { var testDupRecipient = string.Format(Strings.Strings.UserName, 0); var testDupEmailAddress = string.Format(Strings.Strings.UserEmailAddress, 0); var testRecipient = Strings.Strings.DefaultUserName; var testEmailAddress = Strings.Strings.DefaultUserEmail; var recipientDict = new StringDictionary() { { "UserName", testRecipient }, { "EmailAddress", testEmailAddress } }; var recipientDupDict = new StringDictionary() { { "UserName", testDupRecipient }, { "EmailAddress", testDupEmailAddress } }; var peopleCount = 3; ServiceManager = MockServiceManager.SetPeopleToMultiple(peopleCount); await GetTestFlow() .Send(CreateMeetingTestUtterances.BaseCreateMeeting) .AssertReply(ShowAuth()) .Send(GetAuthResponse()) .AssertReplyOneOf(AskForParticpantsPrompt()) .Send(Strings.Strings.DefaultUserName) .AssertReply(ShowContactsList(recipientDict)) .Send(CreateMeetingTestUtterances.ChooseFirstUser) .AssertReplyOneOf(ConfirmOneNameOneAddress(recipientDupDict)) .Send(Strings.Strings.ConfirmYes) .AssertReplyOneOf(AddMoreUserPrompt(testDupRecipient, testDupEmailAddress)) .Send(Strings.Strings.ConfirmNo) .AssertReplyOneOf(AskForSubjectWithContactNamePrompt(string.Format(Strings.Strings.UserName, 0), testDupEmailAddress)) .Send(Strings.Strings.DefaultEventName) .AssertReplyOneOf(AskForContentPrompt()) .Send(Strings.Strings.DefaultContent) .AssertReplyOneOf(AskForDatePrompt()) .Send(Strings.Strings.DefaultStartDate) .AssertReplyOneOf(AskForStartTimePrompt()) .Send(Strings.Strings.DefaultStartTime) .AssertReplyOneOf(AskForDurationPrompt()) .Send(Strings.Strings.DefaultDuration) .AssertReplyOneOf(AskForLocationPrompt()) .Send(Strings.Strings.DefaultLocation) .AssertReply(ShowCalendarList()) .AssertReplyOneOf(ConfirmPrompt()) .Send(Strings.Strings.ConfirmYes) .AssertReply(ShowCalendarList()) .AssertReply(ActionEndMessage()) .StartTestAsync(); }
public async Task Test_CalendarNextMeetingTimeRemaining() { this.ServiceManager = MockServiceManager.SetMeetingsToSpecial(new List <EventModel>() { MockServiceManager.CreateEventModel(startDateTime: DateTime.UtcNow.AddDays(1)) }); await this.GetTestFlow() .Send(TimeRemainingUtterances.NextMeetingTimeRemaining) .AssertReply(this.ShowAuth()) .Send(this.GetAuthResponse()) .AssertReplyOneOf(this.ShowNextMeetingRemainingTime()) .AssertReply(this.ActionEndMessage()) .StartTestAsync(); }
public async Task Test_CalendarSummaryGetMultipleMeetings() { int eventCount = 3; this.ServiceManager = MockServiceManager.SetMeetingsToMultiple(eventCount); await this.GetTestFlow() .Send(string.Empty) .AssertReplyOneOf(GetTemplates(CalendarMainResponses.FirstPromptMessage)) .Send(FindMeetingTestUtterances.BaseFindMeeting) .AssertReplyOneOf(this.FoundMultipleEventPrompt(eventCount)) .AssertReplyOneOf(this.ReadOutMorePrompt()) .Send(Strings.Strings.ConfirmNo) .StartTestAsync(); }
public async Task Test_CalendarMultipleMeetings() { int eventCount = 3; this.ServiceManager = MockServiceManager.SetMeetingsToMultiple(eventCount); await this.GetTestFlow() .Send(FindMeetingTestUtterances.BaseNextMeeting) .AssertReply(this.ShowAuth()) .Send(this.GetAuthResponse()) .AssertReplyOneOf(this.NextMeetingPrompt()) .AssertReply(this.ShowCalendarList(eventCount)) .AssertReply(this.ActionEndMessage()) .StartTestAsync(); }
public async Task Test_CalendarCheckAvailableNotAvailable() { this.ServiceManager = MockServiceManager.SetParticipantNotAvailable(); await this.GetTestFlow() .Send(CheckAvailableTestUtterances.BaseCheckAvailable) .AssertReplyOneOf(this.NotAvailableResponse()) .AssertReplyOneOf(this.AskForFindNextAvailableTimeResponse()) .Send(Strings.Strings.ConfirmYes) .AssertReplyOneOf(this.BothAvailableResponse()) .AssertReplyOneOf(this.AskForCreateNewMeeting()) .Send(Strings.Strings.ConfirmNo) .AssertReply(this.ActionEndMessage()) .StartTestAsync(); }
public async Task Test_CalendarSummaryGetMultipleMeetings() { int eventCount = 3; this.ServiceManager = MockServiceManager.SetMeetingsToMultiple(eventCount); await this.GetTestFlow() .Send(FindMeetingTestUtterances.BaseFindMeeting) .AssertReply(this.ShowAuth()) .Send(this.GetAuthResponse()) .AssertReplyOneOf(this.FoundMultipleEventPrompt(eventCount)) .AssertReplyOneOf(this.ReadOutMorePrompt()) .Send(Strings.Strings.ConfirmNo) .AssertReply(this.ActionEndMessage()) .StartTestAsync(); }
public async Task Test_CalendarDeleteFromMultipleEvents() { int eventCount = 3; this.ServiceManager = MockServiceManager.SetMeetingsToMultiple(eventCount); await this.GetTestFlow() .Send(ChangeMeetingStatusTestUtterances.DeleteMeetingWithTitle) .AssertReply(this.ShowCalendarList()) .Send(GeneralTestUtterances.ChooseOne) .AssertReply(this.ShowCalendarList()) .Send(Strings.Strings.ConfirmYes) .AssertReplyOneOf(this.DeleteEventPrompt()) .AssertReply(this.ActionEndMessage()) .StartTestAsync(); }
public async Task Test_CalendarCheckAvailableNotAvailable() { this.ServiceManager = MockServiceManager.SetParticipantNotAvailable(); await this.GetTestFlow() .Send(string.Empty) .AssertReplyOneOf(GetTemplates(CalendarMainResponses.FirstPromptMessage)) .Send(CheckPersonAvailableTestUtterances.BaseCheckAvailable) .AssertReplyOneOf(this.NotAvailableResponse()) .AssertReplyOneOf(this.AskForFindNextAvailableTimeResponse()) .Send(Strings.Strings.ConfirmYes) .AssertReplyOneOf(this.BothAvailableResponse()) .AssertReplyOneOf(this.AskForCreateNewMeeting()) .Send(Strings.Strings.ConfirmNo) .StartTestAsync(); }
public async Task Test_CalendarCheckAvailableSlotFilling() { this.ServiceManager = MockServiceManager.SetAllToDefault(); await this.GetTestFlow() .Send(CheckAvailableTestUtterances.CheckAvailableSlotFilling) .AssertReplyOneOf(this.AskForCollectContact()) .Send(Strings.Strings.DefaultUserName) .AssertReplyOneOf(this.AskForCollectTime()) .Send("4 pm") .AssertReplyOneOf(this.AvailableResponse()) .AssertReplyOneOf(this.AskForCreateNewMeeting()) .Send(Strings.Strings.ConfirmNo) .AssertReply(this.ActionEndMessage()) .StartTestAsync(); }
public async Task Test_AddMeetingRoomWithNewStartDateEntity() { this.ServiceManager = MockServiceManager.SetMeetingWithMeetingRoom(); await this.GetTestFlow() .Send(string.Empty) .AssertReplyOneOf(GetTemplates(CalendarMainResponses.FirstPromptMessage)) .Send(UpdateMeetingRoomTestUtterances.AddMeetingRoomWithStartTime) .AssertReplyOneOf(AskForBuildingPrompt()) .Send(Strings.Strings.DefaultBuilding) .AssertReplyOneOf(AskForFloorNumberPrompt()) .Send(Strings.Strings.DefaultFloorNumber) .AssertReplyOneOf(AskForConfirmMeetingRoomPrompt(dateTime: "at 6:00 PM")) .Send(Strings.Strings.ConfirmYes) .AssertReplyOneOf(ReplyMeetingRoomAdded(dateTime: "at 6:00 PM")) .StartTestAsync(); }
public async Task Test_CalendarSummaryReadOutWithMutipleMeetingByContactName() { int eventCount = 3; this.ServiceManager = MockServiceManager.SetMeetingsToMultiple(eventCount); await this.GetTestFlow() .Send(FindMeetingTestUtterances.BaseFindMeeting) .AssertReplyOneOf(this.FoundMultipleEventPrompt(eventCount)) .AssertReplyOneOf(this.ReadOutMorePrompt()) .Send(Strings.Strings.DefaultUserName + "0") .AssertReply(this.ShowReadOutEventList("0")) .AssertReplyOneOf(this.AskForOrgnizerActionPrompt()) .Send(Strings.Strings.ConfirmNo) .AssertReply(this.ActionEndMessage()) .StartTestAsync(); }
public async Task Test_CalendarSummaryReadOutWithMutipleMeetingByNumber() { int eventCount = 3; this.ServiceManager = MockServiceManager.SetMeetingsToMultiple(eventCount); await this.GetTestFlow() .Send(string.Empty) .AssertReplyOneOf(GetTemplates(CalendarMainResponses.FirstPromptMessage)) .Send(FindMeetingTestUtterances.BaseFindMeeting) .AssertReplyOneOf(this.FoundMultipleEventPrompt(eventCount)) .AssertReplyOneOf(this.ReadOutMorePrompt()) .Send(GeneralTestUtterances.ChooseOne) .AssertReply(this.ShowReadOutEventList("0")) .AssertReplyOneOf(this.AskForOrgnizerActionPrompt()) .Send(Strings.Strings.ConfirmNo) .StartTestAsync(); }
public virtual void InitializeSkill() { ServiceManager = MockServiceManager.GetServiceManager(); Services = new ServiceCollection(); Services.AddSingleton(new BotSettings()); Services.AddSingleton(new BotServices()); 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 = "ResponsesAndTexts"; var supportedLocales = new List <string>() { "en-us", "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", "ResponsesAndTexts", $"{templateFile}.lg") : Path.Combine(".", "Responses", "ResponsesAndTexts", $"{templateFile}.{locale}.lg"); localizedTemplates.Add(locale, localeTemplateFile); } TemplateEngine = new LocaleTemplateManager(localizedTemplates, "en-us"); Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-us"); Services.AddSingleton(TemplateEngine); Services.AddSingleton(ServiceManager); Services.AddTransient <MainDialog>(); Services.AddTransient <PlayMusicDialog>(); Services.AddTransient <ControlSettingsDialog>(); Services.AddSingleton <TestAdapter, DefaultTestAdapter>(); Services.AddTransient <IBot, DefaultActivityHandler <MainDialog> >(); }
public async Task Test_CalendarUpdateFromMultipleEvents() { int eventCount = 3; this.ServiceManager = MockServiceManager.SetMeetingsToMultiple(eventCount); await this.GetTestFlow() .Send(UpdateMeetingTestUtterances.UpdateMeetingWithStartTime) .AssertReply(this.ShowCalendarList()) .Send(GeneralTestUtterances.ChooseOne) .AssertReplyOneOf(this.AskForNewTimePrompt()) .Send("tomorrow 9 pm") .AssertReply(this.ShowCalendarList()) .Send(Strings.Strings.ConfirmYes) .AssertReplyOneOf(this.UpdateEventPrompt()) .AssertReply(this.ActionEndMessage()) .StartTestAsync(); }
public override void Initialize() { var builder = new ContainerBuilder(); this.ConversationState = new ConversationState(new MemoryStorage()); this.UserState = new UserState(new MemoryStorage()); this.TelemetryClient = new NullBotTelemetryClient(); this.CalendarStateAccessor = this.ConversationState.CreateProperty <CalendarSkillState>(nameof(CalendarSkillState)); this.Services = new MockSkillConfiguration(); builder.RegisterInstance(new BotStateSet(this.UserState, this.ConversationState)); this.Container = builder.Build(); this.ServiceManager = MockServiceManager.GetCalendarService(); this.BotResponseBuilder = new BotResponseBuilder(); this.BotResponseBuilder.AddFormatter(new TextBotResponseFormatter()); }
public override void Initialize() { var builder = new ContainerBuilder(); this.ConversationState = new ConversationState(new MemoryStorage()); this.UserState = new UserState(new MemoryStorage()); this.EmailStateAccessor = this.ConversationState.CreateProperty <EmailSkillState>(nameof(EmailSkillState)); this.Services = new MockSkillConfiguration(); builder.RegisterInstance(new BotStateSet(this.UserState, this.ConversationState)); var fakeServiceManager = new MockServiceManager(); builder.RegisterInstance <IServiceManager>(fakeServiceManager); this.Container = builder.Build(); this.ServiceManager = fakeServiceManager; this.BotResponseBuilder = new BotResponseBuilder(); this.BotResponseBuilder.AddFormatter(new TextBotResponseFormatter()); }
public async Task Test_BookMeetingRoom_MeetingRoomBusyAndRecreate() { var floorNumberBusy = 2; ServiceManager = MockServiceManager.SetFloor2NotAvailable(); await GetTestFlow() .Send(string.Empty) .AssertReplyOneOf(GetTemplates(CalendarMainResponses.CalendarWelcomeMessage)) .Send(BookMeetingRoomTestUtterances.BaseBookMeetingRoom) .AssertReplyOneOf(AskForDurationPrompt()) .Send(Strings.Strings.DefaultDuration) .AssertReplyOneOf(AskForBuildingPrompt()) .Send(Strings.Strings.DefaultBuilding) .AssertReplyOneOf(AskForFloorNumberPrompt()) .Send(string.Format(Strings.Strings.FloorNumber, floorNumberBusy)) .AssertReplyOneOf(ReplyMeetingRoomBusy(floorNumber: floorNumberBusy)) .AssertReplyOneOf(AskForRecreateMeetingRoomPrompt()) .Send(BookMeetingRoomTestUtterances.ChangeMeetingRoom) .AssertReplyOneOf(AskForBuildingPrompt()) .Send(Strings.Strings.DefaultBuilding) .AssertReplyOneOf(AskForFloorNumberPrompt()) .Send(Strings.Strings.DefaultFloorNumber) .AssertReplyOneOf(AskForConfirmMeetingRoomPrompt()) .Send(Strings.Strings.ConfirmYes) .AssertReplyOneOf(ConfirmedMeetingRoom()) .AssertReplyOneOf(AskForParticpantsPrompt()) .Send(Strings.Strings.DefaultUserName) .AssertReplyOneOf(ConfirmOneNameOneAddress()) .AssertReplyOneOf(AddMoreUserPrompt()) .Send(Strings.Strings.ConfirmNo) .AssertReplyOneOf(AskForSubjectWithContactNamePrompt()) .Send(Strings.Strings.DefaultEventName) .AssertReplyOneOf(AskForContentPrompt()) .Send(Strings.Strings.DefaultDuration) .AssertReply(ShowCalendarList()) .AssertReplyOneOf(ConfirmPrompt()) .Send(Strings.Strings.ConfirmYes) .AssertReplyOneOf(BookedMeeting()) .StartTestAsync(); }
public async Task Test_CalendarSummaryByTimeRange() { DateTime now = DateTime.Now; DateTime nextWeekDay = now.AddDays(7); DateTime startTime = new DateTime(nextWeekDay.Year, nextWeekDay.Month, nextWeekDay.Day, 18, 0, 0); startTime = TimeZoneInfo.ConvertTimeToUtc(startTime); this.ServiceManager = MockServiceManager.SetMeetingsToSpecial(new List <EventModel>() { MockServiceManager.CreateEventModel( startDateTime: startTime, endDateTime: startTime.AddHours(1)) }); await this.GetTestFlow() .Send(FindMeetingTestUtterances.FindMeetingByTimeRange) .AssertReplyOneOf(this.FoundOneEventPrompt("for next week", "next week")) .AssertReplyOneOf(this.AskForOrgnizerActionPrompt("next week")) .Send(Strings.Strings.ConfirmNo) .AssertReply(this.ActionEndMessage()) .StartTestAsync(); }
public async Task Test_CalendarCreateWithWrongContactName() { var peopleCount = 3; ServiceManager = MockServiceManager.SetPeopleToMultiple(peopleCount); var testRecipient = string.Format(Strings.Strings.UserName, 0); var testEmailAddress = string.Format(Strings.Strings.UserEmailAddress, 0); await GetTestFlow() .Send(CreateMeetingTestUtterances.BaseCreateMeeting) .AssertReplyOneOf(AskForParticpantsPrompt()) .Send("wrong name") .AssertReplyOneOf(UserNotFoundPrompt("wrong name")) .AssertReplyOneOf(AskForEmailPrompt()) .Send("wrong name") .AssertReplyOneOf(UserNotFoundAgainPrompt("wrong name")) .Send(string.Format(Strings.Strings.UserName, 0)) .AssertReplyOneOf(ConfirmOneNameOneAddress(testRecipient, testEmailAddress)) .AssertReplyOneOf(AddMoreUserPrompt()) .Send(Strings.Strings.ConfirmNo) .AssertReplyOneOf(AskForSubjectWithContactNamePrompt(testRecipient, testEmailAddress)) .Send(Strings.Strings.DefaultEventName) .AssertReplyOneOf(AskForContentPrompt()) .Send(Strings.Strings.DefaultContent) .AssertReplyOneOf(AskForDatePrompt()) .Send(Strings.Strings.DefaultStartDate) .AssertReplyOneOf(AskForStartTimePrompt()) .Send(Strings.Strings.DefaultStartTime) .AssertReplyOneOf(AskForDurationPrompt()) .Send(Strings.Strings.DefaultDuration) .AssertReplyOneOf(AskForLocationPrompt()) .Send(Strings.Strings.DefaultLocation) .AssertReply(ShowCalendarList()) .AssertReplyOneOf(ConfirmPrompt()) .Send(Strings.Strings.ConfirmYes) .AssertReply(ShowCalendarList()) .AssertReply(ActionEndMessage()) .StartTestAsync(); }
public override void Initialize() { var builder = new ContainerBuilder(); this.ConversationState = new ConversationState(new MemoryStorage()); this.UserState = new UserState(new MemoryStorage()); this.ProactiveState = new ProactiveState(new MemoryStorage()); this.TelemetryClient = new NullBotTelemetryClient(); this.BackgroundTaskQueue = new BackgroundTaskQueue(); this.EmailStateAccessor = this.ConversationState.CreateProperty <EmailSkillState>(nameof(EmailSkillState)); this.Services = new MockSkillConfiguration(); this.EndpointService = new EndpointService(); builder.RegisterInstance(new BotStateSet(this.UserState, this.ConversationState)); var fakeServiceManager = new MockServiceManager(); builder.RegisterInstance <IServiceManager>(fakeServiceManager); this.Container = builder.Build(); this.ServiceManager = fakeServiceManager; ResponseManager = new ResponseManager( responseTemplates: new IResponseIdCollection[] { new FindContactResponses(), new DeleteEmailResponses(), new ForwardEmailResponses(), new EmailMainResponses(), new ReplyEmailResponses(), new SendEmailResponses(), new EmailSharedResponses(), new ShowEmailResponses(), }, locales: new string[] { "en", "de", "es", "fr", "it", "zh" }); ConfigData.GetInstance().MaxDisplaySize = 3; ConfigData.GetInstance().MaxReadSize = 3; }
public async Task Test_CalendarJoinLinkWithStartTimeEntity() { var now = DateTime.Now; var startTime = new DateTime(now.Year, now.Month, now.Day, 18, 0, 0); startTime = startTime.AddDays(1); startTime = TimeZoneInfo.ConvertTimeToUtc(startTime); this.ServiceManager = MockServiceManager.SetMeetingsToSpecial(new List <EventModel>() { MockCalendarService.CreateEventModel( startDateTime: startTime, endDateTime: startTime.AddHours(1), content: "<a href=\"meetinglink\">Join Microsoft Teams Meeting</a>") }); await this.GetTestFlow() .Send(ConnectToMeetingUtterances.JoinMeetingWithStartTime) .AssertReplyOneOf(this.ConfirmMeetingLinkPrompt()) .Send(Strings.Strings.ConfirmYes) .AssertReplyOneOf(this.JoinMeetingResponse()) .AssertReply(this.JoinMeetingEvent()) .AssertReply(this.ActionEndMessage()) .StartTestAsync(); }
public async Task Test_CalendarJoinNumberWithStartTimeEntityEvent() { var now = DateTime.Now; var startTime = new DateTime(now.Year, now.Month, now.Day, 18, 0, 0); startTime = startTime.AddDays(1); startTime = TimeZoneInfo.ConvertTimeToUtc(startTime); this.ServiceManager = MockServiceManager.SetMeetingsToSpecial(new List <EventModel>() { MockCalendarService.CreateEventModel( startDateTime: startTime, endDateTime: startTime.AddHours(1), content: "<a href=\"tel:12345678 \">12345678</a>") }); await this.GetSkillTestFlow() .Send(ConnectToMeetingUtterances.JoinMeetingWithStartTimeEvent) .AssertReplyOneOf(this.ConfirmPhoneNumberPrompt()) .Send(Strings.Strings.ConfirmYes) .AssertReplyOneOf(this.JoinMeetingResponse()) .AssertReply(this.JoinMeetingEvent()) .AssertReply(CheckForOperationStatus(true)) .StartTestAsync(); }
public override void Initialize() { // Initialize mock service manager ServiceManager = new MockServiceManager(); // Initialize service collection Services = new ServiceCollection(); Services.AddSingleton(new BotSettings() { OAuthConnections = new List <OAuthConnection>() { new OAuthConnection() { Name = Provider, Provider = Provider } } }); Services.AddSingleton(new BotServices() { CognitiveModelSets = new Dictionary <string, CognitiveModelSet> { { "en-us", new CognitiveModelSet() { LuisServices = new Dictionary <string, LuisRecognizer> { { MockData.LuisGeneral, new MockLuisRecognizer(new GeneralTestUtterances()) }, { MockData.LuisToDo, new MockLuisRecognizer( new DeleteToDoFlowTestUtterances(), new AddToDoFlowTestUtterances(), new MarkToDoFlowTestUtterances(), new ShowToDoFlowTestUtterances()) } } } } } }); Services.AddSingleton <IBotTelemetryClient, NullBotTelemetryClient>(); Services.AddSingleton(new UserState(new MemoryStorage())); Services.AddSingleton(new ConversationState(new MemoryStorage())); Services.AddSingleton(new ProactiveState(new MemoryStorage())); Services.AddSingleton(new MicrosoftAppCredentials(string.Empty, string.Empty)); Services.AddSingleton(sp => { var userState = sp.GetService <UserState>(); var conversationState = sp.GetService <ConversationState>(); var proactiveState = sp.GetService <ProactiveState>(); return(new BotStateSet(userState, conversationState)); }); Services.AddSingleton <IBackgroundTaskQueue, BackgroundTaskQueue>(); Services.AddSingleton <IServiceManager>(ServiceManager); Services.AddSingleton <TestAdapter>(sp => { var adapter = new DefaultTestAdapter(); adapter.AddUserToken(Provider, Channels.Test, "user1", TestToken); return(adapter); }); Services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); Services.AddTransient <MainDialog>(); Services.AddTransient <AddToDoItemDialog>(); Services.AddTransient <DeleteToDoItemDialog>(); Services.AddTransient <MarkToDoItemDialog>(); Services.AddTransient <ShowToDoItemDialog>(); Services.AddTransient <IBot, DefaultActivityHandler <MainDialog> >(); // Configure localized responses var localizedTemplates = new Dictionary <string, string>(); var templateFile = "ResponsesAndTexts"; 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", "Shared", $"{templateFile}.lg") : Path.Combine(".", "Responses", "Shared", $"{templateFile}.{locale}.lg"); localizedTemplates.Add(locale, localeTemplateFile); } Services.AddSingleton(new LocaleTemplateManager(localizedTemplates, "en-us")); // Configure files for generating all responses. Response from bot should equal one of them. var allTemplates = Templates.ParseFile(Path.Combine("Responses", "Shared", "ResponsesAndTexts.lg")); Services.AddSingleton(allTemplates); Services.AddSingleton <IStorage>(new MemoryStorage()); }
public void TestCleanup() { this.ServiceManager = MockServiceManager.SetAllToDefault(); }
public override void Initialize() { // Initialize mock service manager ServiceManager = new MockServiceManager(); // Initialize service collection Services = new ServiceCollection(); Services.AddSingleton(new BotSettings() { OAuthConnections = new List <OAuthConnection>() { new OAuthConnection() { Name = Provider, Provider = Provider } } }); Services.AddSingleton(new BotServices() { CognitiveModelSets = new Dictionary <string, CognitiveModelSet> { { "en-us", new CognitiveModelSet() { LuisServices = new Dictionary <string, LuisRecognizer> { { MockData.LuisGeneral, new MockLuisRecognizer(new GeneralTestUtterances()) }, { MockData.LuisToDo, new MockLuisRecognizer( new DeleteToDoFlowTestUtterances(), new AddToDoFlowTestUtterances(), new MarkToDoFlowTestUtterances(), new ShowToDoFlowTestUtterances()) } } } } } }); Services.AddSingleton <IBotTelemetryClient, NullBotTelemetryClient>(); Services.AddSingleton(new UserState(new MemoryStorage())); Services.AddSingleton(new ConversationState(new MemoryStorage())); Services.AddSingleton(new ProactiveState(new MemoryStorage())); Services.AddSingleton(new MicrosoftAppCredentials(string.Empty, string.Empty)); Services.AddSingleton(sp => { var userState = sp.GetService <UserState>(); var conversationState = sp.GetService <ConversationState>(); var proactiveState = sp.GetService <ProactiveState>(); return(new BotStateSet(userState, conversationState)); }); ResponseManager = new ResponseManager( new string[] { "en", "de", "es", "fr", "it", "zh" }, new AddToDoResponses(), new DeleteToDoResponses(), new ToDoMainResponses(), new MarkToDoResponses(), new ToDoSharedResponses(), new ShowToDoResponses()); Services.AddSingleton(ResponseManager); Services.AddSingleton <IBackgroundTaskQueue, BackgroundTaskQueue>(); Services.AddSingleton <IServiceManager>(ServiceManager); Services.AddSingleton <TestAdapter, DefaultTestAdapter>(); Services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); Services.AddTransient <MainDialog>(); Services.AddTransient <AddToDoItemDialog>(); Services.AddTransient <DeleteToDoItemDialog>(); Services.AddTransient <MarkToDoItemDialog>(); Services.AddTransient <ShowToDoItemDialog>(); Services.AddTransient <IBot, DefaultActivityHandler <MainDialog> >(); }
public override void Initialize() { this.ServiceManager = MockServiceManager.GetCalendarService(); // Initialize service collection Services = new ServiceCollection(); Services.AddSingleton(new BotSettings() { OAuthConnections = new List <OAuthConnection>() { new OAuthConnection() { Name = "Microsoft", Provider = "Microsoft" } } }); Services.AddSingleton(new BotServices()); Services.AddSingleton <IBotTelemetryClient, NullBotTelemetryClient>(); Services.AddSingleton(new UserState(new MemoryStorage())); Services.AddSingleton(new ConversationState(new MemoryStorage())); Services.AddSingleton(new ProactiveState(new MemoryStorage())); Services.AddSingleton(new MicrosoftAppCredentials(string.Empty, string.Empty)); Services.AddSingleton(sp => { var userState = sp.GetService <UserState>(); var conversationState = sp.GetService <ConversationState>(); var proactiveState = sp.GetService <ProactiveState>(); return(new BotStateSet(userState, conversationState)); }); ResponseManager = new ResponseManager( new string[] { "en", "de", "es", "fr", "it", "zh" }, new FindContactResponses(), new ChangeEventStatusResponses(), new CreateEventResponses(), new JoinEventResponses(), new CalendarMainResponses(), new CalendarSharedResponses(), new SummaryResponses(), new TimeRemainingResponses(), new UpdateEventResponses(), new UpcomingEventResponses()); Services.AddSingleton(ResponseManager); Services.AddSingleton <IBackgroundTaskQueue, BackgroundTaskQueue>(); Services.AddSingleton(ServiceManager); Services.AddSingleton <TestAdapter, DefaultTestAdapter>(); Services.AddTransient <MainDialog>(); Services.AddTransient <ChangeEventStatusDialog>(); Services.AddTransient <ConnectToMeetingDialog>(); Services.AddTransient <CreateEventDialog>(); Services.AddTransient <FindContactDialog>(); Services.AddTransient <SummaryDialog>(); Services.AddTransient <TimeRemainingDialog>(); Services.AddTransient <UpcomingEventDialog>(); Services.AddTransient <UpdateEventDialog>(); Services.AddTransient <FindContactDialog>(); Services.AddTransient <IBot, DialogBot <MainDialog> >(); var state = Services.BuildServiceProvider().GetService <ConversationState>(); CalendarStateAccessor = state.CreateProperty <CalendarSkillState>(nameof(CalendarSkillState)); }
public override void Initialize() { // Initialize mock service manager ServiceManager = new MockServiceManager(); // Initialize service collection Services = new ServiceCollection(); Services.AddSingleton(new BotSettings() { OAuthConnections = new List <OAuthConnection>() { new OAuthConnection() { Name = "Microsoft", Provider = "Microsoft" } } }); Services.AddSingleton(new BotServices() { CognitiveModelSets = new Dictionary <string, CognitiveModelSet> { { "en", new CognitiveModelSet() { LuisServices = new Dictionary <string, ITelemetryRecognizer> { { "general", new MockGeneralLuisRecognizer() }, { "email", new MockEmailLuisRecognizer( new ForwardEmailUtterances(), new ReplyEmailUtterances(), new DeleteEmailUtterances(), new SendEmailUtterances(), new ShowEmailUtterances()) } } } } } }); Services.AddSingleton <IBotTelemetryClient, NullBotTelemetryClient>(); Services.AddSingleton(new UserState(new MemoryStorage())); Services.AddSingleton(new ConversationState(new MemoryStorage())); Services.AddSingleton(new ProactiveState(new MemoryStorage())); Services.AddSingleton(new MicrosoftAppCredentials(string.Empty, string.Empty)); Services.AddSingleton(sp => { var userState = sp.GetService <UserState>(); var conversationState = sp.GetService <ConversationState>(); var proactiveState = sp.GetService <ProactiveState>(); return(new BotStateSet(userState, conversationState)); }); ResponseManager = new ResponseManager( new string[] { "en", "de", "es", "fr", "it", "zh" }, new FindContactResponses(), new DeleteEmailResponses(), new ForwardEmailResponses(), new EmailMainResponses(), new ReplyEmailResponses(), new SendEmailResponses(), new EmailSharedResponses(), new ShowEmailResponses()); Services.AddSingleton(ResponseManager); Services.AddSingleton <IBackgroundTaskQueue, BackgroundTaskQueue>(); Services.AddSingleton <IServiceManager>(ServiceManager); Services.AddSingleton <TestAdapter, DefaultTestAdapter>(); Services.AddTransient <MainDialog>(); Services.AddTransient <DeleteEmailDialog>(); Services.AddTransient <FindContactDialog>(); Services.AddTransient <ForwardEmailDialog>(); Services.AddTransient <ReplyEmailDialog>(); Services.AddTransient <SendEmailDialog>(); Services.AddTransient <ShowEmailDialog>(); Services.AddTransient <IBot, DialogBot <MainDialog> >(); ConfigData.GetInstance().MaxDisplaySize = 3; ConfigData.GetInstance().MaxReadSize = 3; }
public override void Initialize() { // Initialize mock service manager ServiceManager = new MockServiceManager(); // Initialize service collection Services = new ServiceCollection(); Services.AddSingleton(new BotSettings() { OAuthConnections = new List <OAuthConnection>() { new OAuthConnection() { Name = Provider, Provider = Provider } } }); Services.AddSingleton(new BotServices() { CognitiveModelSets = new Dictionary <string, CognitiveModelSet> { { "en-us", new CognitiveModelSet() { LuisServices = new Dictionary <string, LuisRecognizer> { { "General", new MockGeneralLuisRecognizer() }, { "Email", new MockEmailLuisRecognizer( new ForwardEmailUtterances(), new ReplyEmailUtterances(), new DeleteEmailUtterances(), new SendEmailUtterances(), new ShowEmailUtterances()) } } } } } }); Services.AddSingleton <IBotTelemetryClient, NullBotTelemetryClient>(); Services.AddSingleton(new UserState(new MemoryStorage())); Services.AddSingleton(new ConversationState(new MemoryStorage())); Services.AddSingleton(new ProactiveState(new MemoryStorage())); Services.AddSingleton(new MicrosoftAppCredentials(string.Empty, string.Empty)); Services.AddSingleton(sp => { var userState = sp.GetService <UserState>(); var conversationState = sp.GetService <ConversationState>(); var proactiveState = sp.GetService <ProactiveState>(); return(new BotStateSet(userState, conversationState)); }); Services.AddSingleton <TestAdapter>(sp => { var adapter = new DefaultTestAdapter(); adapter.AddUserToken("Azure Active Directory v2", Channels.Test, "user1", "test"); return(adapter); }); // Configure localized responses var supportedLocales = new List <string>() { "en-us", "de-de", "es-es", "fr-fr", "it-it", "zh-cn" }; var templateFiles = new Dictionary <string, string> { { "Shared", "ResponsesAndTexts" }, }; var localizedTemplates = new Dictionary <string, List <string> >(); foreach (var locale in supportedLocales) { var localeTemplateFiles = new List <string>(); foreach (var(dialog, template) in templateFiles) { // LG template for default locale should not include locale in file extension. if (locale.Equals("en-us")) { localeTemplateFiles.Add(Path.Combine(".", "Responses", dialog, $"{template}.lg")); } else { localeTemplateFiles.Add(Path.Combine(".", "Responses", dialog, $"{template}.{locale}.lg")); } } localizedTemplates.Add(locale, localeTemplateFiles); } Services.AddSingleton(new LocaleTemplateEngineManager(localizedTemplates, "en-us")); // Configure files for generating all responses. Response from bot should equal one of them. var engineAll = new TemplateEngine().AddFile(Path.Combine("Responses", "Shared", "ResponsesAndTexts.lg")); Services.AddSingleton(engineAll); Services.AddSingleton <IStorage>(new MemoryStorage()); Services.AddSingleton <IBackgroundTaskQueue, BackgroundTaskQueue>(); Services.AddSingleton <IServiceManager>(ServiceManager); Services.AddTransient <MainDialog>(); Services.AddTransient <DeleteEmailDialog>(); Services.AddTransient <FindContactDialog>(); Services.AddTransient <ForwardEmailDialog>(); Services.AddTransient <ReplyEmailDialog>(); Services.AddTransient <SendEmailDialog>(); Services.AddTransient <ShowEmailDialog>(); Services.AddTransient <IBot, DefaultActivityHandler <MainDialog> >(); ConfigData.GetInstance().MaxDisplaySize = 3; ConfigData.GetInstance().MaxReadSize = 3; }