public void LaunchRequestMappedReturnsLocale()
        {
            // arrange
            var skillRequest = new SkillRequest
            {
                Request = new LaunchRequest()
                {
                    Locale = "en-US"
                },
                Context = new Context
                {
                    System = new AlexaSystem()
                    {
                        Application = new Application(), User = new User()
                    }
                },
                Session = new Session()
                {
                    User = new User()
                }
            };


            // act
            var alexaMapper = new AlexaRequestMapper();
            var result      = alexaMapper.RequestToActivity(skillRequest);

            // assert
            Assert.Equal("en-US", result.Locale);
        }
        public void SimpleIntentRequestConverted()
        {
            var skillRequest  = SkillRequestHelper.CreateIntentRequest();
            var mapperOptions = new AlexaRequestMapperOptions {
                ServiceUrl = "service url"
            };
            var mapper = new AlexaRequestMapper(mapperOptions);

            ((IntentRequest)skillRequest.Request).Intent.Slots[mapperOptions.DefaultIntentSlotName].Value = "hello world";

            var convertedActivity = mapper.RequestToActivity(skillRequest);

            VerifyIntentRequest(skillRequest, convertedActivity, mapperOptions);
        }
        public void TaskRequest()
        {
            var request = new LaunchRequest
            {
                Locale    = "en-US",
                RequestId = "amzn1.echo-api.request.00000000-0000-0000-0000-000000000000",
                Type      = "LaunchRequest",
                Timestamp = DateTime.Now,
                Task      = new LaunchRequestTask
                {
                    Name    = "AMAZON.PrintPDF",
                    Version = "1",
                    Input   = new PrintPdfV1
                    {
                        Title       = "Flywheel",
                        Description = "Flywheel",
                        Url         = "http://www.example.com/flywheel.pdf"
                    }
                }
            };

            var skillRequest = new SkillRequest
            {
                Request = request,
                Context = new Context
                {
                    System = new AlexaSystem()
                    {
                        Application = new Application(), User = new User()
                    }
                },
                Session = new Session()
                {
                    User = new User()
                }
            };

            var alexaMapper = new AlexaRequestMapper();
            var result      = alexaMapper.RequestToActivity(skillRequest);

            JsonConvert.SerializeObject(result,
                                        Newtonsoft.Json.Formatting.None,
                                        new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore,
                Formatting        = Formatting.Indented
            });
        }
        public void IntentRequestMappedReturnsLocale()
        {
            // arrange
            var skillRequest = new SkillRequest
            {
                Request = new IntentRequest()
                {
                    Locale = "en-US",
                    Intent = new Intent()
                    {
                        Slots = new Dictionary <string, Slot>()
                        {
                            { "phrase", new Slot() }
                        }
                    }
                },
                Context = new Context
                {
                    System = new AlexaSystem()
                    {
                        Application = new Application(), User = new User()
                    }
                },
                Session = new Session()
                {
                    User = new User()
                }
            };


            // act
            var alexaMapper = new AlexaRequestMapper();
            var result      = alexaMapper.RequestToActivity(skillRequest);

            // assert
            Assert.Equal("en-US", result.Locale);
        }
 public virtual Activity RequestToActivity(SkillRequest request)
 {
     return(_requestMapper.RequestToActivity(request));
 }