Beispiel #1
0
        public async Task Test_CalendarSummaryByStartTime()
        {
            var      serviceManager = this.ServiceManager as MockCalendarServiceManager;
            DateTime now            = DateTime.Now;
            DateTime startTime      = new DateTime(now.Year, now.Month, now.Day, 18, 0, 0);

            startTime = startTime.AddDays(1);
            startTime = TimeZoneInfo.ConvertTimeToUtc(startTime);
            serviceManager.SetupCalendarService(new List <EventModel>()
            {
                MockCalendarService.CreateEventModel(
                    startDateTime: startTime,
                    endDateTime: startTime.AddHours(1)),
            });
            await this.GetTestFlow()
            .Send(FindMeetingTestUtterances.FindMeetingByStartTime)
            .AssertReply(this.ShowAuth())
            .Send(this.GetAuthResponse())
            .AssertReplyOneOf(this.FoundOneEventPrompt())
            .AssertReply(this.ShowCalendarList(1))
            .AssertReplyOneOf(this.ReadOutMorePrompt())
            .Send(Strings.Strings.ConfirmNo)
            .AssertReply(this.ActionEndMessage())
            .StartTestAsync();
        }
Beispiel #2
0
        public async Task Test_CalendarUpdateWithStartTimeEntity()
        {
            var      serviceManager = this.ServiceManager as MockCalendarServiceManager;
            DateTime now            = DateTime.Now;
            DateTime startTime      = new DateTime(now.Year, now.Month, now.Day, 18, 0, 0);

            startTime = startTime.AddDays(1);
            startTime = TimeZoneInfo.ConvertTimeToUtc(startTime);
            serviceManager.SetupCalendarService(new List <EventModel>()
            {
                MockCalendarService.CreateEventModel(
                    startDateTime: startTime,
                    endDateTime: startTime.AddHours(1))
            });
            await this.GetTestFlow()
            .Send(UpdateMeetingTestUtterances.UpdateMeetingWithStartTime)
            .AssertReply(this.ShowAuth())
            .Send(this.GetAuthResponse())
            .AssertReplyOneOf(this.AskForNewTimePrompt())
            .Send("tomorrow 9 pm")
            .AssertReply(this.ShowCalendarList())
            .Send(Strings.Strings.ConfirmYes)
            .AssertReply(this.ShowCalendarList())
            .AssertReply(this.ActionEndMessage())
            .StartTestAsync();
        }
        public async Task Test_CalendarJoinWithStartTimeEntity()
        {
            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.GetTestFlow()
            .Send(ConnectToMeetingUtterances.JoinMeetingWithStartTime)
            .AssertReply(this.ShowAuth())
            .Send(this.GetAuthResponse())
            .AssertReplyOneOf(this.ConfirmPhoneNumberPrompt())
            .Send(Strings.Strings.ConfirmYes)
            .AssertReplyOneOf(this.JoinMeetingResponse())
            .AssertReply(this.JoinMeetingEvent())
            .AssertReply(this.ActionEndMessage())
            .StartTestAsync();
        }
Beispiel #4
0
        public async Task DeleteEventsById()
        {
            ICalendar       mockCalendarService = new MockCalendarService("test token");
            IServiceManager serviceManager      = new ServiceManager(new SkillConfiguration());
            ICalendar       calendarService     = serviceManager.InitCalendarService(mockCalendarService, EventSource.Microsoft);

            await calendarService.DeleteEventById("test id");
        }
Beispiel #5
0
        public async Task GetEventsByStartTimeTest()
        {
            ICalendar       mockCalendarService = new MockCalendarService("test token");
            IServiceManager serviceManager      = new ServiceManager(new SkillConfiguration());
            ICalendar       calendarService     = serviceManager.InitCalendarService(mockCalendarService, EventSource.Microsoft);

            await calendarService.GetEventsByStartTime(DateTime.SpecifyKind(new DateTime(), DateTimeKind.Utc));
        }
Beispiel #6
0
        public async Task GetUpComingEventsTest()
        {
            ICalendar       mockCalendarService = new MockCalendarService("test token");
            IServiceManager serviceManager      = new ServiceManager(new SkillConfiguration());
            ICalendar       calendarService     = serviceManager.InitCalendarService(mockCalendarService, EventSource.Microsoft);

            await calendarService.GetUpcomingEvents();
        }
Beispiel #7
0
        public async Task CreateEventTest()
        {
            EventModel newEvent = new EventModel(EventSource.Microsoft);

            ICalendar calendarService = new MockCalendarService("test token");

            await calendarService.CreateEvent(newEvent);
        }
Beispiel #8
0
        public async Task CreateEventTest()
        {
            EventModel newEvent = new EventModel(EventSource.Microsoft);

            ICalendar       mockCalendarService = new MockCalendarService("test token");
            IServiceManager serviceManager      = new ServiceManager(new SkillConfiguration());
            ICalendar       calendarService     = serviceManager.InitCalendarService(mockCalendarService, EventSource.Microsoft);

            await calendarService.CreateEvent(newEvent);
        }
Beispiel #9
0
        public async Task UpdateEventsById()
        {
            ICalendar calendarService = new MockCalendarService("test token");

            EventModel eventModel = new EventModel(EventSource.Microsoft);

            eventModel.Id        = "test";
            eventModel.TimeZone  = TimeZoneInfo.Utc;
            eventModel.StartTime = DateTime.SpecifyKind(new DateTime(), DateTimeKind.Utc);
            eventModel.EndTime   = DateTime.SpecifyKind(new DateTime(), DateTimeKind.Utc);

            await calendarService.UpdateEventById(eventModel);
        }
