Ejemplo n.º 1
0
        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.CalendarStateAccessor = this.ConversationState.CreateProperty <CalendarSkillState>(nameof(CalendarSkillState));
            this.Services        = new MockSkillConfiguration();
            this.EndpointService = new EndpointService();

            builder.RegisterInstance(new BotStateSet(this.UserState, this.ConversationState));

            this.Container      = builder.Build();
            this.ServiceManager = MockServiceManager.GetCalendarService();

            ResponseManager = new ResponseManager(
                responseTemplates: new IResponseIdCollection[]
            {
                new FindContactResponses(),
                new ChangeEventStatusResponses(),
                new CreateEventResponses(),
                new JoinEventResponses(),
                new CalendarMainResponses(),
                new CalendarSharedResponses(),
                new SummaryResponses(),
                new TimeRemainingResponses(),
                new UpdateEventResponses(),
                new UpcomingEventResponses()
            },
                locales: new string[] { "en", "de", "es", "fr", "it", "zh" });
        }
Ejemplo n.º 2
0
        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());
        }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
        public override void Initialize()
        {
            this.ServiceManager = MockServiceManager.GetCalendarService();
            this.SearchService  = new MockSearchClient();

            // Initialize service collection
            Services = new ServiceCollection();
            Services.AddSingleton(new BotSettings()
            {
                OAuthConnections = new List <OAuthConnection>()
                {
                    new OAuthConnection()
                    {
                        Name = Provider, Provider = Provider
                    }
                },

                AzureSearch = new BotSettings.AzureSearchConfiguration()
                {
                    SearchServiceName = "mockSearchService"
                }
            });

            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));
            });

            Services.AddSingleton <TestAdapter>(sp =>
            {
                var adapter = new DefaultTestAdapter();
                adapter.AddUserToken("Azure Active Directory v2", Channels.Test, "user1", "test");
                return(adapter);
            });
            Services.AddSingleton(SearchService);

            // 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());
            Services.AddSingleton <IBackgroundTaskQueue, BackgroundTaskQueue>();
            Services.AddSingleton(ServiceManager);
            Services.AddTransient <MainDialog>();
            Services.AddTransient <ChangeEventStatusDialog>();
            Services.AddTransient <JoinEventDialog>();
            Services.AddTransient <CreateEventDialog>();
            Services.AddTransient <FindContactDialog>();
            Services.AddTransient <ShowEventsDialog>();
            Services.AddTransient <TimeRemainingDialog>();
            Services.AddTransient <UpcomingEventDialog>();
            Services.AddTransient <UpdateEventDialog>();
            Services.AddTransient <CheckPersonAvailableDialog>();
            Services.AddTransient <FindMeetingRoomDialog>();
            Services.AddTransient <BookMeetingRoomDialog>();
            Services.AddTransient <UpdateMeetingRoomDialog>();
            Services.AddTransient <IBot, DefaultActivityHandler <MainDialog> >();

            var state = Services.BuildServiceProvider().GetService <ConversationState>();

            CalendarStateAccessor = state.CreateProperty <CalendarSkillState>(nameof(CalendarSkillState));
        }