Example #1
0
        /// <summary>
        /// Configures the <see cref="IServiceCollection"/> to use.
        /// </summary>
        /// <param name="services">The service collection to configure.</param>
        protected virtual void ConfigureServices(IServiceCollection services)
        {
            services.AddLogging((builder) =>
            {
                var options = new LambdaLoggerOptions()
                {
                    Filter = FilterLogs,
                };

                builder.AddLambdaLogger(options);
            });

            services.AddHttpClients();
            services.AddPolly();

            services.TryAddSingleton((_) => SkillConfiguration.CreateDefaultConfiguration());

            services.AddSingleton <AlexaSkill>();
            services.AddSingleton <FunctionHandler>();
            services.AddSingleton <IntentFactory>();
            services.AddSingleton((_) => TelemetryConfiguration.CreateDefault());
            services.AddSingleton(CreateTelemetryClient);

            services.AddSingleton <EmptyIntent>();
            services.AddSingleton <HelpIntent>();
            services.AddSingleton <UnknownIntent>();

            services.AddTransient <CommuteIntent>();
            services.AddTransient <DisruptionIntent>();
            services.AddTransient <StatusIntent>();
        }
Example #2
0
        protected virtual async Task <AlexaFunction> CreateFunctionAsync()
        {
            SkillConfiguration config = CreateConfiguration();
            var function = new TestAlexaFunction(config, Interceptor, OutputHelper);

            await function.InitializeAsync();

            return(function);
        }
Example #3
0
 public TestAlexaFunction(
     SkillConfiguration config,
     HttpClientInterceptorOptions options,
     ITestOutputHelper outputHelper)
 {
     Config       = config;
     Options      = options;
     OutputHelper = outputHelper;
 }
Example #4
0
        protected virtual SkillConfiguration CreateConfiguration()
        {
            var config = SkillConfiguration.CreateDefaultConfiguration();

            config.ApplicationInsightsKey = "my-application-insights-key";
            config.SkillApiUrl            = "https://londontravel.martincostello.local/";
            config.SkillId           = "my-skill-id";
            config.TflApplicationId  = "my-tfl-app-id";
            config.TflApplicationKey = "my-tfl-app-key";
            config.VerifySkillId     = true;

            return(config);
        }
Example #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FunctionHandler"/> class.
 /// </summary>
 /// <param name="skill">The <see cref="AlexaSkill"/> to use.</param>
 /// <param name="config">The <see cref="SkillConfiguration"/> to use.</param>
 public FunctionHandler(AlexaSkill skill, SkillConfiguration config)
 {
     Config = config;
     Skill  = skill;
 }