Example #1
0
        public async Task Test_CalendarSummary()
        {
            var serviceManager = this.ServiceManager as MockCalendarServiceManager;

            serviceManager.SetupCalendarService(MockCalendarService.FakeDefaultEvents());
            await this.GetTestFlow()
            .Send(FindMeetingTestUtterances.BaseFindMeeting)
            .AssertReply(this.ShowAuth())
            .Send(this.GetAuthResponse())
            .AssertReplyOneOf(this.FoundOneEventPrompt())
            .AssertReply(this.ShowCalendarList(1))
            .Send(Strings.Strings.ConfirmNo)
            .AssertReply(this.ActionEndMessage())
            .StartTestAsync();
        }
Example #2
0
        public void SetupLuisService()
        {
            this.Services.LocaleConfigurations.Add("en", new LocaleConfiguration()
            {
                Locale       = "en-us",
                LuisServices = new Dictionary <string, ITelemetryLuisRecognizer>()
                {
                    { "general", new MockLuisRecognizer() },
                    { "calendar", new MockLuisRecognizer(new CreateMeetingTestUtterances()) }
                }
            });

            var serviceManager = this.ServiceManager as MockCalendarServiceManager;

            serviceManager.SetupCalendarService(MockCalendarService.FakeDefaultEvents());
            serviceManager.SetupUserService(MockUserService.FakeDefaultUsers(), MockUserService.FakeDefaultPeople());
        }
Example #3
0
        public async Task BasicGetEventPromptTest()
        {
            var convoState  = new ConversationState(new MemoryStorage());
            var dialogState = convoState.CreateProperty <DialogState>("dialogState");

            TestAdapter adapter = new TestAdapter()
                                  .Use(new AutoSaveStateMiddleware(convoState));

            // Create new DialogSet.
            var dialogs = new DialogSet(dialogState);

            // Create and add number prompt to DialogSet.
            var getEventPrompt = new GetEventPrompt("GetEventPrompt", defaultLocale: Culture.English);

            dialogs.Add(getEventPrompt);

            await new TestFlow(adapter, async(turnContext, cancellationToken) =>
            {
                var dc      = await dialogs.CreateContextAsync(turnContext, cancellationToken);
                var service = new MockCalendarService(MockCalendarService.FakeDefaultEvents());

                var results = await dc.ContinueDialogAsync();
                if (results.Status == DialogTurnStatus.Empty)
                {
                    var options = new GetEventOptions(service, mockUserTimeZone)
                    {
                        Prompt = new Activity {
                            Type = ActivityTypes.Message, Text = "Which event you are searching?"
                        },
                    };
                    await dc.PromptAsync("GetEventPrompt", options, cancellationToken);
                }
                else if (results.Status == DialogTurnStatus.Complete)
                {
                    var resolution = (IList <EventModel>)results.Result;
                    var reply      = MessageFactory.Text($"Get {resolution.Count} event");
                    await turnContext.SendActivityAsync(reply, cancellationToken);
                }
            })
            .Send("hello")
            .AssertReply("Which event you are searching?")
            .Send("today")
            .AssertReply(GetEventResponse())
            .StartTestAsync();
        }
Example #4
0
        public void SetupLuisService()
        {
            this.Services.LocaleConfigurations.Add("en", new LocaleConfiguration()
            {
                Locale       = "en-us",
                LuisServices = new Dictionary <string, ITelemetryLuisRecognizer>()
                {
                    { "general", new MockLuisRecognizer() },
                    { "calendar", new MockLuisRecognizer(new UpdateMeetingTestUtterances()) }
                }
            });

            // keep this use old mock, Moq has some conflict with Prompt. It will throw exception in GetEventPrompt
            this.ServiceManager = new MockCalendarServiceManager();
            var serviceManager = this.ServiceManager as MockCalendarServiceManager;

            serviceManager.SetupCalendarService(MockCalendarService.FakeDefaultEvents());
            serviceManager.SetupUserService(MockUserService.FakeDefaultUsers(), MockUserService.FakeDefaultPeople());
        }
Example #5
0
        public void SetupLuisService()
        {
            var botServices = Services.BuildServiceProvider().GetService <BotServices>();

            botServices.CognitiveModelSets.Add("en", new CognitiveModelSet()
            {
                LuisServices = new Dictionary <string, ITelemetryRecognizer>()
                {
                    { "General", new MockLuisRecognizer() },
                    { "Calendar", new MockLuisRecognizer(new DeleteMeetingTestUtterances()) }
                }
            });

            // keep this use old mock, Moq has some conflict with Prompt. It will throw exception in GetEventPrompt
            this.ServiceManager = new MockCalendarServiceManager();
            var serviceManager = this.ServiceManager as MockCalendarServiceManager;

            serviceManager.SetupCalendarService(MockCalendarService.FakeDefaultEvents());
            serviceManager.SetupUserService(MockUserService.FakeDefaultUsers(), MockUserService.FakeDefaultPeople());
        }