public void IsHandlerForRequest_InputtingLaunchRequest_ReturnsTrue() { LaunchRequestHandler launchRequestHandler = new LaunchRequestHandler(); SkillRequest request = new SkillRequest(); request.Request = new LaunchRequest(); Assert.IsTrue(launchRequestHandler.IsHandlerForRequest(request)); }
public void IsHandlerForRequest_InputtingNonLaunchRequest_ReturnsFalse() { LaunchRequestHandler launchRequestHandler = new LaunchRequestHandler(); SkillRequest request = new SkillRequest(); request.Request = new SessionEndedRequest(); Assert.IsFalse(launchRequestHandler.IsHandlerForRequest(request)); request.Request = new IntentRequest(); Assert.IsFalse(launchRequestHandler.IsHandlerForRequest(request)); }
public SkillResponse FunctionHandler(SkillRequest input, ILambdaContext context) { if (input.GetRequestType() == typeof(ILaunchRequest)) { // Default launch request, let's just let them know what you can do. var launchHandler = new LaunchRequestHandler(input, context); return(launchHandler.HandleRequest()); } else if (input.GetRequestType() == typeof(IIntentRequest)) { // Intent request, process the intent. // It's not currently necessary to route intents (by name) to a request handler since we're only supporting one intent. // Poor man's IoC... var locatorFactory = new FamilyMemberLocatorFactory(); var intentHandler = new FamilyMemberIntentHandler(locatorFactory, input, context); return(intentHandler.HandleRequest()); } return(new SkillResponse()); }
public async Task <SkillResponse> FunctionHandler(APLSkillRequest input, ILambdaContext context) { // core initialization await Core.Init(input, context); // direct request in a matching handler switch (Core.Request.GetMainRequestType()) { // handle launch reqeust case AlexaRequestType.LaunchRequest: LaunchRequestHandler launchRequestHandler = new LaunchRequestHandler(); await launchRequestHandler.HandleRequest(); break; // handle intent request case AlexaRequestType.IntentRequest: IntentReqeustHandler intentRequestHandler = new IntentReqeustHandler(); await intentRequestHandler.HandleRequest(); break; // handle audio player request case AlexaRequestType.AudioPlayerRequest: AudioPlayerRequestHandler audioPlayerRequestHandler = new AudioPlayerRequestHandler(); await audioPlayerRequestHandler.HandleRequest(); break; // handle gui event request case AlexaRequestType.AlexaRequest: AlexaRequestHandler alexaRequestHandler = new AlexaRequestHandler(); await alexaRequestHandler.HandleRequest(); break; // handle session eneded request case AlexaRequestType.SessionEndedRequest: SessionEndedRequestHandler sessionEndedRequestHandler = new SessionEndedRequestHandler(); await sessionEndedRequestHandler.HandleRequest(); break; // handle system exception request case AlexaRequestType.SystemRequest: SystemRequestHandler systemRequestHandler = new SystemRequestHandler(); await systemRequestHandler.HandleRequest(); break; // handle unknown request default: bool endSession = Core.State.UserState.NumReprompt > 5 ? true : false; Core.Logger.Write("Function.FunctionHandler()", "Request was not recognized, directing into the default case handler"); Core.Response.SetSpeech(false, endSession, SpeechTemplate.NoUnderstand); Core.State.UserState.Stage = Stage.Menu; Core.State.UserState.NumReprompt++; if (endSession) { Core.State.UserState.NumReprompt = 0; } break; } // log returning message details Core.Logger.Write("Function.FunctionHandler()", $"Response details: {JsonConvert.SerializeObject(Core.Response.GetResponse())}"); Core.Logger.Write("Function.FunctionHandler()", $"User state details: {JsonConvert.SerializeObject(Core.State)}"); // save database context then return await Core.Database.SaveState(); return(Core.Response.GetResponse()); }
public void IsHandlerForRequest_InputtingNull_ReturnsFalse() { LaunchRequestHandler launchRequestHandler = new LaunchRequestHandler(); Assert.IsFalse(launchRequestHandler.IsHandlerForRequest(null)); }