public void GetRequestHandler_ShouldThrowArgumentNullException_WhenSkillRequestIsInvalid()
        {
            Mock <ISkillRequestValidator> mockSkillRequestValidator = new Mock <ISkillRequestValidator>();

            mockSkillRequestValidator.Setup(x => x.IsValid(It.IsAny <SkillRequest>())).Returns(false);
            Mock <ILogger <RequestMapper> > mockLogger         = new Mock <ILogger <RequestMapper> >();
            List <Mock <IRequestRouter> >   mockRequestRouters = new List <Mock <IRequestRouter> >();

            mockRequestRouters.Add(new Mock <IRequestRouter>());

            RequestMapper sut = new RequestMapper(mockSkillRequestValidator.Object, mockLogger.Object, mockRequestRouters.Select(x => x.Object));

            Assert.Throws <ArgumentNullException>(() => sut.GetRequestHandler(new SkillRequest()));
        }
        public void GetRequestHandler_ShouldThrowNotSupportedException_WhenSkillRequestTypeIsUnknown()
        {
            Mock <ISkillRequestValidator> mockSkillRequestValidator = new Mock <ISkillRequestValidator>();

            mockSkillRequestValidator.Setup(x => x.IsValid(It.IsAny <SkillRequest>())).Returns(true);

            Mock <ILogger <RequestMapper> > mockLogger = new Mock <ILogger <RequestMapper> >();

            Mock <IRequestRouter> mockRequestrouter = new Mock <IRequestRouter>();

            mockRequestrouter.Setup(x => x.RequestType).Returns(RequestType.IntentRequest);

            List <Mock <IRequestRouter> > mockRequestRouters = new List <Mock <IRequestRouter> >();

            mockRequestRouters.Add(mockRequestrouter);

            RequestMapper sut = new RequestMapper(mockSkillRequestValidator.Object, mockLogger.Object, mockRequestRouters.Select(x => x.Object));

            Assert.Throws <Exception>(() => sut.GetRequestHandler(GenerateValidSkillRequest(new UnknownRequest())));
        }
        public void GetRequestHandler_ShouldThrowNotSupportedException_WhenSkillRequestTypeIsPlaybackControllerRequest()
        {
            Mock <ISkillRequestValidator> mockSkillRequestValidator = new Mock <ISkillRequestValidator>();

            mockSkillRequestValidator.Setup(x => x.IsValid(It.IsAny <SkillRequest>())).Returns(true);

            Mock <ILogger <RequestMapper> > mockLogger = new Mock <ILogger <RequestMapper> >();

            Mock <IRequestRouter> mockRequestrouter = new Mock <IRequestRouter>();

            mockRequestrouter.Setup(x => x.RequestType).Returns(RequestType.IntentRequest);

            List <Mock <IRequestRouter> > mockRequestRouters = new List <Mock <IRequestRouter> >();

            mockRequestRouters.Add(mockRequestrouter);

            RequestMapper sut = new RequestMapper(mockSkillRequestValidator.Object, mockLogger.Object, mockRequestRouters.Select(x => x.Object));

            Assert.Throws <NotSupportedException>(() => sut.GetRequestHandler(GenerateValidSkillRequest(new PlaybackControllerRequest()
            {
                RequestId = "TestRequestId", Type = "PlaybackControllerRequestType.Next", Locale = "en-US"
            })));
        }
        public void GetRequestHandler_ShouldReturnSessionEndedRequestHandler_WhenSkillRequestTypeIsSessionEndedRequest()
        {
            Mock <ISkillRequestValidator> mockSkillRequestValidator = new Mock <ISkillRequestValidator>();

            mockSkillRequestValidator.Setup(x => x.IsValid(It.IsAny <SkillRequest>())).Returns(true);

            Mock <ILogger <RequestMapper> > mockLogger = new Mock <ILogger <RequestMapper> >();

            Mock <IRequestRouter> mockRequestrouter = new Mock <IRequestRouter>();

            mockRequestrouter.Setup(x => x.RequestType).Returns(RequestType.SessionEndedRequest);

            List <Mock <IRequestRouter> > mockRequestRouters = new List <Mock <IRequestRouter> >();

            mockRequestRouters.Add(mockRequestrouter);

            RequestMapper  sut = new RequestMapper(mockSkillRequestValidator.Object, mockLogger.Object, mockRequestRouters.Select(x => x.Object));
            IRequestRouter intentRequestHandler = sut.GetRequestHandler(GenerateValidSkillRequest(new SessionEndedRequest()
            {
                RequestId = "TestRequestId", Type = "SessionEndedRequest", Locale = "en-US"
            }));

            Assert.Equal(RequestType.SessionEndedRequest, intentRequestHandler.RequestType);
        }
        public void GetRequestHandler_ShouldReturnConnectionResponseRequestHandler_WhenSkillRequestTypeIsConnectionResponseRequest()
        {
            Mock <ISkillRequestValidator> mockSkillRequestValidator = new Mock <ISkillRequestValidator>();

            mockSkillRequestValidator.Setup(x => x.IsValid(It.IsAny <SkillRequest>())).Returns(true);

            Mock <ILogger <RequestMapper> > mockLogger = new Mock <ILogger <RequestMapper> >();

            Mock <IRequestRouter> mockRequestrouter = new Mock <IRequestRouter>();

            mockRequestrouter.Setup(x => x.RequestType).Returns(RequestType.ConnectionResponseRequest);

            List <Mock <IRequestRouter> > mockRequestRouters = new List <Mock <IRequestRouter> >();

            mockRequestRouters.Add(mockRequestrouter);

            RequestMapper  sut            = new RequestMapper(mockSkillRequestValidator.Object, mockLogger.Object, mockRequestRouters.Select(x => x.Object));
            IRequestRouter requestHandler = sut.GetRequestHandler(GenerateValidSkillRequest(new ConnectionResponseRequest()
            {
                RequestId = "TestRequestId", Type = "Connections.Response", Locale = "en-US"
            }));

            Assert.True(requestHandler != null);
        }