Beispiel #10
0
        public async Task UpdateEventsById()
        {
            ICalendar       mockCalendarService = new MockCalendarService("test token");
            IServiceManager serviceManager      = new ServiceManager(new SkillConfiguration());
            ICalendar       calendarService     = serviceManager.InitCalendarService(mockCalendarService, EventSource.Microsoft);

            EventModel eventModel = new EventModel(EventSource.Microsoft);

            eventModel.Id        = "test";
            eventModel.TimeZone  = TimeZoneInfo.Utc;
            eventModel.StartTime = DateTime.SpecifyKind(new DateTime(), DateTimeKind.Utc);
            eventModel.EndTime   = DateTime.SpecifyKind(new DateTime(), DateTimeKind.Utc);

            await calendarService.UpdateEventById(eventModel);
        }
Beispiel #11
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();
        }
Beispiel #12
0
        public async Task Test_CalendarMultipleMeetings()
        {
            int eventCount     = 3;
            var serviceManager = this.ServiceManager as MockCalendarServiceManager;

            serviceManager.SetupCalendarService(MockCalendarService.FakeMultipleNextEvents(eventCount));
            await this.GetTestFlow()
            .Send(FindMeetingTestUtterances.BaseNextMeeting)
            .AssertReply(this.ShowAuth())
            .Send(this.GetAuthResponse())
            .AssertReplyOneOf(this.NextMeetingPrompt())
            .AssertReply(this.ShowCalendarList(eventCount))
            .AssertReply(this.ActionEndMessage())
            .StartTestAsync();
        }
Beispiel #13
0
        public async Task Test_CalendarNextMeetingTimeRemaining()
        {
            var serviceManager = this.ServiceManager as MockCalendarServiceManager;

            serviceManager.SetupCalendarService(new List <EventModel>()
            {
                MockCalendarService.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();
        }
Beispiel #14
0
        public async Task Test_CalendarSummaryGetMultipleMeetings()
        {
            int eventCount     = 3;
            var serviceManager = this.ServiceManager as MockCalendarServiceManager;

            serviceManager.SetupCalendarService(MockCalendarService.FakeMultipleEvents(eventCount));
            await this.GetTestFlow()
            .Send(FindMeetingTestUtterances.BaseFindMeeting)
            .AssertReply(this.ShowAuth())
            .Send(this.GetAuthResponse())
            .AssertReplyOneOf(this.FoundMultipleEventPrompt(eventCount))
            .AssertReply(this.ShowCalendarList(eventCount))
            .AssertReplyOneOf(this.ReadOutMorePrompt())
            .Send(Strings.Strings.ConfirmNo)
            .AssertReply(this.ActionEndMessage())
            .StartTestAsync();
        }
Beispiel #15
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());
        }
Beispiel #16
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();
        }
Beispiel #17
0
        public async Task Test_CalendarSummaryByTimeRange()
        {
            var serviceManager = this.ServiceManager as MockCalendarServiceManager;

            serviceManager.SetupCalendarService(new List <EventModel>()
            {
                MockCalendarService.CreateEventModel(startDateTime: DateTime.UtcNow.AddDays(7), endDateTime: DateTime.UtcNow.AddDays(8))
            });
            await this.GetTestFlow()
            .Send(FindMeetingTestUtterances.FindMeetingByTimeRange)
            .AssertReply(this.ShowAuth())
            .Send(this.GetAuthResponse())
            .AssertReplyOneOf(this.FoundOneEventPrompt())
            .AssertReply(this.ShowCalendarList(1))
            .AssertReplyOneOf(this.ReadOutMorePrompt())
            .Send(Strings.Strings.ConfirmNo)
            .AssertReply(this.ActionEndMessage())
            .StartTestAsync();
        }
Beispiel #18
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());
        }
Beispiel #19
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());
        }
        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(string.Empty)
            .AssertReplyOneOf(GetTemplates(CalendarMainResponses.FirstPromptMessage))
            .Send(ConnectToMeetingUtterances.JoinMeetingWithStartTime)
            .AssertReplyOneOf(this.ConfirmMeetingLinkPrompt())
            .Send(Strings.Strings.ConfirmYes)
            .AssertReplyOneOf(this.JoinMeetingResponse())
            .AssertReply(this.JoinMeetingEvent())
            .StartTestAsync();
        }
Beispiel #21
0
        public async Task DeleteEventsById()
        {
            ICalendar calendarService = new MockCalendarService("test token");

            await calendarService.DeleteEventById("test id");
        }
Beispiel #22
0
        public async Task GetEventsByTitle()
        {
            ICalendar calendarService = new MockCalendarService("test token");

            await calendarService.GetEventsByTitle("test");
        }
Beispiel #23
0
        public async Task GetEventsByStartTimeTest()
        {
            ICalendar calendarService = new MockCalendarService("test token");

            await calendarService.GetEventsByStartTime(DateTime.SpecifyKind(new DateTime(), DateTimeKind.Utc));
        }
Beispiel #24
0
        public async Task GetUpComingEventsTest()
        {
            ICalendar calendarService = new MockCalendarService("test token");

            await calendarService.GetUpcomingEvents();
        }