Exemplo n.º 1
0
        public void ShouldBeAbleToDetermineLowFeasability()
        {
            var skill = new FinancialPlanningSkill();

            intent.Name = "FinancialPlanning";
            var result = skill.FunctionHandler(basicRequest, null);

            Assert.AreEqual(result.Response.ShouldEndSession, false);
            Assert.AreEqual((result.Response.OutputSpeech as PlainTextOutputSpeech).Text, FinancialPlanningSkill.GOAL_AMOUNT_QUESTION);

            intent.Name = "SetGoalAmount";
            var slot = new Slot();

            slot.Value = "26000";
            slots[FinancialPlanningSkill.GOAL_AMOUNT_KEY] = slot;
            result = skill.FunctionHandler(basicRequest, null);
            Assert.AreEqual(result.Response.ShouldEndSession, false);
            Assert.AreEqual(session.Attributes[FinancialPlanningSkill.GOAL_AMOUNT_KEY], 26000.0);
            Assert.AreEqual(result.SessionAttributes[FinancialPlanningSkill.GOAL_AMOUNT_KEY], 26000.0);
            Assert.AreEqual((result.Response.OutputSpeech as PlainTextOutputSpeech).Text, FinancialPlanningSkill.INITIAL_SAVINGS_QUESTION);
            slots.Remove(FinancialPlanningSkill.GOAL_AMOUNT_KEY);

            intent.Name = "SetIntialSavings";
            slot        = new Slot();
            slot.Value  = "11000";
            slots[FinancialPlanningSkill.INITIAL_SAVINGS_KEY] = slot;
            result = skill.FunctionHandler(basicRequest, null);
            Assert.AreEqual(result.Response.ShouldEndSession, false);
            Assert.AreEqual(session.Attributes[FinancialPlanningSkill.INITIAL_SAVINGS_KEY], 11000.0);
            Assert.AreEqual(result.SessionAttributes[FinancialPlanningSkill.INITIAL_SAVINGS_KEY], 11000.0);
            Assert.AreEqual((result.Response.OutputSpeech as PlainTextOutputSpeech).Text, FinancialPlanningSkill.MONTHLY_CONTRIBUTION_QUESTION);
            slots.Remove(FinancialPlanningSkill.INITIAL_SAVINGS_KEY);

            intent.Name = "SetMonthlyContribution";
            slot        = new Slot();
            slot.Value  = "150";
            slots[FinancialPlanningSkill.MONTHLY_CONTRIBUTION_KEY] = slot;
            result = skill.FunctionHandler(basicRequest, null);
            Assert.AreEqual(result.Response.ShouldEndSession, false);
            Assert.AreEqual(session.Attributes[FinancialPlanningSkill.MONTHLY_CONTRIBUTION_KEY], 150.0);
            Assert.AreEqual(result.SessionAttributes[FinancialPlanningSkill.MONTHLY_CONTRIBUTION_KEY], 150.0);
            Assert.AreEqual((result.Response.OutputSpeech as PlainTextOutputSpeech).Text, FinancialPlanningSkill.AMOUNT_OF_MONTHS_QUESTION);
            slots.Remove(FinancialPlanningSkill.MONTHLY_CONTRIBUTION_KEY);

            intent.Name = "SetGoalPeriod";
            slot        = new Slot();
            slot.Value  = "12";
            slots[FinancialPlanningSkill.GOAL_PERIOD_KEY] = slot;
            result = skill.FunctionHandler(basicRequest, null);
            Assert.AreEqual(result.Response.ShouldEndSession, true);
            Assert.AreEqual(session.Attributes[FinancialPlanningSkill.GOAL_PERIOD_KEY], 12.0);
            Assert.AreEqual(result.SessionAttributes[FinancialPlanningSkill.GOAL_PERIOD_KEY], 12.0);
            Assert.AreEqual((result.Response.OutputSpeech as PlainTextOutputSpeech).Text, "The feasability of your goal is Low");
        }
Exemplo n.º 2
0
        public void ShouldHandleHelpCorrectlyInFinancialPlanningSkill()
        {
            var skill = new FinancialPlanningSkill();

            intent.Name = "AMAZON.HelpIntent";

            var result = skill.FunctionHandler(basicRequest, null);
            var output = result.Response.OutputSpeech;

            Assert.AreEqual((output as PlainTextOutputSpeech).Text, FinancialPlanningSkill.HELP_MESSAGE);
            Assert.AreEqual(result.Response.ShouldEndSession, true);
        }
