Exemple #1
0
        private ActionResult ShowResult(OutcomeType expectedOutcomeType)
        {
            var referrer = _httpWrapper.UrlReferrer;

            if (referrer == null || !referrer.IsRouteMatch(_httpWrapper.HttpContext, MVC.Questions.Name, MVC.Questions.ActionNames.Index))
            {
                _answerManager.StoreAnswers(_httpWrapper.QueryString);
            }

            var answers   = _answerManager.GetAnswers();
            var questions = _questionManager.GetAllQuestions();

            if (answers.Count < questions.Count)
            {
                return(RedirectToAction(MVC.Home.Index()));
            }

            var dictionary = answers.ToDictionary(x => x.Key.Id, x => x.Value);

            var persona     = _personaManager.GetPersona(dictionary);
            var outcomeType = persona?.OutcomeType ?? OutcomeType.Unsure;

            if (outcomeType != expectedOutcomeType)
            {
                return(RedirectToOutcomeType(outcomeType));
            }

            var visitor     = new Visitor(outcomeType, persona?.Id, dictionary);
            var obligations = _obligationManager.GetObligationsForVisitor(visitor);

            return(View(MVC.Results.Views.ViewNames.Index, new ResultModel {
                Obligations = obligations, Answers = answers, OutcomeType = outcomeType
            }));
        }
Exemple #2
0
        public void MatchesPersona1()
        {
            // Arrange
            IDictionary <string, IAnswer[]> answers = new Dictionary <string, IAnswer[]>();

            answers.Add("Q1", new IAnswer[] { new Answer {
                                                  Id = "A"
                                              } });
            answers.Add("Q2", new IAnswer[] { new Answer {
                                                  Id = "A"
                                              } });
            answers.Add("Q3", new IAnswer[] { new Answer {
                                                  Id = "A"
                                              } });

            // Act
            var persona     = _manager.GetPersona(answers);
            var outcomeType = _manager.GetOutcomeType(answers);

            //Assert
            Assert.IsNotNull(persona);
            Assert.AreEqual("1", persona.Id);
            Assert.AreEqual(OutcomeType.Hobby, outcomeType);
        }