Exemplo n.º 3
0
        public void ShouldHandleUnknownIntentInFinancialPlanningSkill()
        {
            var skill = new FinancialPlanningSkill();

            intent.Name = "SomethingElse";

            var result = skill.FunctionHandler(basicRequest, null);
            var output = result.Response.OutputSpeech;

            Assert.AreEqual((output as PlainTextOutputSpeech).Text, FinancialPlanningSkill.GOAL_AMOUNT_QUESTION);
            Assert.AreEqual(result.Response.ShouldEndSession, true);
        }
Exemplo n.º 4
0
        public void ShouldHandleSessionEnded()
        {
            var skill = new FinancialPlanningSkill();

            var request      = new SkillRequest();
            var sessionEnded = new SessionEndedRequest();

            request.Request = sessionEnded;


            var result = skill.FunctionHandler(request, null);
            var output = result.Response.OutputSpeech;

            Assert.AreEqual(result.Response.ShouldEndSession, true);
        }
Exemplo n.º 5
0
        public void ShouldHandleLaunchRequest()
        {
            var skill = new FinancialPlanningSkill();

            var request = new SkillRequest();
            var launch  = new LaunchRequest();

            request.Request = launch;


            var result = skill.FunctionHandler(request, null);
            var output = result.Response.OutputSpeech;

            Assert.AreEqual(result.Response.ShouldEndSession, false);
        }
Exemplo n.º 6
0
        public void ShouldSetVersion()
        {
            var skill = new FinancialPlanningSkill();

            intent.Name = "SetGoalAmount";
            var slot = new Slot();

            slot.Value = "25000";

            slots[FinancialPlanningSkill.GOAL_AMOUNT_KEY] = slot;

            var result = skill.FunctionHandler(basicRequest, null);

            Assert.AreEqual(result.Version, "1.0");
        }
Exemplo n.º 7
0
        public void ShouldBeAbleToSetGoalPeriod()
        {
            var skill = new FinancialPlanningSkill();

            intent.Name = "SetGoalPeriod";
            var slot = new Slot();

            slot.Value = "36";

            slots[FinancialPlanningSkill.GOAL_PERIOD_KEY] = slot;

            var result = skill.FunctionHandler(basicRequest, null);
            var output = result.Response.OutputSpeech;

            Assert.AreEqual(session.Attributes[FinancialPlanningSkill.GOAL_PERIOD_KEY], 36.0);
            Assert.AreEqual(result.Response.ShouldEndSession, false);
        }
Exemplo n.º 8
0
        public void ShouldBeAbleToSetMonthlyContributions()
        {
            var skill = new FinancialPlanningSkill();

            intent.Name = "SetMonthlyContribution";
            var slot = new Slot();

            slot.Value = "500";

            slots[FinancialPlanningSkill.MONTHLY_CONTRIBUTION_KEY] = slot;

            var result = skill.FunctionHandler(basicRequest, null);
            var output = result.Response.OutputSpeech;

            Assert.AreEqual(session.Attributes[FinancialPlanningSkill.MONTHLY_CONTRIBUTION_KEY], 500.0);
            Assert.AreEqual(result.Response.ShouldEndSession, false);
        }
Exemplo n.º 9
0
        public void ShouldBeAbleToSetInitialSavings()
        {
            var skill = new FinancialPlanningSkill();

            intent.Name = "SetIntialSavings";
            var slot = new Slot();

            slot.Value = "10000";

            slots[FinancialPlanningSkill.INITIAL_SAVINGS_KEY] = slot;

            var result = skill.FunctionHandler(basicRequest, null);
            var output = result.Response.OutputSpeech;

            Assert.AreEqual(session.Attributes[FinancialPlanningSkill.INITIAL_SAVINGS_KEY], 10000.0);
            Assert.AreEqual(result.Response.ShouldEndSession, false);
        }
Exemplo n.º 10
0
        public void ShouldHandleAttributesAreInitiallyNull()
        {
            var skill = new FinancialPlanningSkill();

            intent.Name = "SetGoalAmount";
            var slot = new Slot();

            slot.Value = "25000";

            slots[FinancialPlanningSkill.GOAL_AMOUNT_KEY] = slot;

            basicRequest.Session.Attributes = null;
            var result = skill.FunctionHandler(basicRequest, null);
            var output = result.Response.OutputSpeech;

            Assert.AreEqual(session.Attributes[FinancialPlanningSkill.GOAL_AMOUNT_KEY], 25000.0);
            Assert.AreEqual(result.Response.ShouldEndSession, false);
        }